Blame view

src/idl/dustem_init_plugins.pro 3.94 KB
5816c74c   Annie Hughes   made fpd a keyword
1
PRO dustem_init_plugins,pd,fpd=fpd,help=help
392ede91   Jean-Philippe Bernard   included an help ...
2
3
4
5
6
7
8
9
10

;+
; NAME:
;    dustem_init_plugins
; PURPOSE:
;    initializes variable !dustem_plugin
; CATEGORY:
;    DustEMWrap
; CALLING SEQUENCE:
90047618   Annie Hughes   made fpd a keyword
11
;    dustem_init_plugins,pd,[fpd=fpd,help=help]
392ede91   Jean-Philippe Bernard   included an help ...
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
; 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
e7938fa3   Ilyes Choubani   Corrected02: Impl...
42

e7938fa3   Ilyes Choubani   Corrected02: Impl...
43

7f2b2149   Jean-Philippe Bernard   a Ilyes
44
plugin_names=['']
5eebdedb   Jean-Philippe Bernard   changed plugin st...
45
;plugind_detect_string='dustem_plugin'
83b3ddee   Jean-Philippe Bernard   modified with Ily...
46
Nplugins=0L
5eebdedb   Jean-Philippe Bernard   changed plugin st...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
plugin_start_str='dustem_'

Npd=n_elements(pd)
Nfpd=0
IF KEYWORD_SET(fpd) THEN Nfpd=n_elements(fpd)

parameter_types=strarr(Npd+Nfpd)
plugin_names=strarr(Npd+Nfpd)
all_par_names=pd
IF KEYWORD_SET(fpd) THEN all_par_names=[all_par_names,fpd]

FOR i=0L,Npd-1 DO BEGIN
    parameter_types[i]=dustem_parameter_description2type(pd[i],string_name=string_name)
    ;print,string_name
    pos=strposmulti(string_name,'_',ccount)
    IF ccount NE 0 THEN BEGIN
        plugin_name=plugin_start_str+strmid(string_name,0,pos[ccount-1])
    ENDIF ELSE BEGIN
        plugin_name='UNKNOWN'
    ENDELSE
    plugin_names[i]=plugin_name
7f2b2149   Jean-Philippe Bernard   a Ilyes
68
ENDFOR
5eebdedb   Jean-Philippe Bernard   changed plugin st...
69
icount=i
3c479f24   Ilyes Choubani   Allowing to fix p...
70
IF KEYWORD_SET(fpd) THEN BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
71
72
73
74
75
76
77
78
79
    FOR i=0L,n_elements(fpd)-1 DO BEGIN
       parameter_types[icount+i]=dustem_parameter_description2type(fpd[i],string_name=string_name)
       pos=strposmulti(string_name,'_',ccount)
        IF ccount NE 0 THEN BEGIN
            plugin_name=plugin_start_str+strmid(string_name,0,pos[ccount-1])
        ENDIF ELSE BEGIN
            plugin_name='UNKNOWN'
        ENDELSE
       plugin_names[icount+i]=plugin_name
3c479f24   Ilyes Choubani   Allowing to fix p...
80
81
    ENDFOR
ENDIF
607060e5   Ilyes Choubani   test version
82

5eebdedb   Jean-Philippe Bernard   changed plugin st...
83
84
85
86
87
88
89
90
order=sort(plugin_names)
plugin_names=plugin_names[order]
parameter_types=parameter_types[order]
un=uniq(plugin_names)
plugin_names=plugin_names[un]
parameter_types=parameter_types[un]

ind=where(parameter_types EQ 'PLUGIN',Nplugins)
a84e0595   Jean-Philippe Bernard   modified plugin s...
91
92
93
94
95
96
97
;===== This is the dustem structure describing the plugin scopes
one_plugin_st={name:'', $           ;name of the plugin
               spec:ptr_new(), $    ;output of the plugin (a spectrum)
               scope:'', $          ;scope of the plugin
               run_order:0L,  $      ;plugin run order
               paramtag:ptr_new() $ ;parameter names
               }
759a527d   Ilyes Choubani   general update
98

83b3ddee   Jean-Philippe Bernard   modified with Ily...
99
IF Nplugins EQ 0 THEN BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
100
101
    plugin_st=replicate(one_plugin_st,1)
    plugin_st[0].name='NONE'
83b3ddee   Jean-Philippe Bernard   modified with Ily...
102
ENDIF ELSE BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
103
104
105
106
107
    plugin_names=plugin_names[ind]
    plugin_st=replicate(one_plugin_st,Nplugins)
    FOR i=0L,Nplugins-1 DO BEGIN
        plugin_st[i].name=plugin_names[i]
    ENDFOR
83b3ddee   Jean-Philippe Bernard   modified with Ily...
108
109
ENDELSE

5eebdedb   Jean-Philippe Bernard   changed plugin st...
110
111
;==== invok each plugin to get their scopes and parameter tag names
FOR i=0L,Nplugins-1 DO BEGIN
25370043   Jean-Philippe Bernard   src/idl/dustem_ac...
112
    scope=1
5eebdedb   Jean-Philippe Bernard   changed plugin st...
113
114
115
116
    str='toto='+plugin_st[i].name+'(scope=scope)'
    str=str[0]       
    toto=execute(str)
    plugin_st[i].scope=scope
25370043   Jean-Philippe Bernard   src/idl/dustem_ac...
117
    paramtag=1   ;otherwise, paramtag may nt be returned by plugin
5eebdedb   Jean-Philippe Bernard   changed plugin st...
118
119
120
121
122
    str='toto='+plugin_st[i].name+'(paramtag=paramtag)'
    str=str[0]       
    toto=execute(str)
    plugin_st[i].paramtag=ptr_new(paramtag)
ENDFOR
a84e0595   Jean-Philippe Bernard   modified plugin s...
123
124
125
126
127
128
129
130
131
132
133
134
;derive the run order from the scopes
file_scopes=!dustem_wrap_soft_dir+'plugin_scopes_definition.xcat'
scope_st=read_xcat(file_scopes,/silent)
possible_scopes=scope_st.objective+'_'+scope_st.target
FOR i=0L,Nplugins-1 DO BEGIN
    ind=where(possible_scopes EQ plugin_st[i].scope,count)
    IF count EQ 0 THEN BEGIN
        message,'scope '+plugin_st[i].scope+' not recognized',/continue
        stop
    ENDIF
    plugin_st[i].run_order=scope_st[ind[0]].run_order
ENDFOR
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
135

5eebdedb   Jean-Philippe Bernard   changed plugin st...
136
137
;creates the !dustem_plugin structure
defsysv, '!dustem_plugin', ptr_new(plugin_st)
e7938fa3   Ilyes Choubani   Corrected02: Impl...
138

5eebdedb   Jean-Philippe Bernard   changed plugin st...
139
140
141
;help,(*!dustem_plugin),/str
;help,(*!dustem_plugin)[0].scope
;stop
e7938fa3   Ilyes Choubani   Corrected02: Impl...
142

392ede91   Jean-Philippe Bernard   included an help ...
143
the_end:
e7938fa3   Ilyes Choubani   Corrected02: Impl...
144

392ede91   Jean-Philippe Bernard   included an help ...
145
END