Commit 25370043f0f5cb2be181e0471a40a2d3ca0329af
1 parent
755a4236
Exists in
master
src/idl/dustem_activate_plugins.pro
Showing
12 changed files
with
152 additions
and
149 deletions
Show diff stats
src/idl/dustem_brute_force_fit.pro
@@ -25,7 +25,7 @@ FUNCTION dustem_brute_force_fit,sed $ | @@ -25,7 +25,7 @@ FUNCTION dustem_brute_force_fit,sed $ | ||
25 | ; CALLING SEQUENCE: | 25 | ; CALLING SEQUENCE: |
26 | ; res=dustem_brute_force_fit(sed,table_name,filters[,/normalize][,fact=][,chi2=][,rchi2=][rchi2][best_sed=][,/show_sed][,/nostop][,/reset]) | 26 | ; res=dustem_brute_force_fit(sed,table_name,filters[,/normalize][,fact=][,chi2=][,rchi2=][rchi2][best_sed=][,/show_sed][,/nostop][,/reset]) |
27 | ; INPUTS: | 27 | ; INPUTS: |
28 | -; sed = sed to be fit. Should contain all filters initialy provided to the routine | 28 | +; sed = sed to be fit. Should contain all filters provided to the routine trhough input variable filter |
29 | ; table_name = name of the fits file to be used as a grid (see dustem_make_sed_table.pro for creation) | 29 | ; table_name = name of the fits file to be used as a grid (see dustem_make_sed_table.pro for creation) |
30 | ; filters = filters to be used in the grid table (only used if !dustem_grid does not exist or if /reset) | 30 | ; filters = filters to be used in the grid table (only used if !dustem_grid does not exist or if /reset) |
31 | ; OPTIONAL INPUT PARAMETERS: | 31 | ; OPTIONAL INPUT PARAMETERS: |
@@ -73,6 +73,7 @@ ENDIF | @@ -73,6 +73,7 @@ ENDIF | ||
73 | ;sed must be normalized to NH=1e20 H/cm2 | 73 | ;sed must be normalized to NH=1e20 H/cm2 |
74 | 74 | ||
75 | ;==== test for the existence of a loaded grid and initialize if needed. | 75 | ;==== test for the existence of a loaded grid and initialize if needed. |
76 | +;==== only filters contained in the filters variable are kept in the grid, and the sum of grid seds are recomputed accordingly | ||
76 | defsysv,'!dustem_grid',0,exist=exist | 77 | defsysv,'!dustem_grid',0,exist=exist |
77 | IF exist EQ 0 or keyword_set(reset)THEN BEGIN | 78 | IF exist EQ 0 or keyword_set(reset)THEN BEGIN |
78 | dustem_define_grid,table_name,filters | 79 | dustem_define_grid,table_name,filters |
@@ -82,6 +83,11 @@ seds=!dustem_grid.seds | @@ -82,6 +83,11 @@ seds=!dustem_grid.seds | ||
82 | Nseds=!dustem_grid.Nsed | 83 | Nseds=!dustem_grid.Nsed |
83 | Nfilters=!dustem_grid.Nfilters | 84 | Nfilters=!dustem_grid.Nfilters |
84 | Nparams=!dustem_grid.Nparams | 85 | Nparams=!dustem_grid.Nparams |
86 | +table_params=!dustem_grid.params | ||
87 | +table_pmins=!dustem_grid.pmin_values | ||
88 | +table_pmaxs=!dustem_grid.pmax_values | ||
89 | +;dustem_grid={Nsed:Nsed,Nfilters:Nfilters,Nparams:Ntparams,filters:filters,params:table_params,seds:st,pmin_values:table_pmins,pmax_values:table_pmaxs} | ||
90 | + | ||
85 | chi2s=dblarr(Nseds) | 91 | chi2s=dblarr(Nseds) |
86 | grid_seds=dblarr(Nseds,Nfilters) | 92 | grid_seds=dblarr(Nseds,Nfilters) |
87 | total_seds=dblarr(Nseds) | 93 | total_seds=dblarr(Nseds) |
@@ -128,21 +134,30 @@ ind=where(chi2s EQ chi2,count) | @@ -128,21 +134,30 @@ ind=where(chi2s EQ chi2,count) | ||
128 | 134 | ||
129 | params=grid_param_values[ind[0],*] ;these are the best fit parameters | 135 | params=grid_param_values[ind[0],*] ;these are the best fit parameters |
130 | fact=facts[ind[0]] ; This is the corresponding scaling factor | 136 | fact=facts[ind[0]] ; This is the corresponding scaling factor |
131 | -Nfreedom=Nseds-Nparams-1 ;This is the degree of freedom | 137 | +Nfreedom=Nfilters-Nparams-1 ;This is the degree of freedom |
132 | rchi2=chi2/Nfreedom ;This is the reduced chi2 | 138 | rchi2=chi2/Nfreedom ;This is the reduced chi2 |
133 | best_grid_sed=reform(grid_seds[ind[0],*]) ;This is the best SED fround in the grid. | 139 | best_grid_sed=reform(grid_seds[ind[0],*]) ;This is the best SED fround in the grid. |
134 | best_sed=best_grid_sed*fact ;This is the best scaled grid SED matching the input SED. | 140 | best_sed=best_grid_sed*fact ;This is the best scaled grid SED matching the input SED. |
135 | 141 | ||
136 | ;==== should check bumping to table edges there | 142 | ;==== should check bumping to table edges there |
137 | -;params_hit=intarr(Nparams) | ||
138 | -;FOR i=0L,Nparams-1 DO BEGIN | ||
139 | -; IF params[i] EQ minvalues[i] THEN params_hit[i]=-1 | ||
140 | -; IF params[i] EQ maxvalues[i] THEN params_hit[i]=1 | ||
141 | -;ENDFOR | 143 | +params_hit=intarr(Nparams) |
144 | +FOR i=0L,Nparams-1 DO BEGIN | ||
145 | + IF params[i] EQ table_pmins[i] THEN params_hit[i]=-1 | ||
146 | + IF params[i] EQ table_pmaxs[i] THEN params_hit[i]=1 | ||
147 | +ENDFOR | ||
142 | 148 | ||
143 | ;==== should compute parameter uncertainties there | 149 | ;==== should compute parameter uncertainties there |
150 | +;stop | ||
144 | conf_level=90./100. | 151 | conf_level=90./100. |
145 | -dchi2=delta_chi2(Nfreedom,conf_level) | 152 | +;print,Nfreedom,conf_level |
153 | +IF Nfreedom NE 0. THEN BEGIN | ||
154 | + dchi2=delta_chi2(Nfreedom,conf_level) | ||
155 | +ENDIF ELSE BEGIN | ||
156 | + message,'Nfreedom = 0. Beware of meaningless fit',/continue | ||
157 | + stop | ||
158 | + message,'seting Nfreedom = 1. Beware of meaningless fit',/continue | ||
159 | + dchi2=delta_chi2(1.,conf_level) | ||
160 | +ENDELSE | ||
146 | ind=where(chi2s LE chi2+dchi2,count) | 161 | ind=where(chi2s LE chi2+dchi2,count) |
147 | params_min=fltarr(Nparams) | 162 | params_min=fltarr(Nparams) |
148 | params_max=fltarr(Nparams) | 163 | params_max=fltarr(Nparams) |
src/idl/dustem_define_grid.pro
1 | -PRO dustem_define_grid,table_name,filters,help=help | 1 | +PRO dustem_define_grid,table_name,filters,help=help, $ |
2 | + table_params=table_params,table_pmins=table_pmins,table_pmaxs=table_pmaxs,table_pnvals=table_pnvals,table_plogs=table_plogs | ||
2 | 3 | ||
3 | ;+ | 4 | ;+ |
4 | ; NAME: | 5 | ; NAME: |
@@ -8,7 +9,7 @@ PRO dustem_define_grid,table_name,filters,help=help | @@ -8,7 +9,7 @@ PRO dustem_define_grid,table_name,filters,help=help | ||
8 | ; CATEGORY: | 9 | ; CATEGORY: |
9 | ; Dustem | 10 | ; Dustem |
10 | ; CALLING SEQUENCE: | 11 | ; CALLING SEQUENCE: |
11 | -; dustem_define_grid,table_name,filters | 12 | +; dustem_define_grid,table_name,filters[,table_params=][,table_pmins=][,table_pmaxs=][,table_pnvals=][,table_plogs=] |
12 | ; INPUTS: | 13 | ; INPUTS: |
13 | ; table_name : fits file name containing the grid | 14 | ; table_name : fits file name containing the grid |
14 | ; filters : name of dustemwrap filters to be included in the GRID | 15 | ; filters : name of dustemwrap filters to be included in the GRID |
@@ -17,7 +18,11 @@ PRO dustem_define_grid,table_name,filters,help=help | @@ -17,7 +18,11 @@ PRO dustem_define_grid,table_name,filters,help=help | ||
17 | ; OUTPUTS: | 18 | ; OUTPUTS: |
18 | ; None | 19 | ; None |
19 | ; OPTIONAL OUTPUT PARAMETERS: | 20 | ; OPTIONAL OUTPUT PARAMETERS: |
20 | -; None | 21 | +; table_params= parameter names in the grid table |
22 | +; table_pmins= parameter min values in the grid table | ||
23 | +; table_pmaxs= parameter max values in the grid table | ||
24 | +; table_pnvals= parameter number of values in the grid table | ||
25 | +; table_plogs= 1=parameter values in log in the grid table, 0=linear | ||
21 | ; ACCEPTED KEY-WORDS: | 26 | ; ACCEPTED KEY-WORDS: |
22 | ; help = If set, print this help | 27 | ; help = If set, print this help |
23 | ; COMMON BLOCKS: | 28 | ; COMMON BLOCKS: |
src/idl/dustem_init_params.pro
@@ -194,6 +194,7 @@ if keyword_set(polarization) and polexists eq 0 then $ | @@ -194,6 +194,7 @@ if keyword_set(polarization) and polexists eq 0 then $ | ||
194 | ; basic sanity checking of plugins | 194 | ; basic sanity checking of plugins |
195 | ; to be written | 195 | ; to be written |
196 | 196 | ||
197 | +;stop | ||
197 | ;== INITIALIZE DUST MODEL PARAMETERS and PLUGIN FREE PARAMETERS | 198 | ;== INITIALIZE DUST MODEL PARAMETERS and PLUGIN FREE PARAMETERS |
198 | dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims,fixed=fixed,tied=tied | 199 | dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims,fixed=fixed,tied=tied |
199 | 200 | ||
@@ -203,7 +204,9 @@ IF not keyword_set(no_reset_plugin_structure) THEN BEGIN | @@ -203,7 +204,9 @@ IF not keyword_set(no_reset_plugin_structure) THEN BEGIN | ||
203 | ENDIF | 204 | ENDIF |
204 | 205 | ||
205 | ;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODEL AND PLUGINS | 206 | ;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODEL AND PLUGINS |
206 | -if keyword_set(fpd) then dustem_init_fixed_params,fpd,fiv | 207 | +IF keyword_set(fpd) THEN BEGIN |
208 | + dustem_init_fixed_params,fpd,fiv | ||
209 | +ENDIF | ||
207 | 210 | ||
208 | message,'Finished initializing free and fixed parameters of dust model and plugins',/info | 211 | message,'Finished initializing free and fixed parameters of dust model and plugins',/info |
209 | 212 |
src/idl/dustem_init_plugins.pro
@@ -103,11 +103,12 @@ ENDELSE | @@ -103,11 +103,12 @@ ENDELSE | ||
103 | 103 | ||
104 | ;==== invok each plugin to get their scopes and parameter tag names | 104 | ;==== invok each plugin to get their scopes and parameter tag names |
105 | FOR i=0L,Nplugins-1 DO BEGIN | 105 | FOR i=0L,Nplugins-1 DO BEGIN |
106 | + scope=1 | ||
106 | str='toto='+plugin_st[i].name+'(scope=scope)' | 107 | str='toto='+plugin_st[i].name+'(scope=scope)' |
107 | str=str[0] | 108 | str=str[0] |
108 | toto=execute(str) | 109 | toto=execute(str) |
109 | plugin_st[i].scope=scope | 110 | plugin_st[i].scope=scope |
110 | - | 111 | + paramtag=1 ;otherwise, paramtag may nt be returned by plugin |
111 | str='toto='+plugin_st[i].name+'(paramtag=paramtag)' | 112 | str='toto='+plugin_st[i].name+'(paramtag=paramtag)' |
112 | str=str[0] | 113 | str=str[0] |
113 | toto=execute(str) | 114 | toto=execute(str) |
src/idl/dustem_make_sed_table.pro
@@ -9,6 +9,8 @@ PRO dustem_make_sed_table,model, $ | @@ -9,6 +9,8 @@ PRO dustem_make_sed_table,model, $ | ||
9 | filters=filters, $ | 9 | filters=filters, $ |
10 | log=log, $ | 10 | log=log, $ |
11 | show_seds=show_seds, $ | 11 | show_seds=show_seds, $ |
12 | + use_isrf_class=use_isrf_class, $ | ||
13 | + isrf_class=isrf_class, $ | ||
12 | help=help | 14 | help=help |
13 | 15 | ||
14 | ;+ | 16 | ;+ |
@@ -31,6 +33,7 @@ PRO dustem_make_sed_table,model, $ | @@ -31,6 +33,7 @@ PRO dustem_make_sed_table,model, $ | ||
31 | ; filters : name of dustemwrap filters to be included in the SED calculations (default = IRAS filters) | 33 | ; filters : name of dustemwrap filters to be included in the SED calculations (default = IRAS filters) |
32 | ; fpd : fixed parameter description | 34 | ; fpd : fixed parameter description |
33 | ; fiv : fixed parameter values | 35 | ; fiv : fixed parameter values |
36 | +; isrf_class ; If set use_isrf_class is set, uses ISRF from this PHANGs ISRF class | ||
34 | ; filename : output fits file name for the table (default ='/tmp/dustem_seds.fits') | 37 | ; filename : output fits file name for the table (default ='/tmp/dustem_seds.fits') |
35 | ; log : array indicating if a given parameter is to be sampled in linear (0) or log scale (1) | 38 | ; log : array indicating if a given parameter is to be sampled in linear (0) or log scale (1) |
36 | ; show_seds : if set, plots SEDs as they are computed. | 39 | ; show_seds : if set, plots SEDs as they are computed. |
@@ -39,6 +42,7 @@ PRO dustem_make_sed_table,model, $ | @@ -39,6 +42,7 @@ PRO dustem_make_sed_table,model, $ | ||
39 | ; OPTIONAL OUTPUT PARAMETERS: | 42 | ; OPTIONAL OUTPUT PARAMETERS: |
40 | ; None | 43 | ; None |
41 | ; ACCEPTED KEY-WORDS: | 44 | ; ACCEPTED KEY-WORDS: |
45 | +; use_isrf_class = If set, uses ISRF from a given PHANGs ISRF class | ||
42 | ; help = If set, print this help | 46 | ; help = If set, print this help |
43 | ; COMMON BLOCKS: | 47 | ; COMMON BLOCKS: |
44 | ; None | 48 | ; None |
@@ -132,14 +136,15 @@ dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext | @@ -132,14 +136,15 @@ dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext | ||
132 | ;=== initialize at least one parameter as 'free' | 136 | ;=== initialize at least one parameter as 'free' |
133 | ;=== this is only to keep dustemwrap happy in its management of variables | 137 | ;=== this is only to keep dustemwrap happy in its management of variables |
134 | ;=== no fitting is going to be done | 138 | ;=== no fitting is going to be done |
135 | -pd = ['(*!dustem_params).gas.G0'] ; G0 | ||
136 | -pval = [1.] | 139 | +;pd = ['(*!dustem_params).gas.G0'] ; G0 |
140 | +;pval = [-1.e-20] | ||
141 | +pd=parameters_description | ||
137 | 142 | ||
138 | ;=== declare some other parameters as fixed | 143 | ;=== declare some other parameters as fixed |
139 | ;=== this shows how to add any non-dust plugins to the observed spectra/SED | 144 | ;=== this shows how to add any non-dust plugins to the observed spectra/SED |
140 | ;=== for the dust-model parameters, it is not necessary, but allows the | 145 | ;=== for the dust-model parameters, it is not necessary, but allows the |
141 | ;=== user to (i) change default values and (2) see the adopted values in the graphical output windows | 146 | ;=== user to (i) change default values and (2) see the adopted values in the graphical output windows |
142 | -fpd=parameters_description | 147 | +;fpd=parameters_description |
143 | seds=ptrarr(Nc) | 148 | seds=ptrarr(Nc) |
144 | yrange=[1.e-5,1.e5] | 149 | yrange=[1.e-5,1.e5] |
145 | colors=long(range_gen(Nc,[0,255])) | 150 | colors=long(range_gen(Nc,[0,255])) |
@@ -149,13 +154,16 @@ FOR i=0L,Nc-1 DO BEGIN | @@ -149,13 +154,16 @@ FOR i=0L,Nc-1 DO BEGIN | ||
149 | ;dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext | 154 | ;dustem_set_data,m_fit=sed,m_show=sed,x_fit=ext,x_show=ext |
150 | dummy=0 ;otherwise model is not recomputed !! | 155 | dummy=0 ;otherwise model is not recomputed !! |
151 | 156 | ||
152 | - fpval = *parameter_values[i] | ||
153 | - | 157 | + ;fpval = *parameter_values[i] |
158 | + pval = *parameter_values[i] | ||
154 | message,'================= computing model '+strtrim(i,2)+'/'+strtrim(Nc,2)+' ('+strtrim(1.*i/Nc*100.)+'%)',/continue | 159 | message,'================= computing model '+strtrim(i,2)+'/'+strtrim(Nc,2)+' ('+strtrim(1.*i/Nc*100.)+'%)',/continue |
155 | - print,'parameter_values=',fpval | 160 | + ;print,'parameter_values=',fpval |
161 | + print,'parameter_values=',pval | ||
156 | 162 | ||
157 | ;=== initialise all this information into dustemwrap's brain | 163 | ;=== initialise all this information into dustemwrap's brain |
158 | - dustem_init_params,model,pd,pval,fpd=fpd,fiv=fpval,pol=use_polarisation | 164 | + ;stop |
165 | + ;dustem_init_params,model,pd,pval,fpd=fpd,fiv=fpval,pol=use_polarisation | ||
166 | + dustem_init_params,model,pd,pval,fpd=fpd,fiv=fiv,pol=use_polarisation | ||
159 | 167 | ||
160 | ;=== compute the predicted SED and extinction curve for the dust-model | 168 | ;=== compute the predicted SED and extinction curve for the dust-model |
161 | ;=== and any plugins | 169 | ;=== and any plugins |
@@ -196,11 +204,11 @@ FOR i=0L,Nc-1 DO BEGIN | @@ -196,11 +204,11 @@ FOR i=0L,Nc-1 DO BEGIN | ||
196 | ;==== fill in dependent columns of the SED. | 204 | ;==== fill in dependent columns of the SED. |
197 | sed=dustem_fill_sed_dependent_columns(sed) | 205 | sed=dustem_fill_sed_dependent_columns(sed) |
198 | seds[i]=ptr_new(sed) | 206 | seds[i]=ptr_new(sed) |
199 | - tit='Grid SEDs model '+model | ||
200 | - xtit='Wavelength [mic]' | ||
201 | - ytit='SED [MJy/sr for NH=1.e20 H/cm^2]' | ||
202 | - IF keyword_set(show_seds) THEN BEGIN | 207 | + IF keyword_set(show_seds) THEN BEGIN |
203 | IF i EQ 0 THEN BEGIN | 208 | IF i EQ 0 THEN BEGIN |
209 | + tit='Grid SEDs model '+model | ||
210 | + xtit='Wavelength [mic]' | ||
211 | + ytit='SED [MJy/sr for NH=1.e20 H/cm^2]' | ||
204 | cgplot,(*seds[i]).wave,(*seds[i]).stokesI,psym=-4,/ylog,yr=yrange,xtit=xtit,ytit=ytit,tit=tit,/xlog | 212 | cgplot,(*seds[i]).wave,(*seds[i]).stokesI,psym=-4,/ylog,yr=yrange,xtit=xtit,ytit=ytit,tit=tit,/xlog |
205 | ENDIF ELSE BEGIN | 213 | ENDIF ELSE BEGIN |
206 | cgoplot,(*seds[i]).wave,(*seds[i]).stokesI,psym=-4,color=colors[i] | 214 | cgoplot,(*seds[i]).wave,(*seds[i]).stokesI,psym=-4,color=colors[i] |
src/idl/dustem_param_range2param_values.pro
src/idl/dustem_plot_dataset.pro
@@ -3183,6 +3183,7 @@ if keyword_set(dataset) then begin ; | @@ -3183,6 +3183,7 @@ if keyword_set(dataset) then begin ; | ||
3183 | testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O' | 3183 | testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O' |
3184 | 3184 | ||
3185 | IF parameter_type EQ 'PLUGIN' THEN BEGIN | 3185 | IF parameter_type EQ 'PLUGIN' THEN BEGIN |
3186 | + ;stop | ||
3186 | mm = where((*!dustem_plugin).name EQ plugin_name,count) ; ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector | 3187 | mm = where((*!dustem_plugin).name EQ plugin_name,count) ; ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector |
3187 | prmtg = (*(*!dustem_plugin)[mm].paramtag) ;these are all plugin parameter names | 3188 | prmtg = (*(*!dustem_plugin)[mm].paramtag) ;these are all plugin parameter names |
3188 | indtg=key | 3189 | indtg=key |
src/idl/dustem_plugin_phangs_stellar_continuum.pro
@@ -15,20 +15,21 @@ FUNCTION dustem_plugin_phangs_stellar_continuum,key=key $ | @@ -15,20 +15,21 @@ FUNCTION dustem_plugin_phangs_stellar_continuum,key=key $ | ||
15 | ; CATEGORY: | 15 | ; CATEGORY: |
16 | ; DustEM, Distributed, Mid-Level, Plugin | 16 | ; DustEM, Distributed, Mid-Level, Plugin |
17 | ; CALLING SEQUENCE: | 17 | ; CALLING SEQUENCE: |
18 | -; stellar_brightness=dustem_plugin_phangs_stellar_continuum([,key=][,val=][,scope=][,paramtag=][paramdefault=][,/help]) | 18 | +; stellar_ISRF=dustem_plugin_phangs_stellar_continuum([,key=][,val=][,scope=][,paramtag=][paramdefault=][,/help]) |
19 | ; INPUTS: | 19 | ; INPUTS: |
20 | ; None | 20 | ; None |
21 | ; OPTIONAL INPUT PARAMETERS: | 21 | ; OPTIONAL INPUT PARAMETERS: |
22 | ; key = input parameter number | 22 | ; key = input parameter number |
23 | -; First parameter: E(B-V) for extinction applied to the template, as used in Phangs | 23 | +; First parameter: Amplitude factor for the emission |
24 | +; Second parameter: E(B-V) for extinction to stars applied to the template, as used in Phangs | ||
24 | ; Following 13*6 parameters are weights by which to multiply the MILES templates [Msun/pc^2] | 25 | ; Following 13*6 parameters are weights by which to multiply the MILES templates [Msun/pc^2] |
25 | ; val = corresponding input parameter value | 26 | ; val = corresponding input parameter value |
26 | ; OUTPUTS: | 27 | ; OUTPUTS: |
27 | -; stellar_brightness = stellar spectrum spectrum resampled on dustem wavelengths [MJy/sr] | 28 | +; stellar_isrf = stellar ISRF spectrum resampled on dustem wavelengths [MJy/sr] |
28 | ; OPTIONAL OUTPUT PARAMETERS: | 29 | ; OPTIONAL OUTPUT PARAMETERS: |
29 | -; scope = scope of the plugin | 30 | +; scope = if set, return the scope of the plugin |
30 | ; paramdefault = default values of parameters | 31 | ; paramdefault = default values of parameters |
31 | -; paramtag = plugin parameter names as strings | 32 | +; paramtag = if set, return the return plugin parameter names as strings |
32 | ; ACCEPTED KEY-WORDS: | 33 | ; ACCEPTED KEY-WORDS: |
33 | ; help = if set, print this help | 34 | ; help = if set, print this help |
34 | ; method = SSP used. can be EMILES or CB19. default='EMILES' | 35 | ; method = SSP used. can be EMILES or CB19. default='EMILES' |
@@ -56,7 +57,8 @@ IF keyword_set(help) THEN BEGIN | @@ -56,7 +57,8 @@ IF keyword_set(help) THEN BEGIN | ||
56 | goto,the_end | 57 | goto,the_end |
57 | ENDIF | 58 | ENDIF |
58 | 59 | ||
59 | -IF keyword_set(scope) THEN BEGIN | 60 | +IF keyword_set(scope) THEN BEGIN |
61 | + scope='ADD_SED' | ||
60 | out=0 | 62 | out=0 |
61 | goto, the_scope | 63 | goto, the_scope |
62 | ENDIF | 64 | ENDIF |
@@ -95,7 +97,7 @@ metalicity_values=[-1.48630, -0.961400, -0.351200, +0.0600000, +0.255900, +0.397 | @@ -95,7 +97,7 @@ metalicity_values=[-1.48630, -0.961400, -0.351200, +0.0600000, +0.255900, +0.397 | ||
95 | 97 | ||
96 | Nage=n_elements(age_values) | 98 | Nage=n_elements(age_values) |
97 | Nmetalicity=n_elements(metalicity_values) | 99 | Nmetalicity=n_elements(metalicity_values) |
98 | -Nparam=Nage*Nmetalicity+2 ;+2 is for Amplitude and opacity | 100 | +Nparam=Nage*Nmetalicity+2 ;+2 is for Amplitude and E(B-V) |
99 | 101 | ||
100 | ;==== define parameter tags | 102 | ;==== define parameter tags |
101 | IF keyword_set(paramtag) THEN BEGIN | 103 | IF keyword_set(paramtag) THEN BEGIN |
@@ -170,6 +172,7 @@ FOR i=2L,Nparam-1 DO BEGIN | @@ -170,6 +172,7 @@ FOR i=2L,Nparam-1 DO BEGIN | ||
170 | output[*,0]=output[*,0]+paramvalues[i]*Mstar*ssp | 172 | output[*,0]=output[*,0]+paramvalues[i]*Mstar*ssp |
171 | message,'Mstar='+strtrim(Mstar,2)+' paramvalue='+strtrim(paramvalues[i],2),/info | 173 | message,'Mstar='+strtrim(Mstar,2)+' paramvalue='+strtrim(paramvalues[i],2),/info |
172 | ;ENDIF | 174 | ;ENDIF |
175 | + ;stop | ||
173 | ENDIF | 176 | ENDIF |
174 | ENDFOR | 177 | ENDFOR |
175 | output[*,0]=output[*,0]*paramvalues[0] | 178 | output[*,0]=output[*,0]*paramvalues[0] |
@@ -201,7 +204,11 @@ fact=fact2*fact3*fact4 | @@ -201,7 +204,11 @@ fact=fact2*fact3*fact4 | ||
201 | ;==== reden spectrum using Calzetti's extinction law (which is what Phangs does) | 204 | ;==== reden spectrum using Calzetti's extinction law (which is what Phangs does) |
202 | ;cgplot,lambir,flux,/xlog,/ylog | 205 | ;cgplot,lambir,flux,/xlog,/ylog |
203 | ;factor -1 is to reden, instead of unreden. factor 1e4 is to go from microns to Angstroem | 206 | ;factor -1 is to reden, instead of unreden. factor 1e4 is to go from microns to Angstroem |
207 | +;This uses the prescription of Calzetti et al 2000. It is applied from 912AA to 2.2 mic, no correction applied before and beyound that. | ||
208 | +;Note that the supplied color excess should be that derived for the stellar continuum, EBV(stars), which (in Calzetti 2000) is related to the | ||
209 | +;reddening derived from the gas, EBV(gas), via the Balmer decrement by EBV(stars) = 0.44*EBV(gas) | ||
204 | calz_unred, lambir*1.e4, output[*,0], -1.*paramvalues[1], flux_red, R_V = R_V | 210 | calz_unred, lambir*1.e4, output[*,0], -1.*paramvalues[1], flux_red, R_V = R_V |
211 | +;Note: we could actually use our own dustemwrap extinction curve to do that. | ||
205 | output[*,0]=flux_red | 212 | output[*,0]=flux_red |
206 | 213 | ||
207 | no_unred: | 214 | no_unred: |
@@ -214,7 +221,6 @@ output[*,0]=output[*,0]*fact | @@ -214,7 +221,6 @@ output[*,0]=output[*,0]*fact | ||
214 | ;stop | 221 | ;stop |
215 | 222 | ||
216 | the_scope: | 223 | the_scope: |
217 | -scope='ADD_SED' | ||
218 | 224 | ||
219 | the_paramtag: | 225 | the_paramtag: |
220 | 226 |
src/idl/dustem_read_cb19_stellar_templates.pro
@@ -67,7 +67,8 @@ Z=alog10(Z/Z0) | @@ -67,7 +67,8 @@ Z=alog10(Z/Z0) | ||
67 | ; -2.18299 -1.88196 -1.48401 -1.18298 -0.881955 -0.580925 -0.404834 -0.279895 -0.182985 -0.0368569 0.0474640 0.118045 0.294136 0.419075 0.595166 | 67 | ; -2.18299 -1.88196 -1.48401 -1.18298 -0.881955 -0.580925 -0.404834 -0.279895 -0.182985 -0.0368569 0.0474640 0.118045 0.294136 0.419075 0.595166 |
68 | NZ=n_elements(Z) | 68 | NZ=n_elements(Z) |
69 | 69 | ||
70 | -dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/CB2019/CB19_Chabrier/Mu100/' | 70 | +dir_templates=!phangs_data_dir+'/SSPs/CB2019/CB19_Chabrier/Mu100/' |
71 | +;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/CB2019/CB19_Chabrier/Mu100/' | ||
71 | files=file_search(dir_templates+'*.fits') | 72 | files=file_search(dir_templates+'*.fits') |
72 | Nfiles=n_elements(files) | 73 | Nfiles=n_elements(files) |
73 | ;metalicities=fltarr(Nfiles) | 74 | ;metalicities=fltarr(Nfiles) |
src/idl/dustem_read_emiles_stellar_templates.pro
@@ -53,7 +53,8 @@ IF keyword_set(help) THEN BEGIN | @@ -53,7 +53,8 @@ IF keyword_set(help) THEN BEGIN | ||
53 | END | 53 | END |
54 | 54 | ||
55 | ;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch/' | 55 | ;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch/' |
56 | -dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch_extended/' | 56 | +dir_templates=!phangs_data_dir+'/SSPs/ssp_emiles-ch_extended/' |
57 | +;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch_extended/' | ||
57 | 58 | ||
58 | ;read templates info file | 59 | ;read templates info file |
59 | ;IMF slope Z Age Mtotal M(*+remn) M* Mremn Mgas M(*+remn)/Lv M*/Lv Mv unknown | 60 | ;IMF slope Z Age Mtotal M(*+remn) M* Mremn Mgas M(*+remn)/Lv M*/Lv Mv unknown |
src/idl/dustem_set_params.pro
@@ -86,13 +86,8 @@ FOR i=0L,Nparams-1 DO BEGIN | @@ -86,13 +86,8 @@ FOR i=0L,Nparams-1 DO BEGIN | ||
86 | 86 | ||
87 | ;Not to be used for the moment. | 87 | ;Not to be used for the moment. |
88 | 88 | ||
89 | - | ||
90 | - | ||
91 | END | 89 | END |
92 | ENDCASE | 90 | ENDCASE |
93 | - | ||
94 | - | ||
95 | - | ||
96 | ENDFOR | 91 | ENDFOR |
97 | 92 | ||
98 | dustem_write_all,*!dustem_params,!dustem_dat | 93 | dustem_write_all,*!dustem_params,!dustem_dat |
src/idl/dustem_write_isrf_release.pro
@@ -59,7 +59,7 @@ ENDIF | @@ -59,7 +59,7 @@ ENDIF | ||
59 | ;IF PLUGINS AREN'T SET. WRITE THE DEFAULT DUSTEM ISRF.DAT FILE | 59 | ;IF PLUGINS AREN'T SET. WRITE THE DEFAULT DUSTEM ISRF.DAT FILE |
60 | Nplugins=n_elements(*!dustem_plugin) | 60 | Nplugins=n_elements(*!dustem_plugin) |
61 | scopes = strarr(Nplugins) | 61 | scopes = strarr(Nplugins) |
62 | -IF (*!dustem_plugin)[0].name EQ 'NONE' THEN GOTO, the_after | 62 | +IF (*!dustem_plugin)[0].name EQ 'NONE' THEN GOTO,write_isrf_file |
63 | 63 | ||
64 | ;IF PLUGINS ARE SET, LOOP OVER THEIR SCOPES. | 64 | ;IF PLUGINS ARE SET, LOOP OVER THEIR SCOPES. |
65 | ;Getting the actual scopes | 65 | ;Getting the actual scopes |
@@ -69,141 +69,108 @@ FOR i=0L, Nplugins-1 DO BEGIN | @@ -69,141 +69,108 @@ FOR i=0L, Nplugins-1 DO BEGIN | ||
69 | ;ENDIF ELSE goto, the_after | 69 | ;ENDIF ELSE goto, the_after |
70 | ENDFOR | 70 | ENDFOR |
71 | 71 | ||
72 | -;TESTING FOR THE TWO CURRENT ISRF PLUGINS | ||
73 | -tstpop = where(scopes EQ 'STELLAR_POPULATION',ctpop) | ||
74 | -;tstusrisrf = where(scopes EQ 'USER_ISRF',ctusrisrf) | ||
75 | -tstusrisrf = where(scopes EQ 'REPLACE_ISRF',ctusrisrf) | 72 | +Ncomments=3 ;default number of comments in the .DAT file (minus the ISRF used) |
73 | +c=strarr(Ncomments) | ||
74 | +c[*]='#' | ||
75 | +c[0]='# DUSTEM_WRAP: Interstellar radiation field ' | ||
76 | + | ||
77 | +;Testing for the two current ISRF plugin scopes | ||
78 | +ind_replace_isrf = where(scopes EQ 'REPLACE_ISRF',count_replace_isrf) | ||
79 | +ind_add_isrf = where(scopes EQ 'ADD_ISRF',count_add_isrf) | ||
76 | 80 | ||
77 | -IF ctpop NE 0 or ctusrisrf NE 0 THEN BEGIN | ||
78 | - ;stop | 81 | +;stop |
79 | 82 | ||
83 | +IF count_add_isrf NE 0 OR count_replace_isrf NE 0 THEN BEGIN | ||
84 | + lambir=dustem_get_wavelengths() | ||
85 | + ;IF ctpop NE 0 or ctusrisrf NE 0 THEN BEGIN | ||
80 | ;NB: Since we're using G0_mathis=1 by default now. We will test on the !dustem_params sysvar instead of the parameter description vectors | 86 | ;NB: Since we're using G0_mathis=1 by default now. We will test on the !dustem_params sysvar instead of the parameter description vectors |
81 | 87 | ||
82 | G0_mathis = 1. ;Default value | 88 | G0_mathis = 1. ;Default value |
83 | 89 | ||
84 | - IF ((*!dustem_params).g0) NE 1. then G0_mathis = ((*!dustem_params).g0) | ||
85 | -; Fortran now uses negative numbers to specify Gas.dat G0 | ||
86 | -; If positive G0 present in Gas.dat, it takes precedence over grain.dat G0 | ||
87 | -; IF ((*!dustem_params).gas.g0) NE 1. then G0_mathis = float((*!dustem_params).gas.g0) | ||
88 | - IF ((*!dustem_params).gas.g0) gt 0. then G0_mathis = float((*!dustem_params).gas.g0) | ||
89 | - | 90 | + IF ((*!dustem_params).g0) NE 1. THEN BEGIN |
91 | + G0_mathis = ((*!dustem_params).g0) | ||
92 | + ENDIF | ||
93 | + ; Fortran now uses negative numbers to specify Gas.dat G0 | ||
94 | + ; If positive G0 present in Gas.dat, it takes precedence over the G0 value in GRAIN.DAT | ||
95 | + ; IF ((*!dustem_params).gas.g0) NE 1. then G0_mathis = float((*!dustem_params).gas.g0) | ||
96 | + IF ((*!dustem_params).gas.g0) gt 0. THEN BEGIN | ||
97 | + G0_mathis = float((*!dustem_params).gas.g0) | ||
98 | + ENDIF | ||
90 | ;Getting the ISRF default wavelengths | 99 | ;Getting the ISRF default wavelengths |
91 | ;using this structure | 100 | ;using this structure |
92 | - st=((*!dustem_params).isrf) | 101 | + ;st=((*!dustem_params).isrf) |
93 | final_isrf = fltarr(n_elements(st)) ;Initializing the ISRF vector | 102 | final_isrf = fltarr(n_elements(st)) ;Initializing the ISRF vector |
94 | - Ncomments=3 ;default number of comments in the .DAT file (minus the ISRF used) | ||
95 | - c=strarr(Ncomments) | ||
96 | - c[0]='# DUSTEM_WRAP: exciting radiation field featuring' | ||
97 | - | ||
98 | ;=== ADD to the ISRF | 103 | ;=== ADD to the ISRF |
99 | - IF ctpop NE 0. THEN final_isrf=final_isrf+(*(*!dustem_plugin)[tstpop].spec) | ||
100 | - IF ctusrisrf NE 0. THEN final_isrf=final_isrf+(*(*!dustem_plugin)[tstusrisrf].spec) | ||
101 | - | ||
102 | - IF ctpop NE 0. and ctusrisrf EQ 0. THEN c[1] = '# Stellar population ISRF' | ||
103 | - IF ctpop EQ 0. and ctusrisrf NE 0. THEN c[1] = '# User-defined ISRF' | ||
104 | - | ||
105 | - IF ctpop NE 0. and ctusrisrf NE 0. THEN BEGIN | ||
106 | - Ncomments+=1 | ||
107 | - c=strarr(Ncomments) | ||
108 | - c[0]='# DUSTEM_WRAP: exciting radiation field featuring' | ||
109 | - c[1] = '# Stellar population ISRF' | ||
110 | - c[2] = '# User-defined ISRF' | 104 | + ;IF ctpop NE 0. THEN final_isrf=final_isrf+(*(*!dustem_plugin)[tstpop].spec) |
105 | + ;JPB: This line below can have an undefined plugin ISRF if the REPLACE_ISRF plugin has not been called earlier except with /scope or paramtags keywords | ||
106 | + IF count_replace_isrf NE 0. THEN BEGIN | ||
107 | + IF ptr_valid((*!dustem_plugin)[ind_replace_isrf].spec) THEN BEGIN | ||
108 | + c[1]='# DUSTEM_WRAP: replaced by radiation field from plugin '+(*!dustem_plugin)[ind_replace_isrf].name | ||
109 | + ;final_isrf=final_isrf+(*(*!dustem_plugin)[tstusrisrf].spec) | ||
110 | + final_isrf=interpol(*(*!dustem_plugin)[ind_replace_isrf].spec,lambir,st.lambisrf) | ||
111 | + ENDIF ELSE BEGIN | ||
112 | + message,'Replacement ISRF not found. Using Mathis',/continue | ||
113 | + ;stop | ||
114 | + mathis_isrf_datfile=!dustem_soft_dir+'data/ISRF_MATHIS.DAT' | ||
115 | + sst=dustem_read_isrf(mathis_isrf_datfile) | ||
116 | + final_isrf=sst.isrf | ||
117 | + ;stop | ||
118 | + ;LEFT blank intensionally | ||
119 | + ENDELSE | ||
111 | ENDIF | 120 | ENDIF |
112 | - | ||
113 | - ;WHEN G0 IS USED (MATHIS FIELD ON) | ||
114 | - IF G0_mathis GT 1E-10 THEN BEGIN ;discussed with JP | ||
115 | - ;This is reading the mathis isrf from the fortran release | ||
116 | - mathis_isrf_datfile=!dustem_soft_dir+'data/ISRF_MATHIS.DAT' | ||
117 | - mathis_isrf=dustem_read_isrf(mathis_isrf_datfile) | ||
118 | - final_isrf=final_isrf/G0_mathis+mathis_isrf.isrf ;[0] | ||
119 | - Ncomments=4 | ||
120 | - c=strarr(Ncomments) | ||
121 | - c[0]='# DUSTEM_WRAP: exciting radiation field featuring' | ||
122 | - | ||
123 | - IF ctpop NE 0 and ctusrisrf EQ 0 THEN c[1] = '# Stellar population ISRF' | ||
124 | - IF ctpop EQ 0 and ctusrisrf NE 0 THEN c[1] = '# User-Defined ISRF' | ||
125 | - | ||
126 | - IF ctpop NE 0 and ctusrisrf NE 0 THEN BEGIN | ||
127 | - Ncomments+=2 | ||
128 | - c=strarr(Ncomments) | ||
129 | - c[0]='# DUSTEM_WRAP: exciting radiation field featuring' | ||
130 | - c[1] = '# Stellar population ISRF' | ||
131 | - c[2] ='# User-defined ISRF' | ||
132 | - c[3] = '# Mathis ISRF' | ||
133 | - ENDIF ELSE c[Ncomments-3] = '# Mathis ISRF' | ||
134 | - | ||
135 | - ENDIF ELSE final_isrf = final_isrf/G0_mathis ;WHEN G0 ISN'T USED (MATHIS FIELD OFF) ie: lower values than 1.0E-10. | ||
136 | - | 121 | + IF count_add_isrf NE 0 THEN BEGIN |
122 | + IF ptr_valid((*!dustem_plugin)[ind_add_isrf].spec) THEN BEGIN | ||
123 | + c[2]='# DUSTEM_WRAP: added radiation field from plugin '+(*!dustem_plugin)[ind_replace_isrf].name | ||
124 | + ;final_isrf=final_isrf+(*(*!dustem_plugin)[ind_add_isrf].spec) | ||
125 | + final_isrf=final_isrf+interpol(*(*!dustem_plugin)[ind_add_isrf].spec,lambir,st.lambisrf) | ||
126 | + ENDIF ELSE BEGIN | ||
127 | + ;stop | ||
128 | + ;LEFT blank intensionally | ||
129 | + ENDELSE | ||
130 | + ENDIF | ||
131 | + ;JPB: I don't think this loop is in fact needed, as the default value (without plugins) is the Mathis ISRF and ADD_ISRF will just add to this | ||
132 | + ;IF G0_mathis GT 1E-10 THEN BEGIN ;discussed with JP | ||
133 | + ; ;This is reading the mathis isrf from the fortran release | ||
134 | + ; mathis_isrf_datfile=!dustem_soft_dir+'data/ISRF_MATHIS.DAT' | ||
135 | + ; mathis_isrf=dustem_read_isrf(mathis_isrf_datfile) | ||
136 | + ; final_isrf=final_isrf/G0_mathis+mathis_isrf.isrf ;This is because Fortran uses ISRF*G0 which is now final_isrf+G0*mathis_isrf | ||
137 | + ; c=[c,'# Mathis ISRF'] | ||
138 | + ; Ncomments=Ncomments+1 | ||
139 | + ;ENDIF ELSE BEGIN | ||
140 | + ; ;final_isrf = final_isrf/G0_mathis ;This is because Fortran uses ISRF*G0 | ||
141 | + ;ENDELSE | ||
142 | + ;=== set the ISRF in the st structure | ||
137 | st.isrf = final_isrf | 143 | st.isrf = final_isrf |
144 | +ENDIF ELSE BEGIN ;This is Mathis field only | ||
145 | + ;==== default comment lines for ISRF.DAT | ||
146 | + Ncomments=4 | ||
147 | + c=strarr(Ncomments) | ||
148 | + c[1]='# Mathis ISRF' | ||
149 | +ENDELSE | ||
138 | 150 | ||
139 | - ;Last .DAT header comments lines | ||
140 | - c[Ncomments-2]='# Nbr of points' | ||
141 | - c[Ncomments-1]='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)' | ||
142 | - | ||
143 | - ;Computing the 'G0' of the new ISRF (integral(ISRF)/integral(MATHIS_ISRF)) | ||
144 | -; un=uniq(ma_isrf.isrf) ;because of the zeros | ||
145 | -; | ||
146 | -; int_mathis=INT_TABULATED((ma_isrf.lambisrf)[un],(ma_isrf.isrf)[un]) | ||
147 | -; | ||
148 | -; | ||
149 | -; ;integrating the composite isrf | ||
150 | -; int_isrf=INT_TABULATED((ma_isrf.lambisrf)[un],(st.isrf)[un]) | ||
151 | -; print, 'G0_stellar_population=' | ||
152 | -; print, int_isrf/(int_mathis) | ||
153 | - | ||
154 | - | ||
155 | -;WRITING THE NEW ISRF | ||
156 | - | ||
157 | - file=!dustem_dat+'data/ISRF.DAT' | ||
158 | - openw,unit,file,/get_lun | ||
159 | - | ||
160 | - FOR i=0,Ncomments-1 DO BEGIN | ||
161 | - printf,unit,c[i] | ||
162 | - ENDFOR | ||
163 | - | ||
164 | - n_waves=n_elements(st) | ||
165 | - printf,unit,n_waves | ||
166 | - | ||
167 | - FOR i=0L,n_waves-1 DO BEGIN | ||
168 | - printf,unit,st(i).lambisrf,st(i).isrf | ||
169 | - ENDFOR | ||
170 | - | ||
171 | - close,unit | ||
172 | - free_lun,unit | ||
173 | - | ||
174 | - goto, the_end | ||
175 | -ENDIF | ||
176 | - | ||
177 | - | ||
178 | - | ||
179 | -the_after: ;Defaut ISRF writing (MATHIS) | ||
180 | - | ||
181 | -;This was changed because 6 comments aren't needed | ||
182 | -Ncomments=4 | ||
183 | -c=strarr(Ncomments) | 151 | +c[Ncomments-2]='# Nbr of points' |
152 | +c[Ncomments-1]='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)' | ||
184 | 153 | ||
185 | -;First lines of the ISRF.DAT file | ||
186 | -c[0]='# DUSTEM_WRAP: exciting radiation field featuring' | ||
187 | -c[1]='# Mathis ISRF' | ||
188 | -c[2]='# Nbr of points' | ||
189 | -c[3]='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)' | 154 | +;==== Write the ISRF file |
155 | +write_isrf_file: | ||
190 | 156 | ||
191 | openw,unit,file,/get_lun | 157 | openw,unit,file,/get_lun |
192 | - | ||
193 | FOR i=0,Ncomments-1 DO BEGIN | 158 | FOR i=0,Ncomments-1 DO BEGIN |
194 | printf,unit,c[i] | 159 | printf,unit,c[i] |
195 | ENDFOR | 160 | ENDFOR |
196 | - | ||
197 | n_waves=n_elements(st) | 161 | n_waves=n_elements(st) |
198 | printf,unit,n_waves | 162 | printf,unit,n_waves |
199 | - | ||
200 | FOR i=0L,n_waves-1 DO BEGIN | 163 | FOR i=0L,n_waves-1 DO BEGIN |
201 | printf,unit,st[i].lambisrf,st[i].isrf | 164 | printf,unit,st[i].lambisrf,st[i].isrf |
202 | ENDFOR | 165 | ENDFOR |
203 | - | ||
204 | close,unit | 166 | close,unit |
205 | free_lun,unit | 167 | free_lun,unit |
206 | 168 | ||
169 | +;print,(*!dustem_params).g0 | ||
170 | +;print,(*!dustem_params).gas.g0 | ||
171 | +;cgplot,st.lambisrf,st.isrf,/xlog,/ylog | ||
172 | +;stop | ||
173 | + | ||
207 | the_end: | 174 | the_end: |
208 | 175 | ||
209 | 176 |