Commit 4a2d1650046e56ca40774d3f1a7efd3ab8cf78d4
1 parent
2b6fd350
Exists in
master
improved
Showing
5 changed files
with
64 additions
and
49 deletions
Show diff stats
src/idl/dustem_init_params.pro
... | ... | @@ -2,7 +2,8 @@ PRO dustem_init_params,model,pd,iv, $ |
2 | 2 | fpd=fpd,fiv=fiv $ |
3 | 3 | ,ulimed=ulimed,llimed=llimed,ulims=ulims,llims=llims $ |
4 | 4 | ,tied=tied,fixed=fixed $ |
5 | - ,polarization=polarization | |
5 | + ,polarization=polarization $ | |
6 | + ,no_reset_plugin_structure=no_reset_plugin_structure | |
6 | 7 | ;+ |
7 | 8 | ; NAME: |
8 | 9 | ; dustem_init_params |
... | ... | @@ -29,10 +30,6 @@ PRO dustem_init_params,model,pd,iv, $ |
29 | 30 | ; llimed -- flag 1/0 if lower limits ON/OFF |
30 | 31 | ; ulims -- upper limit values |
31 | 32 | ; llims -- lower limit values |
32 | -; | |
33 | -; | |
34 | -; | |
35 | -; | |
36 | 33 | ; OUTPUTS: |
37 | 34 | ; None |
38 | 35 | ; |
... | ... | @@ -42,7 +39,7 @@ PRO dustem_init_params,model,pd,iv, $ |
42 | 39 | ; ACCEPTED KEY-WORDS: |
43 | 40 | ; polarization = assume dustem is running in polarization mode |
44 | 41 | ; help = if set, print this help |
45 | -; | |
42 | +; no_reset_plugin_structure = if set, does not reset the plugin structure | |
46 | 43 | ; COMMON BLOCKS: |
47 | 44 | ; None |
48 | 45 | ; |
... | ... | @@ -201,9 +198,11 @@ if keyword_set(polarization) and polexists eq 0 then $ |
201 | 198 | dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims,fixed=fixed,tied=tied |
202 | 199 | |
203 | 200 | ;== INITIALIZE ANY PLUGINS |
204 | -dustem_init_plugins,pd,fpd=fpd | |
201 | +IF not keyword_set(no_reset_plugin_structure) THEN BEGIN | |
202 | + dustem_init_plugins,pd,fpd=fpd | |
203 | +ENDIF | |
205 | 204 | |
206 | -;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODOEL AND PLUGINS | |
205 | +;== INITIALIZE ANY FIXED PARAMETERS FOR DUST MODEL AND PLUGINS | |
207 | 206 | if keyword_set(fpd) then dustem_init_fixed_params,fpd,fiv |
208 | 207 | |
209 | 208 | message,'Finished initializing free and fixed parameters of dust model and plugins',/info | ... | ... |
src/idl/dustem_plugin_phangs_stellar_continuum.pro
... | ... | @@ -96,17 +96,21 @@ metalicity_values=[-1.48630, -0.961400, -0.351200, +0.0600000, +0.255900, +0.397 |
96 | 96 | Nage=n_elements(age_values) |
97 | 97 | Nmetalicity=n_elements(metalicity_values) |
98 | 98 | Nparam=Nage*Nmetalicity+2 ;+2 is for Amplitude and opacity |
99 | -paramdefault=dblarr(Nparam) | |
100 | -paramdefault[*]=0.D0 ;default parameter values is 0. | |
101 | 99 | |
102 | 100 | ;==== define parameter tags |
103 | -paramtag=strarr(Nparam) | |
104 | -paramtag[0]='Amplitude' | |
105 | -paramtag[1]='E(B-V)' | |
106 | -FOR i=2L,Nparam-1 DO BEGIN | |
107 | - ij=index2ij([i-2],[Nage,Nmetalicity]) | |
108 | - paramtag[i]='Age'+strtrim(ij[0,0],2)+'Met'+strtrim(ij[0,1],2) | |
109 | -ENDFOR | |
101 | +IF keyword_set(paramtag) THEN BEGIN | |
102 | + paramtag=strarr(Nparam) | |
103 | + paramtag[0]='Amplitude' | |
104 | + paramtag[1]='E(B-V)' | |
105 | + FOR i=2L,Nparam-1 DO BEGIN | |
106 | + ij=index2ij([i-2],[Nage,Nmetalicity]) | |
107 | + paramtag[i]='Age'+strtrim(ij[0,0],2)+'Met'+strtrim(ij[0,1],2) | |
108 | + ENDFOR | |
109 | + GOTO,the_paramtag | |
110 | +ENDIF | |
111 | + | |
112 | +paramdefault=dblarr(Nparam) | |
113 | +paramdefault[*]=0.D0 ;default parameter values is 0. | |
110 | 114 | |
111 | 115 | ;==== decode key keyword. |
112 | 116 | ;stop |
... | ... | @@ -136,6 +140,7 @@ IF not ptr_valid(!dustem_plugin_phangs_stellar_continuum.ssps) THEN BEGIN |
136 | 140 | ;== this is just to get the Mstars |
137 | 141 | bidon=dustem_read_emiles_stellar_templates(age_values,metalicity_values,template_wav=template_wav,Mstars=Mstars) |
138 | 142 | ;== This is to read in the CB19 templates |
143 | + ;== Note, templates are already interpolated on dustem wavelenghts (!) | |
139 | 144 | template_flux=dustem_read_cb19_stellar_templates(age_values=age_values,metalicity_values=metalicity_values,template_wav=template_wav,Mstars=Mstars) |
140 | 145 | END |
141 | 146 | ENDCASE |
... | ... | @@ -157,20 +162,21 @@ FOR i=2L,Nparam-1 DO BEGIN |
157 | 162 | IF paramvalues[i] NE 0. THEN BEGIN |
158 | 163 | ;stop |
159 | 164 | ;only interpolate within the template wavelengths |
160 | - ind=where(lambir LE max(wavs) AND lambir GE min(wavs),count) | |
165 | + ;ind=where(lambir LE max(wavs) AND lambir GE min(wavs),count) | |
161 | 166 | Mstar=Mstars[i-2] |
162 | - IF count NE 0 THEN BEGIN | |
163 | - ssp=*(*!dustem_plugin_phangs_stellar_continuum.ssps)[i-2] | |
164 | - output[ind,0]=output[ind,0]+paramvalues[i]*Mstar*interpol(ssp,wavs,lambir[ind]) | |
165 | - message,'Mstar='+strtrim(Mstar,2)+' paramvalue='+strtrim(paramvalues[i],2),/info | |
166 | - ENDIF | |
167 | + ;IF count NE 0 THEN BEGIN | |
168 | + ssp=*(*!dustem_plugin_phangs_stellar_continuum.ssps)[i-2] | |
169 | + ;output[ind,0]=output[ind,0]+paramvalues[i]*Mstar*interpol(ssp,wavs,lambir[ind]) | |
170 | + output[*,0]=output[*,0]+paramvalues[i]*Mstar*ssp | |
171 | + message,'Mstar='+strtrim(Mstar,2)+' paramvalue='+strtrim(paramvalues[i],2),/info | |
172 | + ;ENDIF | |
167 | 173 | ENDIF |
168 | 174 | ENDFOR |
169 | 175 | output[*,0]=output[*,0]*paramvalues[0] |
170 | -flux=output[*,0] | |
176 | +;flux=output[*,0] | |
171 | 177 | ;no polarization for now |
172 | -output[*,1]=0. | |
173 | -output[*,2]=0. | |
178 | +;output[*,1]=0. | |
179 | +;output[*,2]=0. | |
174 | 180 | |
175 | 181 | |
176 | 182 | ;==== Caution: |
... | ... | @@ -195,28 +201,14 @@ fact=fact2*fact3*fact4 |
195 | 201 | ;==== reden spectrum using Calzetti's extinction law (which is what Phangs does) |
196 | 202 | ;cgplot,lambir,flux,/xlog,/ylog |
197 | 203 | ;factor -1 is to reden, instead of unreden. factor 1e4 is to go from microns to Angstroem |
198 | -calz_unred, lambir*1.e4, flux, -1.*paramvalues[1], flux_red, R_V = R_V | |
204 | +calz_unred, lambir*1.e4, output[*,0], -1.*paramvalues[1], flux_red, R_V = R_V | |
199 | 205 | output[*,0]=flux_red |
200 | 206 | |
201 | 207 | no_unred: |
202 | 208 | |
203 | -;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 | |
204 | - | |
205 | -;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 | |
206 | -;print,'flux=',interpol(flux,lambir,1.),' Lsun/Mpc^2/AA' | |
207 | -;print,'fact1=',fact1 | |
208 | -;print,'fact2=',interpol(fact2,lambir,1.) | |
209 | -;print,'fact3=',fact3 | |
210 | -;print,'fact=',interpol(fact,lambir,1.) | |
211 | -;print,'flux=',interpol(flux,lambir,1.)*interpol(fact,lambir,1.),' ergs/s/H' | |
212 | -;print,'fact4=',interpol(fact4,lambir,1.) | |
213 | -;print,'fact5=',fact5 | |
214 | -;print,'flux=',interpol(flux,lambir,1.)*interpol(fact,lambir,1.)*interpol(fact4,lambir,1.),' MJy/sr' | |
215 | - | |
216 | -;output=output*fact | |
217 | 209 | output[*,0]=output[*,0]*fact |
218 | -output[*,1]=output[*,1]*fact | |
219 | -output[*,2]=output[*,2]*fact | |
210 | +;output[*,1]=output[*,1]*fact | |
211 | +;output[*,2]=output[*,2]*fact | |
220 | 212 | |
221 | 213 | ;print,'output=',interpol(output[*,0],lambir,1.),' MJy/sr' |
222 | 214 | ;stop | ... | ... |
src/idl/dustem_read_cb19_stellar_templates.pro
... | ... | @@ -127,12 +127,12 @@ FOR i=0L,Ntemplates-1 DO BEGIN |
127 | 127 | ;==== This is nearest neighbour on age and interpolation on Z |
128 | 128 | ssps_used=all_ssps[*,ind_age[0]] |
129 | 129 | xx=indgen(Nz) |
130 | - toto=interpol(xx,Z,met) | |
131 | - u1=abs(toto-round(toto)) | |
132 | - u2=abs(toto-fix(toto)) | |
133 | - ;print,round(toto),toto,fix(toto) | |
134 | - ;print,1.-u1,1.-u2 | |
135 | - templates[i]=ptr_new((*ssps_used[round(toto)])*(1.-u1) + (*ssps_used[fix(toto)])*(1.-u2)) | |
130 | + toto=interpol(xx,Z,met) | |
131 | + u1=abs(toto-round(toto)) | |
132 | + u2=abs(toto-fix(toto)) | |
133 | + ;print,round(toto),toto,fix(toto) | |
134 | + ;print,1.-u1,1.-u2 | |
135 | + templates[i]=ptr_new((*ssps_used[round(toto)])*(1.-u1) + (*ssps_used[fix(toto)])*(1.-u2)) | |
136 | 136 | ;stop |
137 | 137 | ENDFOR |
138 | 138 | |
... | ... | @@ -147,6 +147,18 @@ metalicity_values=metalicity_values_wanted |
147 | 147 | angstroem2mic=1.e6/1.e10 |
148 | 148 | template_wav=wavs*angstroem2mic ;mic |
149 | 149 | |
150 | +;do_interpol=1L | |
151 | + | |
152 | +;IF do_interpol THEN BEGIN | |
153 | + ;stop | |
154 | + lambir=dustem_get_wavelengths() | |
155 | + FOR i=0L,Ntemplates-1 DO BEGIN | |
156 | + ;ind=where(lambir LE max(template_wav) AND lambir GE min(template_wav),count) | |
157 | + templates[i]=ptr_new(interpol(*templates[i],template_wav,lambir)) | |
158 | + ENDFOR | |
159 | + template_wav=lambir | |
160 | +;ENDIF | |
161 | + | |
150 | 162 | the_end: |
151 | 163 | |
152 | 164 | RETURN,templates | ... | ... |
src/idl/dustem_read_emiles_stellar_templates.pro
... | ... | @@ -154,6 +154,17 @@ ENDIF |
154 | 154 | angstroem2mic=1.e6/1.e10 |
155 | 155 | template_wav=wavs*angstroem2mic ;mic |
156 | 156 | |
157 | +;do_interpol=1L | |
158 | + | |
159 | +;IF do_interpol THEN BEGIN | |
160 | + lambir=dustem_get_wavelengths() | |
161 | + FOR i=0L,Ntemplates-1 DO BEGIN | |
162 | + ;ind=where(lambir LE max(template_wav) AND lambir GE min(template_wav),count) | |
163 | + templates[i]=ptr_new(interpol(*templates[i],template_wav,lambir)) | |
164 | + ENDFOR | |
165 | + template_wav=lambir | |
166 | +;ENDIF | |
167 | + | |
157 | 168 | the_end: |
158 | 169 | |
159 | 170 | RETURN,templates | ... | ... |
src/idl/dustem_run_plugins.pro