Blame view

src/idl/dustem_init_plugins.pro 2.6 KB
e7938fa3   Ilyes Choubani   Corrected02: Impl...
1
2
3
PRO dustem_init_plugins, pd


4750086c   Ilyes Choubani   nouvelle philosph...
4
;INITIALIZING THE SCOPES DATA ARRAYS--------------------
e7938fa3   Ilyes Choubani   Corrected02: Impl...
5
6
7

varvar=create_struct('varvar',ptr_new())

7f2b2149   Jean-Philippe Bernard   a Ilyes
8
plugin_names=['']
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
9
plugind_detect_string='dustem_plugin'
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
10

83b3ddee   Jean-Philippe Bernard   modified with Ily...
11
Nplugins=0L
7f2b2149   Jean-Philippe Bernard   a Ilyes
12
13
14
15
16
17
18
19
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((*(*!dustem_fit).param_descs)(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]
83b3ddee   Jean-Philippe Bernard   modified with Ily...
20
        Nplugins=Nplugins+1
7f2b2149   Jean-Philippe Bernard   a Ilyes
21
22
    ENDIF
ENDFOR
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
23

83b3ddee   Jean-Philippe Bernard   modified with Ily...
24
25
26
27
28
29
30
31
32
33
34
35
36
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

message, 'plugin_names is:',/continue
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
37
38
print, plugin_names

83b3ddee   Jean-Philippe Bernard   modified with Ily...
39
message, 'Nplugins is:',/continue
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
40
41
42
print, Nplugins


9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
43
44
45
46
IF Nplugins NE 0 THEN BEGIN
    
    IF Nplugins GT 1 THEN BEGIN ;case of multiple plugins
    
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
47
48
        arr_ptrs=replicate('ptr_new()',Nplugins)
        str_fin=strjoin(("'"+plugin_names+"'"+','+arr_ptrs),',')
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
49
                
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
50
        str='varvar=create_struct('+str_fin+')'
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
51
        toto=execute(str)
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
52
        
83b3ddee   Jean-Philippe Bernard   modified with Ily...
53
        message, 'varvar is:',/continue
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
54
55
        print, varvar
        
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
56
57
58
59
60
61
        defsysv, '!dustem_scope', ptr_new(varvar)
    
   ENDIF ELSE BEGIN ;case of one plugin
   
           varvar=create_struct(plugin_names,ptr_new())
           defsysv, '!dustem_scope', ptr_new(varvar)
83b3ddee   Jean-Philippe Bernard   modified with Ily...
62
    ENDELSE 
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
63
64
65
66

ENDIF 


83b3ddee   Jean-Philippe Bernard   modified with Ily...
67
68
;test=(n_tags(varvar) eq 1 && tag_exist(varvar,'varvar'))  
;if test then varvar=create_struct('varvar','ERROR IN DUSTEM_INIT_PLUGINS!')
e7938fa3   Ilyes Choubani   Corrected02: Impl...
69
70
71

defsysv, '!dustem_scope', ptr_new(varvar)
;---------------------------------------------
4750086c   Ilyes Choubani   nouvelle philosph...
72

e7938fa3   Ilyes Choubani   Corrected02: Impl...
73
74
75
76
77
78
                                                                                                         
;INITIALIZING THE PLUGIN DATA ARRAYS----------
tgnms=tag_names(varvar)

for i=0L, n_tags(varvar)-1 do begin

4750086c   Ilyes Choubani   nouvelle philosph...
79
80
    if i eq 0 then strct= create_struct(tgnms(i),ptr_new())
    if i ge 1 then strct= create_struct(strct, tgnms(i),ptr_new())
e7938fa3   Ilyes Choubani   Corrected02: Impl...
81
82
endfor

4750086c   Ilyes Choubani   nouvelle philosph...
83
defsysv, '!dustem_plugin', ptr_new(strct)  ; structure that will contain the spectra associated to each plugin ; how do I insert a whole structure as a fucking tag? 
e7938fa3   Ilyes Choubani   Corrected02: Impl...
84
85
;---------------------------------------------

4750086c   Ilyes Choubani   nouvelle philosph...
86
end