Blame view

src/idl/dustem_init_plugins.pro 3.76 KB
759a527d   Ilyes Choubani   general update
1
PRO dustem_init_plugins, pd, fpd
e7938fa3   Ilyes Choubani   Corrected02: Impl...
2

1355825c   Ilyes Choubani   General update
3
4
5
6
;NB: 
;#Fixed parameters still haven't been taken care of
;#There is use of pointers when the need does not present itself. This implies modifying the rest of the code.

e7938fa3   Ilyes Choubani   Corrected02: Impl...
7

4750086c   Ilyes Choubani   nouvelle philosph...
8
;INITIALIZING THE SCOPES DATA ARRAYS--------------------
e7938fa3   Ilyes Choubani   Corrected02: Impl...
9
10
11

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

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

83b3ddee   Jean-Philippe Bernard   modified with Ily...
15
Nplugins=0L
607060e5   Ilyes Choubani   test version
16

7f2b2149   Jean-Philippe Bernard   a Ilyes
17
18
19
20
21
22
23
24
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...
25
        Nplugins=Nplugins+1
7f2b2149   Jean-Philippe Bernard   a Ilyes
26
27
    ENDIF
ENDFOR
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
28

607060e5   Ilyes Choubani   test version
29

759a527d   Ilyes Choubani   general update
30
; ;In the case the plugin is only present in the fixed parameter vector 
af6214c9   Ilyes Choubani   Added Modified-Bl...
31
32
33
34
35
36
37
38
39
40
; 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
;             if isa((*!dustem_fit).fixed_param_descs) then begin
;             
;                 ftn = strmid((*(*!dustem_fit).fixed_param_descs)(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)    
;             
;             endif else  ftn = strmid((*(*!dustem_fit).param_descs)(i),0) 
759a527d   Ilyes Choubani   general update
41
;                             
af6214c9   Ilyes Choubani   Added Modified-Bl...
42
43
44
45
46
47
48
49
50
51
;             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
; 
;     
; ENDIF
607060e5   Ilyes Choubani   test version
52

759a527d   Ilyes Choubani   general update
53

83b3ddee   Jean-Philippe Bernard   modified with Ily...
54
55
56
57
58
59
60
61
62
63
64
65
66
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...
67
68
print, plugin_names

83b3ddee   Jean-Philippe Bernard   modified with Ily...
69
message, 'Nplugins is:',/continue
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
70
71
72
print, Nplugins


9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
73
74
75
76
IF Nplugins NE 0 THEN BEGIN
    
    IF Nplugins GT 1 THEN BEGIN ;case of multiple plugins
    
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
77
78
        arr_ptrs=replicate('ptr_new()',Nplugins)
        str_fin=strjoin(("'"+plugin_names+"'"+','+arr_ptrs),',')
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
79
                
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
80
        str='varvar=create_struct('+str_fin+')'
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
81
        toto=execute(str)
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
82
        
83b3ddee   Jean-Philippe Bernard   modified with Ily...
83
        message, 'varvar is:',/continue
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
84
85
        print, varvar
        
1355825c   Ilyes Choubani   General update
86
        defsysv, '!dustem_scope', ptr_new(varvar) 
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
87
88
89
90
91
    
   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...
92
    ENDELSE 
9e6a6a33   Ilyes Choubani   a JP /BUT HAS FAU...
93
94
95

ENDIF 

759a527d   Ilyes Choubani   general update
96
;defsysv, '!dustem_scope', ptr_new(varvar) commented this recently
e7938fa3   Ilyes Choubani   Corrected02: Impl...
97
;---------------------------------------------
4750086c   Ilyes Choubani   nouvelle philosph...
98

e7938fa3   Ilyes Choubani   Corrected02: Impl...
99
100
101
102
103
104
                                                                                                         
;INITIALIZING THE PLUGIN DATA ARRAYS----------
tgnms=tag_names(varvar)

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

4750086c   Ilyes Choubani   nouvelle philosph...
105
106
    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...
107
108
endfor

759a527d   Ilyes Choubani   general update
109
110
defsysv, '!dustem_plugin', ptr_new(strct)  ; structure that will contain the spectra associated to each plugin. 
defsysv, '!dustem_paramtag', ptr_new(strct)  ; structure that will contain the spectra associated to each plugin.
e7938fa3   Ilyes Choubani   Corrected02: Impl...
111
112
;---------------------------------------------

4750086c   Ilyes Choubani   nouvelle philosph...
113
end