Commit 9a3272b133334f3985a0b48a68a6d49d5ad03c67
1 parent
eb263d61
Exists in
master
improved
Showing
3 changed files
with
74 additions
and
146 deletions
Show diff stats
src/idl/dustem_fit_intensity_phangs_example.pro
... | ... | @@ -156,118 +156,12 @@ pd = [ $ |
156 | 156 | ; initial values vector for run without synchrotron plugin |
157 | 157 | iv = [1.6, 2.2e-4, 5.7e-4, 3.4e-3,100.] |
158 | 158 | |
159 | -; initial values vector for run including the synchrotron plugin | |
160 | -; [G0,PAH0,VSG,BG,alpha_CR,Amp_syn] | |
161 | -;iv = [1.6, 2.2e-4, 5.7e-4, 3.4e-3, 2.7,0.01] | |
162 | - | |
163 | -; initial values vector for run including the synchrotron plugin and | |
164 | -; fixing the G0 and BB continuum parameters | |
165 | -;iv = [2.2e-4, 5.7e-4, 3.4e-3, 2.7,0.01] | |
166 | - | |
167 | 159 | Npar=n_elements(pd) |
168 | 160 | ulimed=replicate(0,Npar) |
169 | 161 | llimed=replicate(1,Npar) |
170 | 162 | llims=replicate(1.e-15,Npar) |
171 | 163 | fpd=[] & fiv=[] |
172 | 164 | |
173 | -; example using fixed parameters (ISRF and a NIR continuum) | |
174 | - | |
175 | -; Uncomment the following lines to include these fixed parameters | |
176 | -;fpd = ['(*!dustem_params).G0', $ ;G0 | |
177 | -; 'dustem_plugin_continuum_1', $ ;Temperature of a BB | |
178 | -; 'dustem_plugin_continuum_2'] ;Peak amplitude of a BB | |
179 | - | |
180 | -; fixed values vector | |
181 | -; [G0,T_BB,Amp_BB] | |
182 | -;fiv=[0.5,750,1.e-2] | |
183 | - | |
184 | -;; ;================================== | |
185 | -;; ;=== EXAMPLES FOR OTHER DUST MODELS | |
186 | -;; ;=== START BELOW HERE | |
187 | -;; ;================================== | |
188 | - | |
189 | - | |
190 | -;; ;=== AN EXAMPLE FOR DL07 | |
191 | -;; ;=== Here we fit the dust abundances of the model and the | |
192 | -;; ;=== intensity of the ISRF (via gas.G0 since the model | |
193 | -;; ;=== includes spinning dust) | |
194 | -;; ;=== The free parameters are all lower-bounded at zero. | |
195 | -;; use_model='DL07' ; you should specify this above, or in the command line | |
196 | -;; pd = [ '(*!dustem_params).gas.G0'], $ | |
197 | -;; '(*!dustem_params).grains(0).mdust_o_mh',$ ;PAH0 mass fraction | |
198 | -;; '(*!dustem_params).grains(1).mdust_o_mh',$ ;PAH1 mass fraction | |
199 | -;; '(*!dustem_params).grains(2).mdust_o_mh', $ ;Gra | |
200 | -;; '(*!dustem_params).grains(3).mdust_o_mh', $ ;Gra | |
201 | -;; '(*!dustem_params).grains(4).mdust_o_mh'] ;aSil | |
202 | -;; iv = [1.5 ,5.4e-4, 5.4e-4,1.8e-4,2.33e-3,8.27e-3] | |
203 | -;; Npar=n_elements(pd) | |
204 | -;; ulimed=replicate(0,Npar) | |
205 | -;; llimed=replicate(1,Npar) | |
206 | -;; llims=replicate(1.e-15,Npar) | |
207 | -;; ; fpd=['(*!dustem_params).gas.G0'] | |
208 | -;; ; fiv=[2.] | |
209 | - | |
210 | - | |
211 | -;; ;; ;=== AN EXAMPLE FOR MC10 | |
212 | -;; ;; ;=== Here we fit the dust abundances of the MC10 model, the | |
213 | -;; ;; ;=== intensity of the dust-heating radiation field as well as a plug-in: | |
214 | -;; ;; ;=== (i) continuum due to a blackbody | |
215 | -;; ;; ;=== The intensity of the dust-heating radiation field is fixed to | |
216 | -;; ;; ;=== 1.5*G0 and the tmperature of the blackbody is fixed to 1200K | |
217 | -;; ;; ;=== The free parameters in the fit are lower-bounded at zero. | |
218 | -;; use_model='MC10' ; you should specify this above, or in the command line | |
219 | -;; pd = [ $ | |
220 | -;; '(*!dustem_params).grains(0).mdust_o_mh'$ ;PAH0 mass fraction | |
221 | -;; ,'(*!dustem_params).grains(1).mdust_o_mh' $ ;PAH1 mass fraction | |
222 | -;; ,'(*!dustem_params).grains(2).mdust_o_mh' $ ;amCBEx | |
223 | -;; ,'(*!dustem_params).grains(3).mdust_o_mh' $ ;amCBEx | |
224 | -;; ,'(*!dustem_params).grains(4).mdust_o_mh' $ ;aSilx | |
225 | -;; ,'dustem_plugin_continuum_2' $ ;Intensity at peak of the continuum | |
226 | -;; ] | |
227 | -;; iv = [ 7.8e-4, 7.8e-4, 1.65e-4, 1.45e-3, 6.7e-3, 0.003] | |
228 | -;; Npar=n_elements(pd) | |
229 | -;; ulimed=replicate(0,Npar) | |
230 | -;; llimed=replicate(1,Npar) | |
231 | -;; llims=replicate(1.e-15,Npar) | |
232 | -;; fpd=[ $ | |
233 | -;; '(*!dustem_params).G0' $ ; ISRF intensity | |
234 | -;; ,'dustem_plugin_continuum_1' $ ;temperature of blackbody the produces the continuum | |
235 | -;; ] | |
236 | -;; fiv=[1.5, 1200.] | |
237 | - | |
238 | - | |
239 | - | |
240 | -;; ;=== AN EXAMPLE FOR J13 | |
241 | -;; ;=== Here we fit the dust abundances of the J13 model, the | |
242 | -;; ;=== intensity of the dust-heating radiation field as well as two plug-ins: | |
243 | -;; ;=== (i) free-free emission | |
244 | -;; ;=== (ii)continuum due to a blackbody | |
245 | -;; ;=== The temperature of the blackbody is fixed to 1000K | |
246 | -;; ;=== The free parameters in the fit are all lower-bounded at zero. | |
247 | -;; use_model='J13' ; you should specify this above, or in the command line | |
248 | -;; pd = [ $ | |
249 | -;; '(*!dustem_params).G0' $ ;G0 | |
250 | -;; ,'(*!dustem_params).grains(0).mdust_o_mh'$ ;CM20 -- power law size distribution | |
251 | -;; ,'(*!dustem_params).grains(1).mdust_o_mh'$ ;CM20 -- logN size distribution | |
252 | -;; ,'(*!dustem_params).grains(2).mdust_o_mh' $ ;aPyM5 | |
253 | -;; ,'(*!dustem_params).grains(3).mdust_o_mh' $ ;aOlM5 | |
254 | -;; ,'dustem_plugin_freefree_1' $ ;ionized gas temperature | |
255 | -;; ,'dustem_plugin_freefree_2' $ ;free-free amplitude | |
256 | -;; ,'dustem_plugin_continuum_2'] ;Intensity at peak of the BB continuum | |
257 | -;; iv = [1.2,1.7e-3, 6.3e-4, 2.55e-3, 2.55e-3, 7500., 0.4, 0.001] | |
258 | -;; Npar=n_elements(pd) | |
259 | -;; ulimed=replicate(0,Npar) | |
260 | -;; llimed=replicate(1,Npar) | |
261 | -;; llims=replicate(1.e-15,Npar) | |
262 | -;; fpd=[ 'dustem_plugin_continuum_1'] ; Temperature of the BB | |
263 | -;; fiv=[1000.] | |
264 | - | |
265 | - | |
266 | -;;Nfix=n_elements(fpd) | |
267 | -;;if n_elements(fiv) ne Nfix then begin | |
268 | -;; message,'Number of fixed parameters (fpd) does not equal number of initial values of fixed parameters (fiv)',/info | |
269 | -;; stop | |
270 | -;;end | |
271 | 165 | |
272 | 166 | if keyword_set(wait) then begin |
273 | 167 | message,'Finished setting dust model and plug-in parameters: '+use_model,/info | ... | ... |
src/idl/dustem_plugin_phangs_stellar_continuum.pro
... | ... | @@ -2,6 +2,8 @@ FUNCTION dustem_plugin_phangs_stellar_continuum,key=key $ |
2 | 2 | ,val=val $ |
3 | 3 | ,scope=scope $ |
4 | 4 | ,paramtag=paramtag $ |
5 | + ,age_values=age_values $ | |
6 | + ,metalicity_values=metalicity_values $ | |
5 | 7 | ,paramdefault=paramdefault $ |
6 | 8 | ,help=help |
7 | 9 | |
... | ... | @@ -87,28 +89,29 @@ met_values_emiles=met_values_emiles[un] |
87 | 89 | ;==== This does not work because the info files has many more entries than there are available ssps. |
88 | 90 | ;age_values=age_values_emiles |
89 | 91 | ;metalicity_values=met_values_emiles |
92 | +;This does not work either | |
93 | +;st_templates=read_muse_templates_info(age_values=age_values,metalicity_values=metalicity_values,Nbins=Nbins,Nage=Nage,NZ=Nmetalicity,bins=bins) | |
94 | +;print,age_values | |
95 | +; 0.030000000 0.050000000 0.080000000 0.15000000 0.25000000 0.40000000 0.60000000 1.0000000 1.7500000 3.0000000 5.0000000 8.5000000 13.500000 | |
96 | +;print,metalicity_values | |
97 | +; -1.49000 -0.960000 -0.350000 0.0600000 0.260000 0.400000 | |
98 | + | |
99 | +;stop | |
90 | 100 | |
91 | 101 | Nage=n_elements(age_values) |
92 | 102 | Nmetalicity=n_elements(metalicity_values) |
93 | -Nparam=Nage*Nmetalicity+1 ;+1 is for opacity | |
103 | +Nparam=Nage*Nmetalicity+2 ;+2 is for Amplitude and opacity | |
94 | 104 | paramdefault=dblarr(Nparam) |
95 | 105 | paramdefault[*]=0.D0 ;default parameter values is 0. |
96 | 106 | |
97 | 107 | ;==== define parameter tags |
98 | - | |
99 | -;If the test below is activated (ie paramtags computed only when requested) the pluggin does not work. | |
100 | -;IF keyword_set(paramtag) THEN BEGIN | |
101 | - paramtag=strarr(Nparam) | |
102 | - paramtag[0]='E(B-V)' | |
103 | - ii=1L | |
104 | - FOR i=1L,Nparam-1 DO BEGIN | |
105 | - ij=index2ij([i-1],[Nage,Nmetalicity]) | |
106 | - paramtag[ii]='Age'+strtrim(ij[0,0],2)+'Met'+strtrim(ij[0,1],2) | |
107 | - ii=ii+1 | |
108 | - ENDFOR | |
109 | - ;out=0. | |
110 | - ;GOTO,the_paramtag | |
111 | -;ENDIF | |
108 | +paramtag=strarr(Nparam) | |
109 | +paramtag[0]='Amplitude' | |
110 | +paramtag[1]='E(B-V)' | |
111 | +FOR i=2L,Nparam-1 DO BEGIN | |
112 | + ij=index2ij([i-2],[Nage,Nmetalicity]) | |
113 | + paramtag[i]='Age'+strtrim(ij[0,0],2)+'Met'+strtrim(ij[0,1],2) | |
114 | +ENDFOR | |
112 | 115 | |
113 | 116 | ;==== decode key keyword. |
114 | 117 | ;stop |
... | ... | @@ -140,51 +143,78 @@ ENDIF |
140 | 143 | |
141 | 144 | lambir=dustem_get_wavelengths() |
142 | 145 | Nwavs=n_elements(lambir) |
143 | -output=fltarr(Nwavs,3) | |
146 | +output=dblarr(Nwavs,3) | |
144 | 147 | wavs=*!dustem_plugin_phangs_stellar_continuum.wavs |
145 | 148 | Mstars=*!dustem_plugin_phangs_stellar_continuum.mstars |
146 | 149 | ;==== sum up the stellar spectrum |
147 | 150 | ;stop |
148 | -FOR i=1L,Nparam-1 DO BEGIN | |
151 | +FOR i=2L,Nparam-1 DO BEGIN | |
149 | 152 | IF paramvalues[i] NE 0. THEN BEGIN |
150 | 153 | ;stop |
151 | 154 | ;only interpolate within the template wavelengths |
152 | 155 | ind=where(lambir LE max(wavs) AND lambir GE min(wavs),count) |
153 | - Mstar=Mstars[i-1] | |
156 | + Mstar=Mstars[i-2] | |
154 | 157 | IF count NE 0 THEN BEGIN |
155 | - ssp=*(*!dustem_plugin_phangs_stellar_continuum.ssps)[i-1] | |
158 | + ssp=*(*!dustem_plugin_phangs_stellar_continuum.ssps)[i-2] | |
156 | 159 | output[ind,0]=output[ind,0]+paramvalues[i]*Mstar*interpol(ssp,wavs,lambir[ind]) |
157 | 160 | message,'Mstar='+strtrim(Mstar,2)+' paramvalue='+strtrim(paramvalues[i],2),/continue |
158 | 161 | ENDIF |
159 | 162 | ENDIF |
160 | 163 | ENDFOR |
161 | -;==== Caution: at this point, output is unredenned Flambda in Lsun/pc^2/Angstroem | |
164 | +output[*,0]=output[*,0]*paramvalues[0] | |
165 | +flux=output[*,0] | |
166 | +;no polarization for now | |
167 | +output[*,1]=0. | |
168 | +output[*,2]=0. | |
169 | + | |
170 | + | |
171 | +;==== Caution: | |
172 | +;output is Flambda in ergs/s/cm2/AA | |
173 | +;at this point, output is unredenned | |
174 | +;==== must be transformed into MJy/sr | |
175 | +NHref=*!DUSTEM_HCD ;NH dustemwrap reference [H/cm^2] | |
176 | +fact2=lambir*1.e4 ;[AA] to go from F_lambda in ergs/s/cm2/AA to Fnu ergs/s/cm2 | |
177 | +fact3=1./NHref ;[cm2/H] to go from ergs/s/cm2 to ergs/s/H | |
178 | +fact4=1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/lambir)*1.e20/1.e7 ;This goes from ergs/s/H to MJy/sr (see dustem_plot_dataset) | |
179 | +fact=fact2*fact3*fact4 | |
180 | + | |
181 | +print,'flux(1mic)=',interpol(flux,lambir,1.),' ergs/s/cm2/AA' | |
182 | +print,'fact2=',interpol(fact2,lambir,1.) | |
183 | +print,'fact3=',fact3 | |
184 | +print,'fact4=',interpol(fact4,lambir,1.) | |
185 | +print,'fact=',interpol(fact,lambir,1.) | |
186 | +print,'flux(1mic)=',interpol(flux,lambir,1.)*interpol(fact,lambir,1.),' MJy/sr' | |
187 | + | |
188 | +;goto,no_unred | |
162 | 189 | |
163 | -stop | |
164 | 190 | ;==== reden spectrum using Calzetti's extinction law (which is what Phangs does) |
165 | -flux=output[*,0] | |
191 | +;cgplot,lambir,flux,/xlog,/ylog | |
166 | 192 | ;factor -1 is to reden, instead of unreden. factor 1e4 is to go from microns to Angstroem |
167 | -calz_unred, lambir*1.e4, flux, -1.*paramvalues[0], flux_red, R_V = R_V | |
193 | +calz_unred, lambir*1.e4, flux, -1.*paramvalues[1], flux_red, R_V = R_V | |
168 | 194 | output[*,0]=flux_red |
169 | 195 | |
170 | -;no polarization for now | |
171 | -output[*,1]=0. | |
172 | -output[*,2]=0. | |
196 | +no_unred: | |
197 | + | |
198 | +;fact=Lsun*watts2ergs/Mpc2cm*1.e-4*4.*!pi/Mpc2cm/NHref ;to go from F_lambda in Lsun/A/pc^2 to Watts/m2/Hz/sr to MJy/sr | |
199 | + | |
200 | +;fact=Lsun/pc*(lambir/1.e6)^2/c/4./!pi/pc*1.e20 ;to go from F_lambda in Lsun/A/pc^2 to Watts/m2/Hz/sr to MJy/sr | |
201 | +;print,'flux=',interpol(flux,lambir,1.),' Lsun/Mpc^2/AA' | |
202 | +;print,'fact1=',fact1 | |
203 | +;print,'fact2=',interpol(fact2,lambir,1.) | |
204 | +;print,'fact3=',fact3 | |
205 | +;print,'fact=',interpol(fact,lambir,1.) | |
206 | +;print,'flux=',interpol(flux,lambir,1.)*interpol(fact,lambir,1.),' ergs/s/H' | |
207 | +;print,'fact4=',interpol(fact4,lambir,1.) | |
208 | +;print,'fact5=',fact5 | |
209 | +;print,'flux=',interpol(flux,lambir,1.)*interpol(fact,lambir,1.)*interpol(fact4,lambir,1.),' MJy/sr' | |
173 | 210 | |
174 | -;at that stage, output is F_lambda in Lsun/A/pc^2 | |
175 | -;going to W/m2/sr/hz | |
176 | -pc=3.085677581e16 ;m | |
177 | -Lsun=3.828e26 ;Watts | |
178 | -c=3.e5*1e3 ;m/s | |
179 | -;Fact=Lsun ;Watts/A | |
180 | -;fact=fact*c ;Watts/hz | |
181 | -;fact=fact/4./!pi ;Watts/Hz/sr | |
182 | -;fact=fact/pc^2 ;Watts/m2/Hz/sr | |
183 | - | |
184 | -fact=Lsun/pc*c/4./!pi/pc ;to go from F_lambda in Lsun/A/pc^2 to Watts/m2/Hz/sr | |
185 | -output=output*fact | |
186 | -;print,fact | |
187 | -; 9.59803 | |
211 | +;output=output*fact | |
212 | +output[*,0]=output[*,0]*fact | |
213 | +output[*,1]=output[*,1]*fact | |
214 | +output[*,2]=output[*,2]*fact | |
215 | + | |
216 | +print,'output=',interpol(output[*,0],lambir,1.),' MJy/sr' | |
217 | +;stop | |
188 | 218 | |
189 | 219 | the_scope: |
190 | 220 | scope='ADD_SED' | ... | ... |
src/idl/dustem_read_emiles_stellar_templates.pro
... | ... | @@ -91,6 +91,10 @@ metalicity_values_4str=string(metalicity_values_4str,format='(F5.2)') |
91 | 91 | FOR i=0L,n_elements(metalicity_values_4str)-1 DO metalicity_values_4str[i]=textoidl_str_replace(metalicity_values_4str[i],' ','p') |
92 | 92 | FOR i=0L,n_elements(metalicity_values_4str)-1 DO metalicity_values_4str[i]=textoidl_str_replace(metalicity_values_4str[i],'-','m') |
93 | 93 | |
94 | +print,age_values | |
95 | +print,metalicity_values | |
96 | +;stop | |
97 | + | |
94 | 98 | ;Ntemplates=n_elements(paramvalues)-1 |
95 | 99 | Ntemplates=n_elements(age_values)*n_elements(metalicity_values) |
96 | 100 | Nage=n_elements(age_values) | ... | ... |