Function dustem_plugin_modify_isrf, key=key, val=val, scope=scope, paramtag=paramtag,help=help ;+ ; NAME: ; dustem_plugin_modify_isrf ; PURPOSE: ; REPLACES THE DEFAULT DUSTEM ISRF with a user-defined one ; CATEGORY: ; DUSTEM Wrapper ; CALLING SEQUENCE: ; dustem_plugin_modify_isrf(key=key,val=val) ; INPUTS: ; None ; OPTIONAL INPUT PARAMETERS: ; key = input parameter number ; val = input parameter value ; key = 1 sets the ISRF file path. The call is placed in the fixed parameters vector. ; It can also mean that G0 or gas.GO is present in PD vector and is thus not handled here. ; key = 2 means G0/gas.G0 isn't present in the PD vector and is handled here. ; The plugin is placed in the parameters vector and G0 is fitted through this plugin. ; if key=1, val = 1 means the !dustem_free1 pointer (containing the user-defined file's directory) is used. ; if key=2, val = value of G0. The file path has supposedly already been defined. ; OUTPUTS: ; None ; OPTIONAL OUTPUT PARAMETERS: ; None ; ACCEPTED KEY-WORDS: ; help = if set, print this help ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; None ; RESTRICTIONS: ; The dustem fortran code must be installed ; The dustem idl wrapper must be installed ; The path of the ISRF must be assigned to one of the dustemwrap free pointers. ; Two calls of the plugin are necessary if fitting of G0 through this plugin is done. ; The user-defined ISRF needs to be on the same dustem ISRF grid. ; PROCEDURE: ; This is a dustem plugin ;- ;- IF keyword_set(help) THEN BEGIN doc_library,'dustem_plugin_modify_isrf' goto,the_end ENDIF IF keyword_set(scope) THEN BEGIN out=0 goto, the_end ENDIF IF keyword_set(paramtag) THEN BEGIN out=0 goto, the_end ENDIF out=0;? G0=1. IF keyword_set(key) THEN BEGIN ind1=where(key EQ 1,count1) ;G0/gas.GO is present in PD vector ind2=where(key EQ 2,count2) ;G0/gas.GO is not present in PD vector IF count1 NE 0 then begin file_idx=val[ind1[0]] file_str = 'file=(*!dustem_free'+strtrim(string(fix(file_idx)),2)+')' toto = execute(file_str) ENDIF IF count2 NE 0 then begin G0=val[ind2[0]] ENDIF ENDIF ;This is because the mathis ISRF is automatically read and written. ;We just need the wavelengths. This means that this wavelength vector is the dustem (IAS) provided one. ;We don't use the ISRF values in this structure to read the mathis ISRF because ;the ISRF in this structure might be the altered one. st=((*!dustem_params).isrf) ;this is just to read the wavelengths ;storing the mathis isrf in variable mathis_isrf - if the user wants to use ma_isrf_dir=!dustem_soft_dir+'data/ISRF_MATHIS.DAT' ma_isrf=dustem_read_isrf(ma_isrf_dir) if isa(file) then user_ISRF = dustem_read_isrf(file) IF isa(ma_isrf) THEN Ncomments=5 ELSE Ncomments=4 c = strarr(Ncomments) ;First and last lines of the new composite ISRF.DAT file c(0)='# DUSTEM: exciting radiation field featuring' IF isa(ma_isrf) THEN BEGIN c(1)='# Mathis ISRF' c(2)='# User ISRF' ENDIF ELSE c(1)='# User ISRF' c(Ncomments-2)='# Nbr of points' c(Ncomments-1)='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)' ;decided to do something else: IF G0 EQ 1. THEN BEGIN IF ((*!dustem_params).g0) NE 1. THEN G0 = ((*!dustem_params).g0) IF ((*!dustem_params).gas.g0) NE 1. THEN G0 = ((*!dustem_params).gas.g0) ENDIF IF isa(ma_isrf) THEN st.isrf=ma_isrf.isrf+user_ISRF/(G0) ELSE st.isrf=user_ISRF ;TEST IF THE PLUGIN WORKSs ; print,'The user_ISRF is:' ; ; print, user_isrf ; ; print, 'Final isrf is:' ; print, st.isrf file=!dustem_dat+'data/ISRF.DAT' openw,unit,file,/get_lun FOR i=0,Ncomments-1 DO BEGIN printf,unit,c(i) ENDFOR n_waves=n_elements(st) printf,unit,n_waves FOR i=0L,n_waves-1 DO BEGIN printf,unit,st(i).lambisrf,st(i).isrf ENDFOR close,unit free_lun,unit out=st.isrf the_end: scope='USER_ISRF' ;paramtag will only matter if G0 is fitted through the plugin. paramtag=['G0'] return, out end