Commit c9abf9b43086b6c41f5f5fdb46358427f5d12c9a
1 parent
3d0f6b67
Exists in
master
Uploading stellarpopisrf_example and some minor debugging
Showing
5 changed files
with
442 additions
and
27 deletions
Show diff stats
src/idl/dustem_fit_ext_pol_example.pro
... | ... | @@ -388,7 +388,6 @@ dustem_init_plugins, pd,fpd=fpd |
388 | 388 | |
389 | 389 | dustem_init_fixed_params,fpd,fiv |
390 | 390 | |
391 | - | |
392 | 391 | ;generation of the fake data (since dustem_set_data takes ONE structure containing all the info) |
393 | 392 | !dustem_psi_ext=25 |
394 | 393 | |
... | ... | @@ -396,8 +395,6 @@ ext.EXT_I = dustem_compute_ext(rv,st=st) |
396 | 395 | toto = dustem_compute_stokext(rv,st=st,qext_spec=dustem_qext,uext_spec=dustem_uext) |
397 | 396 | ext.EXT_Q = toto[0] |
398 | 397 | ext.EXT_U = toto[1] |
399 | -;stop | |
400 | - | |
401 | 398 | |
402 | 399 | ;==== JPB |
403 | 400 | ;below m_fit does not exist, so there is no emission data to plot, and therefore, no emission data to plot. |
... | ... | @@ -420,6 +417,7 @@ yr_x=[1.00E-10,10] |
420 | 417 | tit='Spectral Energy Distribution' |
421 | 418 | ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') |
422 | 419 | xtit=textoidl('\lambda (\mum)') |
420 | + | |
423 | 421 | ;Set show_plot to 0 to hide plot |
424 | 422 | ;Commented or set to 1 is the same since !dustem_show_plot (existing sysvar) is initialized to 1 in dustem_init |
425 | 423 | ;show_plot = 0 | ... | ... |
src/idl/dustem_fit_intensity_example.pro
... | ... | @@ -336,16 +336,6 @@ if keyword_set(wait) then begin |
336 | 336 | end |
337 | 337 | |
338 | 338 | |
339 | - | |
340 | -;IC: - | |
341 | -;The final plot is automatically plotted | |
342 | -;and a (Final run) string is automatically added | |
343 | -;to modify this go to dustemwrap_plot and search for the string '(FINAL_RUN)' | |
344 | -;This is true for OOP plotting. | |
345 | -;However, even thought the last iteration for noobj plotting is plotted, the '(FINAL_RUN)' string isn't applied | |
346 | -;to modify this, got to dustemwrap_plot_noobj and search for the '(RUNNING)' string. | |
347 | -;an extra condition using !dustem_end (signaling end of fit) will have to be used. | |
348 | - | |
349 | 339 | ;=== MAKE THE FINAL PLOT |
350 | 340 | IF keyword_set(postscript) THEN BEGIN |
351 | 341 | dir_ps='./' |
... | ... | @@ -353,6 +343,7 @@ IF keyword_set(postscript) THEN BEGIN |
353 | 343 | ps_file=dir_ps+postscript |
354 | 344 | device,filename=ps_file,/color |
355 | 345 | ENDIF |
346 | + | |
356 | 347 | IF !dustem_noobj THEN BEGIN |
357 | 348 | dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' |
358 | 349 | ENDIF ELSE BEGIN |
... | ... | @@ -370,13 +361,6 @@ if keyword_set(wait) then begin |
370 | 361 | wait,wait |
371 | 362 | end |
372 | 363 | |
373 | -;IC: Last iteration is automatically plotted. | |
374 | -;I think modifications will have to be applied to dustemwrap_plot... | |
375 | -;idea: create a system variable that signals if the fits file has been successfully saved and use it in the dustemwrap_plot(obj/noobj) routine(s) | |
376 | -;to add the '(From saved FITS file)' string to the title | |
377 | - | |
378 | -;stop | |
379 | - | |
380 | 364 | IF keyword_set(fits_save_and_restore) THEN BEGIN |
381 | 365 | message,'Writing out results structure: '+fits_save_and_restore,/info |
382 | 366 | dustem_write_fits_table,filename=fits_save_and_restore,help=help | ... | ... |
src/idl/dustem_plot_dataset.pro
... | ... | @@ -3218,13 +3218,25 @@ if keyword_set(dataset) then begin |
3218 | 3218 | |
3219 | 3219 | Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs)) |
3220 | 3220 | res = (*(*!dustem_fit).fixed_param_init_values) |
3221 | + | |
3222 | + iii=0 | |
3223 | + FOR i=0L,Nfpar-1 DO BEGIN | |
3224 | + | |
3225 | + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i] | |
3226 | + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name) | |
3227 | + if parameter_type NE 'PLUGIN' then iii+=1 | |
3228 | + | |
3229 | + ENDFOR | |
3230 | + | |
3221 | 3231 | k = 0 |
3222 | - xxpos = 0.0 | |
3223 | - yypos = 0.9 | |
3224 | - ;xxpos = 0.0 ;might need to be modified | |
3225 | - cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal | |
3226 | - xxpos=(1-thiswidth)/2 | |
3227 | - xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0 | |
3232 | + if iii ne 0 then begin | |
3233 | + xxpos = 0.0 | |
3234 | + yypos = 0.9 | |
3235 | + ;xxpos = 0.0 ;might need to be modified | |
3236 | + cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal | |
3237 | + xxpos=(1-thiswidth)/2 | |
3238 | + xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0 | |
3239 | + endif | |
3228 | 3240 | |
3229 | 3241 | FOR i=0L,Nfpar-1 DO BEGIN |
3230 | 3242 | ... | ... |
src/idl/dustem_plugin_modify_isrf.pro
... | ... | @@ -0,0 +1,421 @@ |
1 | +PRO dustem_stellarpopisrf_example,model=model $ | |
2 | + ,sed=sed $ | |
3 | + ,Nitermax=Nitermax $ | |
4 | + ,postscript=postscript $ | |
5 | + ,fits_save_and_restore=fits_save_and_restore $ | |
6 | + ,wait=wait $ | |
7 | + ,verbose=verbose $ | |
8 | + ,help=help | |
9 | + | |
10 | +;+ | |
11 | +; NAME: | |
12 | +; dustem_fit_stellarpopisrf_example | |
13 | +; | |
14 | +; PURPOSE: | |
15 | +; This routine is an example of how to fit an observational SED | |
16 | +; (StokesI only) with DustEM and DustEMWrap. The objective is to | |
17 | +; illustrate how to use the stellar population plugin and not to do science -- the fit | |
18 | +; obtained by running this example is likely to be poor. | |
19 | +; | |
20 | +; For this example, the code uses the SED in the file example_SED_2.xcat, | |
21 | +; which is distributed in the Data/EXAMPLE_OBSDATA/ directory | |
22 | +; | |
23 | +; The example SED has Stokes I photometric data points from | |
24 | +; IRAC, MIPS and IRAS. Examples illustrating running DustEMWrap to | |
25 | +; fit spectral data, polarisation data and extinction data | |
26 | +; are provided in other _example routines in the src/idl/ | |
27 | +; directory. See the DustEMWrap User Guide for more information. | |
28 | +; | |
29 | +; CATEGORY: | |
30 | +; DustEMWrap, Distributed, High-Level, User Example | |
31 | +; | |
32 | +; CALLING SEQUENCE: | |
33 | +; dustem_fit_stellarpopisrf_example[,model=][sed_file=][,postscript=][,Nitermax=][,fits_save_and_restore=][,/help,/wait,/verbose] | |
34 | +; | |
35 | +; INPUTS: | |
36 | +; None | |
37 | +; | |
38 | +; OPTIONAL INPUT PARAMETERS: | |
39 | +; None | |
40 | +; | |
41 | +; OUTPUTS: | |
42 | +; None | |
43 | +; | |
44 | +; OPTIONAL OUTPUT PARAMETERS: | |
45 | +; Plots, results structure in binary FITS table format | |
46 | +; | |
47 | +; ACCEPTED KEY-WORDS: | |
48 | +; model = specifies the interstellar dust mixture used by DustEM | |
49 | +; 'MC10' model from Compiegne et al 2010 | |
50 | +; 'DBP90' model from Desert et al 1990 | |
51 | +; 'DL01' model from Draine & Li 2001 | |
52 | +; 'WD01_RV5p5B' model from Weingartner & Draine 2002 with Rv=5.5 | |
53 | +; 'DL07' model from Draine & Li 2007 | |
54 | +; 'J13' model from Jones et al 2013, as updated in | |
55 | +; Koehler et al 2014 | |
56 | +; sed_file = string naming the path to text file in .xcat format that | |
57 | +; describes the observational SED. If not set, the file | |
58 | +; 'Data/EXAMPLE_OBSDATA/example_SED_2.xcat' is used. | |
59 | +; postscript = if set, final plot is saved as postscript in the | |
60 | +; current working directory | |
61 | +; Nitermax = maximum number of fit iterations. Default is 5. | |
62 | +; fits_save_and_restore = if set, save the fit results in a binary | |
63 | +; FITS file. The code then restore this file and plots | |
64 | +; the results using the saved results information. | |
65 | +; help = if set, print this help | |
66 | +; wait = if set, wait this many seconds between each step of | |
67 | +; the code (for illustration purposes) | |
68 | +; verbose = if set, subroutines will run in verbose mode | |
69 | +; | |
70 | +; COMMON BLOCKS: | |
71 | +; None | |
72 | +; | |
73 | +; SIDE EFFECTS: | |
74 | +; None | |
75 | +; | |
76 | +; RESTRICTIONS: | |
77 | +; The DustEM fortran code must be installed | |
78 | +; The DustEMWrap IDL code must be installed | |
79 | +; | |
80 | +; PROCEDURES AND SUBROUTINES USED: | |
81 | +; | |
82 | +; | |
83 | +; EXAMPLES | |
84 | +; dustem_fit_stellarpopisrf_example | |
85 | +; dustem_fit_stellarpopisrf_example,Nitermax=1,fits_save_and_restore='/tmp/mysavefile.fits' | |
86 | +; dustem_fit_stellarpopisrf_example,model='DBP90' | |
87 | +; | |
88 | +; MODIFICATION HISTORY: | |
89 | +; Evolution details on the DustEMWrap gitlab. | |
90 | +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. | |
91 | +;- | |
92 | + | |
93 | + | |
94 | +IF keyword_set(help) THEN BEGIN | |
95 | + doc_library,'dustem_stellarpopisrf_example' | |
96 | + goto,the_end | |
97 | +END | |
98 | + | |
99 | +IF keyword_set(model) THEN BEGIN | |
100 | + use_model=strupcase(model) | |
101 | +ENDIF ELSE BEGIN | |
102 | + use_model='J13' ;Default is last dustem model | |
103 | +ENDELSE | |
104 | + | |
105 | + | |
106 | + | |
107 | + | |
108 | + | |
109 | +use_verbose=0 | |
110 | +if keyword_set(verbose) then use_verbose=1 | |
111 | +use_Nitermax=5 ; maximum number of iterations for the fit | |
112 | +IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax | |
113 | + | |
114 | +dustem_define_la_common | |
115 | + | |
116 | +;=== Set the (model-dependent) parameters that you want to fit | |
117 | +;=== Refer to the DustEM and DustEMWrap userguides for an explanation | |
118 | +; of the different grain types | |
119 | + | |
120 | +CASE use_model OF | |
121 | + 'DBP90':BEGIN | |
122 | + pd = [ $ | |
123 | + '(*!dustem_params).grains(0).mdust_o_mh',$ ;PAH0 mass fraction | |
124 | + '(*!dustem_params).grains(1).mdust_o_mh',$ ;VSG mass fraction | |
125 | + '(*!dustem_params).grains(2).mdust_o_mh', $ ;amCBEx | |
126 | + 'dustem_plugin_stellar_population_O7V3',$ ;distance to stellar population | |
127 | + 'dustem_plugin_stellar_population_O5V4'] ;number of stars | |
128 | + rv = [4.3e-4, 4.7e-4,6.4e-3,1.5,100.] ;rv because we're generating fake data and try to retrieve the original values | |
129 | + | |
130 | + iv = rv+[5.00E-4,5.00E-4,5.00E-4,-1.,-30] ;###setting the initial parameter vector | |
131 | + | |
132 | + Npar=n_elements(pd) | |
133 | + ulimed=replicate(0,Npar) | |
134 | + llimed=replicate(1,Npar) | |
135 | + llims=replicate(0.,Npar) | |
136 | + | |
137 | + | |
138 | + fpd=[ $ | |
139 | + 'dustem_plugin_stellar_population_O7V4',$ ;number of stars of stellar population' , $ ;multiplicative factor to total ISRF | |
140 | + 'dustem_plugin_stellar_population_O5V3'$ ; stellar distance | |
141 | + ] | |
142 | + ;initial parameter values for fixed parameters | |
143 | + fiv=[ $ | |
144 | + 2. , $ ;number of stars of pop O7 | |
145 | + 45$ ;dustance of pop O5 | |
146 | + ] | |
147 | + | |
148 | + END | |
149 | + 'DL01':BEGIN | |
150 | + pd = [ $ | |
151 | + '(*!dustem_params).grains(0).mdust_o_mh',$ ;PAH0 mass fraction | |
152 | + '(*!dustem_params).grains(1).mdust_o_mh',$ ;PAH1 mass fraction | |
153 | + '(*!dustem_params).grains(2).mdust_o_mh', $ ;Gra | |
154 | + '(*!dustem_params).grains(3).mdust_o_mh', $ ;Gra | |
155 | + '(*!dustem_params).grains(4).mdust_o_mh', $ ;aSil | |
156 | + 'dustem_plugin_stellar_population_O5V4'] ;number of stars of pop O5 | |
157 | + | |
158 | + rv = [5.4e-4, 5.4e-4,1.8e-4,2.33e-3,8.27e-3,50] | |
159 | + iv = rv+[5.e-4, 5.e-4,5.e-5,5.e-3,5.e-3,100] | |
160 | + | |
161 | + fpd=[ $ | |
162 | + 'dustem_plugin_stellar_population_O5V3'$ ; stellar distance | |
163 | + ] | |
164 | + ;initial parameter values for fixed parameters | |
165 | + fiv=[ $ | |
166 | + 45$ ;fixed stellar distance | |
167 | + ] | |
168 | + | |
169 | + | |
170 | + Npar=n_elements(pd) | |
171 | + ulimed=replicate(0,Npar) | |
172 | + llimed=replicate(1,Npar) | |
173 | + llims=replicate(0.,Npar) | |
174 | + END | |
175 | + 'WD01_RV5p5B':BEGIN | |
176 | +;; ***COMMENT AH*** | |
177 | +;; we need to implement this, or remove | |
178 | + message, 'WD01 model not yet implemented in DustEMWrap',/info | |
179 | +;; ***END COMMENT AH*** | |
180 | + END | |
181 | + 'DL07':BEGIN | |
182 | + pd = [ $ | |
183 | + '(*!dustem_params).grains(0).mdust_o_mh', $ ;PAH0 mass fraction | |
184 | + '(*!dustem_params).grains(1).mdust_o_mh', $ ;PAH1 mass fraction | |
185 | + '(*!dustem_params).grains(2).mdust_o_mh', $ ;Gra | |
186 | + '(*!dustem_params).grains(3).mdust_o_mh', $ ;Gra | |
187 | + '(*!dustem_params).grains(4).mdust_o_mh', $ ;aSil | |
188 | + 'dustem_plugin_stellar_population_O5V3' $ ;distance to stellar pop O5V | |
189 | + ] | |
190 | + | |
191 | + rv = [5.4e-4, 5.4e-4,1.8e-4,2.33e-3,8.27e-3,5.];,10,1.,10.,1.] | |
192 | + iv = rv+ [5.e-4, 5.e-4,5.e-4,5.e-3,5.e-3,25.] | |
193 | + | |
194 | + Npar=n_elements(pd) | |
195 | + ulimed=replicate(0,Npar) | |
196 | + llimed=replicate(1,Npar) | |
197 | + llims=replicate(0.,Npar) | |
198 | + | |
199 | + fpd=[ $ | |
200 | + 'dustem_plugin_stellar_population_O5V4'$ ; stellar number of pop O5V | |
201 | + ] | |
202 | + ;initial parameter values for fixed parameters | |
203 | + fiv=[ $ | |
204 | + 30$ ;fixed stellar population number | |
205 | + ] | |
206 | + | |
207 | + END | |
208 | + 'MC10':BEGIN | |
209 | + | |
210 | + pd = [ $ | |
211 | + 'dustem_plugin_stellar_population_O5V4', $ ;stellar number of pop O5V | |
212 | + '(*!dustem_params).grains(0).mdust_o_mh',$ ;PAH0 mass fraction | |
213 | + '(*!dustem_params).grains(1).mdust_o_mh',$ ;PAH1 mass fraction | |
214 | + '(*!dustem_params).grains(2).mdust_o_mh', $ ;amCBEx | |
215 | + '(*!dustem_params).grains(3).mdust_o_mh', $ ;amCBEx | |
216 | + '(*!dustem_params).grains(4).mdust_o_mh' $ ;aSilx | |
217 | + ] | |
218 | + ;initial parameter values for parameters to be fitted | |
219 | + rv = [ $ | |
220 | + 50, $ | |
221 | + 7.8e-4, $ ;mass fraction of PAH0 | |
222 | + 7.8e-4, $ ;mass fraction of PAH1 | |
223 | + 1.65e-4, $ ;mass fraction of amCBEx | |
224 | + 1.45e-3, $ ;mass fraction of amCBEx | |
225 | + 7.8e-3 $ ;mass fraction of aSilx | |
226 | + ] | |
227 | + | |
228 | + iv = rv + [-30,5.E-4,5.E-4,5.E-4,5.E-3,5.E-3] | |
229 | + | |
230 | + fpd = ['dustem_plugin_stellar_population_O5V3'] ;distance to stellar population O5V | |
231 | + fiv = [25] | |
232 | + | |
233 | + | |
234 | + Npar=n_elements(pd) | |
235 | + | |
236 | + ulimed=replicate(0,Npar) | |
237 | + llimed=replicate(1,Npar) | |
238 | + llims=replicate(0.,Npar) | |
239 | + | |
240 | + END | |
241 | + 'J13':BEGIN | |
242 | + pd = [ $ | |
243 | + '(*!dustem_params).grains(1).mdust_o_mh',$ ;CM20 mass fraction | |
244 | + '(*!dustem_params).grains(0).mdust_o_mh',$ ;CM20 mass fraction | |
245 | + '(*!dustem_params).grains(2).mdust_o_mh', $ ;aPyM5 | |
246 | + '(*!dustem_params).grains(3).mdust_o_mh', $ ;aPyM5 | |
247 | + 'dustem_plugin_stellar_population_O5V4'] ;stellar number of pop O5V | |
248 | + | |
249 | + rv = [7.8e-4, 7.8e-4,1.65e-4,1.45e-3,35] | |
250 | + iv = rv+ [5.e-4,5.e-4,5.e-4,5.e-3,35] | |
251 | + | |
252 | + Npar=n_elements(pd) | |
253 | + ulimed=replicate(0,Npar) | |
254 | + llimed=replicate(1,Npar) | |
255 | + llims=replicate(0.,Npar) | |
256 | + | |
257 | + fpd = ['dustem_plugin_stellar_population_O5V3'] ;distance to stellar population O5V | |
258 | + fiv = [5] | |
259 | + | |
260 | + END | |
261 | + 'ELSE':BEGIN | |
262 | + message,'model '+model+' unknown',/continue | |
263 | + message,'Known models are MC10,DBP90,DL01,DL07,J13,G17_MODELA,G17_MODELB,G17_MODELC,G17_MODELD',/continue | |
264 | + stop | |
265 | + END | |
266 | +ENDCASE | |
267 | + | |
268 | + | |
269 | +if keyword_set(wait) then begin | |
270 | + message,'Finished setting dust model and plug-in parameters: '+use_model,/info | |
271 | + wait,wait | |
272 | +end | |
273 | + | |
274 | + | |
275 | +dustem_init,model=use_model | |
276 | + | |
277 | +!dustem_nocatch=1 | |
278 | +!dustem_verbose=1 | |
279 | +;!dustem_show_plot=1 | |
280 | +!EXCEPT=2 ;so I can locate the plotting error... | |
281 | +;!dustem_dim=1 ; this option is to dim the stellar population ISRF with the current Dustem extinction | |
282 | +;We're fitting total optical depths so the dimmed-ISRF scenario is a reasonable assumption. | |
283 | +;Because of this the final parameter values are slightly lower than the initial (real) values. | |
284 | +;But this is because the first run was not extinct with the current dustem extinction | |
285 | +;since it comes prior to the dustem run. Meaning the first ISRF has to be extinct to see if the paramters are retrieved. | |
286 | + | |
287 | + | |
288 | +!dustem_isrf_file=ptr_new(!dustem_soft_dir+'data/ISRF_MATHIS.DAT') | |
289 | + | |
290 | + | |
291 | +;=== READ EXAMPLE DATA: EXTINCTION | |
292 | + | |
293 | +;NB:HERE WE ARE NOT FITTING THE DATA. WE'RE JUST USING THE EXISTING FILTERS. | |
294 | + | |
295 | +dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/' | |
296 | +file=dir+'example_SED_2.xcat' | |
297 | +sed=read_xcat(file,/silent) | |
298 | + | |
299 | +if keyword_set(wait) then begin | |
300 | + message,'Finished reading SED data: '+file,/info | |
301 | + wait,wait | |
302 | +end | |
303 | + | |
304 | + | |
305 | +;=== GENERATE EXAMPLE DATA: EXTINCTION | |
306 | + | |
307 | +;=== initializing IQU and associated errors to avoid problems when checking SED in dustem_set_data.pro | |
308 | +;sed.StokesI=1. | |
309 | +;setting the errors (well equating all the tags to the sigmaii array but this is an initialization) | |
310 | +for i=4l,n_tags(sed)-1 do begin | |
311 | + sed.(i) = sed.sigmaii | |
312 | +endfor | |
313 | + | |
314 | +;###first call to dustem_set_data so that the !dustem_data tags that are used in the 'compute_' procedures are set | |
315 | + | |
316 | +dustem_set_data,sed,sed | |
317 | + | |
318 | +; ;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS THAT WILL BE | |
319 | +; ;== ADJUSTED DURING THE FIT | |
320 | +; dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims | |
321 | +; | |
322 | +; ;== INITIALIZE ANY PLUGINS | |
323 | +; dustem_init_plugins, pd,fpd=fpd | |
324 | +; | |
325 | +; dustem_init_fixed_params,fpd,fiv | |
326 | + | |
327 | +dustem_init_params,use_model,pd,iv,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,ulims=ulims,llims=llims | |
328 | + | |
329 | +;Generating the fake emission data | |
330 | +sed.StokesI = dustem_compute_sed(rv,st=st) | |
331 | + | |
332 | +;== SET THE OBSERVATIONAL STRUCTURE | |
333 | +dustem_set_data, sed,sed | |
334 | + | |
335 | + | |
336 | +if keyword_set(wait) then begin | |
337 | + message,'Finished initializing DustEMWrap, including plugins and fixed parameters',/info | |
338 | + wait,wait | |
339 | +end | |
340 | + | |
341 | +;== RUN THE FIT | |
342 | +tol=1.e-18 | |
343 | +use_Nitermax=20 ;maximum number of iterations. | |
344 | +IF keyword_set(itermax) THEN use_Nitermax=itermax | |
345 | + | |
346 | +xr_m = [1.,5e5] | |
347 | +yr_m = [5e-8,1.00e6] | |
348 | + | |
349 | + | |
350 | +tit='Spectral Energy Distribution' | |
351 | +ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') | |
352 | +xtit=textoidl('\lambda (\mum)') | |
353 | +;Set show_plot to 0 to hide plot | |
354 | +;Commented or set to 1 is the same since !dustem_show_plot (existing sysvar) is initialized to 1 in dustem_init | |
355 | +;show_plot = 0 | |
356 | +t1=systime(0,/sec) | |
357 | +res=dustem_mpfit_data(tol=tol,Nitermax=use_Nitermax,gtol=gtol $ | |
358 | + ,/xlog,/ylog,xr_m=xr_m,yr_m=yr_m,xtit=xtit,ytit=ytit,title=tit $ | |
359 | + ,legend_xpos=legend_xpos,legend_ypos=legend_ypos $ | |
360 | + ,errors=errors,chi2=chi2,rchi2=rchi2,show_plot=show_plot) | |
361 | +t2=systime(0,/sec) | |
362 | + | |
363 | + | |
364 | +if keyword_set(wait) then begin | |
365 | + message,'Finished running DustEMWrap, using Niters: '+strtrim(string(use_Nitermax),2),/info | |
366 | + message,'Time taken [sec]: '+sigfig(t2-t1,2,/sci),/info | |
367 | + wait,wait | |
368 | +end | |
369 | + | |
370 | + | |
371 | +;=== MAKE THE FINAL PLOT | |
372 | +IF keyword_set(postscript) THEN BEGIN | |
373 | + dir_ps='./' | |
374 | + set_plot,'PS' | |
375 | + ps_file=dir_ps+postscript | |
376 | + device,filename=ps_file,/color | |
377 | +ENDIF | |
378 | + | |
379 | +IF !dustem_noobj THEN BEGIN | |
380 | + dustemwrap_plot_noobj,*(*!dustem_fit).CURRENT_PARAM_VALUES,dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' | |
381 | + ENDIF ELSE BEGIN | |
382 | + dustemwrap_plot,*(*!dustem_fit).CURRENT_PARAM_VALUES,dummy,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (Final fit)' | |
383 | +ENDELSE | |
384 | + | |
385 | +IF keyword_set(postscript) THEN BEGIN | |
386 | + set_plot,'X' | |
387 | + device,/close | |
388 | + message,'Wrote '+ps_file,/info | |
389 | +ENDIF | |
390 | + | |
391 | +if keyword_set(wait) then begin | |
392 | + message,'Made the plot of the final results',/info | |
393 | + wait,wait | |
394 | +end | |
395 | + | |
396 | +IF keyword_set(fits_save_and_restore) THEN BEGIN | |
397 | + message,'Writing out results structure: '+fits_save_and_restore,/info | |
398 | + dustem_write_fits_table,filename=fits_save_and_restore,help=help | |
399 | +;=== At this point, you could erase all dustem system variables, or exit idl... all the | |
400 | +;=== information needed to recover the results and remake the plots has been saved in the FITS table | |
401 | + ;stop | |
402 | + dustem_read_fits_table,filename=fits_save_and_restore,dustem_spectra_st=dustem_spectra_st | |
403 | + ;==== plot result taken from the saved fits table | |
404 | + res=*(*!dustem_fit).CURRENT_PARAM_VALUES | |
405 | + IF !dustem_noobj THEN BEGIN | |
406 | + dustemwrap_plot_noobj,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
407 | + ENDIF ELSE BEGIN | |
408 | + dustemwrap_plot,res,dustem_spectra_st,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,title=tit+' (From Saved FITS file)' | |
409 | + ENDELSE | |
410 | + IF keyword_set(wait) THEN BEGIN | |
411 | + message,'Saved the results as FITS in the file: '+fits_save_and_restore+', and made a plot using the data in this file',/info | |
412 | + wait,wait | |
413 | + ENDIF | |
414 | +ENDIF | |
415 | + | |
416 | +message,'Finished dustem_fit_intensity_example',/info | |
417 | + | |
418 | + | |
419 | +the_end: | |
420 | + | |
421 | +END | ... | ... |