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 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 ENDFOR icount=i IF KEYWORD_SET(fpd) THEN BEGIN 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 ENDFOR ENDIF 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) ;===== 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 } IF Nplugins EQ 0 THEN BEGIN plugin_st=replicate(one_plugin_st,1) plugin_st[0].name='NONE' ENDIF ELSE BEGIN 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 ENDELSE ;==== invok each plugin to get their scopes and parameter tag names FOR i=0L,Nplugins-1 DO BEGIN scope=1 str='toto='+plugin_st[i].name+'(scope=scope)' str=str[0] toto=execute(str) plugin_st[i].scope=scope paramtag=1 ;otherwise, paramtag may nt be returned by plugin str='toto='+plugin_st[i].name+'(paramtag=paramtag)' str=str[0] toto=execute(str) plugin_st[i].paramtag=ptr_new(paramtag) ENDFOR ;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 ;creates the !dustem_plugin structure defsysv, '!dustem_plugin', ptr_new(plugin_st) ;help,(*!dustem_plugin),/str ;help,(*!dustem_plugin)[0].scope ;stop the_end: END