dustem_init_plugins.pro
3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
PRO dustem_init_plugins,pd,fpd=fpd,help=help
;+
; NAME:
; dustem_init_plugins
; PURPOSE:
; initializes variable !dustem_plugin
; CATEGORY:
; DustEMWrap
; CALLING SEQUENCE:
; dustem_init_plugins,pd,[fpd=fpd,help=help]
; INPUTS:
; pd : variable parameters description
; OPTIONAL INPUT PARAMETERS:
; fpd : fixed parameters description
; OUTPUTS:
; None
; OPTIONAL OUTPUT PARAMETERS:
; None
; ACCEPTED KEY-WORDS:
; help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; !dustem_plugin is set
; RESTRICTIONS:
; The DustEM fortran code must be installed
; The DustEMWrap IDL code must be installed
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
;
; MODIFICATION HISTORY:
; Written by Ilyes Choubani
; Evolution details on the DustEMWrap gitlab.
;-
IF keyword_set(help) THEN BEGIN
doc_library,'dustem_init_plugins'
goto,the_end
END
plugin_names=['']
plugind_detect_string='dustem_plugin'
Nplugins=0L
for i=0L,n_elements(pd)-1 do begin
fi=strtrim(strmid(pd(i),0,strlen(plugind_detect_string)),2)
if fi eq plugind_detect_string then begin
ftn = strmid(pd(i),0);strmid((*(*!dustem_fit).param_descs)(i),0) ;Try replacing this ;String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
ii = strsplit(ftn,'_',count=countx)
ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
ftn = strmid(ftn,14,ii-14) ; String containing the name of the plugin without the associated keyword
plugin_names=[plugin_names,ftn]
Nplugins=Nplugins+1
ENDIF
ENDFOR
IF KEYWORD_SET(fpd) THEN BEGIN
for i=0L,n_elements(fpd)-1 do begin
fi=strtrim(strmid(fpd(i),0,strlen(plugind_detect_string)),2)
if fi eq plugind_detect_string then begin
ftn = strmid(fpd(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
ii = strsplit(ftn,'_',count=countx)
ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
ftn = strmid(ftn,14,ii-14) ; String containing the name of the plugin without the associated keyword
plugin_names=[plugin_names,ftn]
Nplugins+=1
ENDIF
ENDFOR
ENDIF
IF Nplugins EQ 0 THEN BEGIN
plugin_names=['NONE']
Nplugins=1
ENDIF ELSE BEGIN
plugin_names=plugin_names[1:*]
order=sort(plugin_names)
plugin_names=plugin_names[order]
un=uniq(plugin_names)
plugin_names=plugin_names[un]
Nplugins=n_elements(plugin_names)
ENDELSE
IF Nplugins NE 0 THEN BEGIN
for i=0L, Nplugins-1 do begin
If i EQ 0 then begin ;probably won't need the freezing part.
strct = create_struct(plugin_names(i),{spec:ptr_new(),scope:ptr_new(),paramtag:ptr_new()});,freeze:{key:ptr_new(),val:ptr_new()}})
endif else begin ;IF i GE 1
strct = create_struct(strct,plugin_names(i),{spec:ptr_new(),scope:ptr_new(),paramtag:ptr_new()});,freeze:{key:ptr_new(),val:ptr_new()}})
endelse
ENDFOR
ENDIF
;---------------------------------------------
defsysv, '!dustem_plugin', ptr_new(strct) ; Need the use of the pointer because dustem_init_plugins is called in dustem_init (avoid conflicting structures error).
the_end:
END