Commit 1355825cf3651fa87141046849d32ebd8d10be92
1 parent
18e4331f
Exists in
master
General update
Showing
11 changed files
with
355 additions
and
305 deletions
Show diff stats
src/idl/dustem_activate_plugins.pro
... | ... | @@ -82,15 +82,6 @@ FOR i=0L,n_elements(p_min)-1 DO BEGIN |
82 | 82 | |
83 | 83 | ;==============Assigning data to the initialized plugin data arrays============== |
84 | 84 | |
85 | - | |
86 | - print, 'ftn is:' | |
87 | - print, ftn | |
88 | - print, 'key is:' | |
89 | - print, index | |
90 | - print, 'val is:' | |
91 | - print, value | |
92 | - | |
93 | - | |
94 | 85 | if strmid(ftn,0,13) eq 'dustem_plugin' then begin |
95 | 86 | |
96 | 87 | ... | ... |
src/idl/dustem_fit_sed_readme.pro
... | ... | @@ -343,7 +343,7 @@ CASE use_model OF |
343 | 343 | END |
344 | 344 | 'THEMIS':BEGIN |
345 | 345 | pd = [ $ |
346 | - '(*!dustem_params).G0', $ ;G0 | |
346 | + '(*!dustem_params).G0', $ h;G0 | |
347 | 347 | '(*!dustem_params).grains(0).mdust_o_mh',$ |
348 | 348 | '(*!dustem_params).grains(1).mdust_o_mh',$ |
349 | 349 | '(*!dustem_params).grains(2).mdust_o_mh', $ |
... | ... | @@ -358,7 +358,7 @@ CASE use_model OF |
358 | 358 | |
359 | 359 | ENDCASE |
360 | 360 | |
361 | -dustem_init,model=use_model,pol=polarization | |
361 | +dustem_init,model=use_model;,pol=polarization | |
362 | 362 | !dustem_nocatch=1 |
363 | 363 | |
364 | 364 | !dustem_verbose=1 |
... | ... | @@ -382,8 +382,8 @@ ind=where(spec.instru EQ 'FIRAS',count) |
382 | 382 | IF count NE 0 THEN spec(ind).sigmaII=(0.2*spec(ind).StokesI)^2 |
383 | 383 | |
384 | 384 | ;=== SET THE OBSERVATION STRUCTURE |
385 | -st=dustem_set_data(sed=spec) | |
386 | - | |
385 | +st=dustem_set_data(st_sed_fit=spec);sed=spec) | |
386 | +;stop | |
387 | 387 | ;== SET THE FITTED PARAMETERS |
388 | 388 | dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims |
389 | 389 | |
... | ... | @@ -401,8 +401,8 @@ use_Nitermax=5 ;maximum number of iteration. This is the criterium which will st |
401 | 401 | IF keyword_set(itermax) THEN use_Nitermax=itermax |
402 | 402 | |
403 | 403 | t1=systime(0,/sec) |
404 | -yr=[1e-4,100] | |
405 | -xr=[1,6e4] | |
404 | +yr=[1.00e-4,1.00E2] | |
405 | +xr=[1.00E0,6.00e4] | |
406 | 406 | ;legend_xpos=0.6 |
407 | 407 | ;legend_ypos=0.8 |
408 | 408 | tit='Spectral Energy Distribution (Running)' | ... | ... |
src/idl/dustem_init.pro
... | ... | @@ -205,7 +205,7 @@ defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run. |
205 | 205 | ext: {pl:0, nrm:0}, $ |
206 | 206 | polext: {pl:0, nrm:0}, $ |
207 | 207 | polsed: {pl:0, nrm:0}, $ |
208 | - polfrac: {pl:0, nrm:0}, $ | |
208 | + polfrac: {pl:0}, $ | |
209 | 209 | psi_em: {pl:0}, $ |
210 | 210 | psi_ext: {pl:0}, $ |
211 | 211 | qsed: {pl:0, nrm:0}, $ | ... | ... |
src/idl/dustem_init_plugins.pro
1 | 1 | PRO dustem_init_plugins, pd, fpd |
2 | 2 | |
3 | +;NB: | |
4 | +;#Fixed parameters still haven't been taken care of | |
5 | +;#There is use of pointers when the need does not present itself. This implies modifying the rest of the code. | |
6 | + | |
3 | 7 | |
4 | 8 | ;INITIALIZING THE SCOPES DATA ARRAYS-------------------- |
5 | 9 | |
... | ... | @@ -79,7 +83,7 @@ IF Nplugins NE 0 THEN BEGIN |
79 | 83 | message, 'varvar is:',/continue |
80 | 84 | print, varvar |
81 | 85 | |
82 | - defsysv, '!dustem_scope', ptr_new(varvar) | |
86 | + defsysv, '!dustem_scope', ptr_new(varvar) | |
83 | 87 | |
84 | 88 | ENDIF ELSE BEGIN ;case of one plugin |
85 | 89 | ... | ... |
src/idl/dustem_mpfit_data.pro
... | ... | @@ -58,7 +58,23 @@ IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax |
58 | 58 | |
59 | 59 | ; Build array concatenating observational datas |
60 | 60 | ; Order : that of !dustem_data (sed, ext, polext, polsed) |
61 | -ind_data_tag=dustem_data_tag(count=count_data_tag) | |
61 | + | |
62 | +if !run_pol then begin | |
63 | + | |
64 | + ind_data_tag=dustem_data_tag(count=count_data_tag) | |
65 | + tagnames=tag_names(!dustem_data) | |
66 | + testpol = tagnames EQ 'POLSED' or tagnames EQ 'POLEXT' or tagnames EQ 'POLFRAC' or tagnames EQ 'POLSED' or tagnames EQ 'PSI_EM' or tagnames EQ 'PSI_EXT' | |
67 | + data_ind=where(~testpol,ctestpol) | |
68 | + if ctestpol ne 0 then begin | |
69 | + match,ind_data_tag,data_ind,ind1,ind2 ;not using match2 because when matching indices, if the first is 0 it doesn't count which is wrong. | |
70 | + ;I also only need the points that match. | |
71 | + ;testind1 = where(ind1 ne -1,ctind1) | |
72 | + ;if ctind1 ne 0 then ind_data_tag = ind_data_tag[testind1] | |
73 | + ind_data_tag = ind_data_tag[ind1] | |
74 | + count_data_tag = n_elements(ind_data_tag) | |
75 | + endif | |
76 | +endif else ind_data_tag=dustem_data_tag(count=count_data_tag) | |
77 | + | |
62 | 78 | |
63 | 79 | fields=['wav','values','sigma'] |
64 | 80 | FOR j=0,n_elements(fields)-1 DO BEGIN |
... | ... | @@ -104,6 +120,7 @@ p_min = dustem_mpfitfun(func_name,wav,values,sigma, $ |
104 | 120 | parinfo=(*!dustem_parinfo), perror=perror, yfit=yfit, $ |
105 | 121 | bestnorm=bestnorm, dof=dof,quiet=quiet, status=status, xtol=xtol, niter=niter_completed, ftol=use_tol, $ |
106 | 122 | maxiter=use_Nitermax,gtol=gtol,errmsg=errmsg,functargs=_extra,nocatch=nocatch) |
123 | + | |
107 | 124 | message,errmsg,/info |
108 | 125 | message,'mpfitfun Status='+strtrim(status,2),/info |
109 | 126 | p_dim=p_min*(*(*!dustem_fit).param_init_values) | ... | ... |
src/idl/dustem_mpfit_run.pro
... | ... | @@ -112,26 +112,12 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN |
112 | 112 | print,"Best SED chi2 obtained if f_HI = ",alpha, " or if we multiply model by ",beta |
113 | 113 | (*!dustem_fit).chi2=chi2_sed |
114 | 114 | (*!dustem_fit).rchi2=rchi2_sed |
115 | - ; Plot if needed | |
116 | - IF !dustem_show_plot NE 0 THEN BEGIN | |
117 | - | |
118 | - ;window,win,title='DUSTEM WRAP (SED)' | |
119 | - | |
120 | - ;cgwindow,WMULTI=[2,2,1],/CURRENT | |
121 | - | |
122 | - | |
123 | - | |
124 | - ;stop | |
125 | - ;dustemwrap_plott,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra | |
126 | - ;dustem_plot_fit_sed,st,dustem_sed,_extra=_extra,res=p_min*(*(*!dustem_fit).param_init_values),chi2=(*!dustem_fit).chi2,rchi2=(*!dustem_fit).rchi2,fpol=fpol | |
127 | - | |
128 | - ENDIF | |
129 | - | |
130 | - dustem_out = [ dustem_out, dustem_sed ] | |
115 | + | |
116 | + if isa(!dustem_data.sed) then dustem_out = [ dustem_out, dustem_sed ] | |
131 | 117 | |
132 | 118 | END |
133 | 119 | |
134 | - 'EXT' : BEGIN | |
120 | + 'EXT' : BEGIN ;STILL HAVEN'T DONE THE EXTINCTION PART | |
135 | 121 | |
136 | 122 | ;ADDING PLUGIN TO SPECTRUM---------------- |
137 | 123 | IF ptr_valid(*!dustem_plugin) THEN BEGIN |
... | ... | @@ -266,67 +252,65 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN |
266 | 252 | |
267 | 253 | END |
268 | 254 | |
269 | - ; 'POLFRAC': BEGIN | |
270 | -; if !run_lin then begin | |
271 | -; dustem_polsed = dustem_compute_polsed(p_dim,st) ; this quantity hasn't been computed yet that is why this line is present here. | |
272 | -; ind_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',count_filt) ;locating the filters of polfrac=smallp in SED xcat | |
273 | -; ind_fspec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',count_fspec) ;locating the spectrum points in polfrac data. Later testing will have to be on the wavelengths | |
274 | -; ; | |
275 | -; ; ;dustem_sed and dustem_polsed might not have the same length thus this block. | |
276 | -; ; | |
277 | -; If n_elements(dustem_sed) ne n_elements(dustem_polsed) then begin | |
278 | -; if n_elements(dustem_sed) gt n_elements(dustem_polsed) then begin | |
279 | -; dustem_polsed_x = dustem_polsed | |
280 | -; dustem_sed_x = dustem_polsed ;meaning dustem_sed needs to be modified | |
281 | -; ;matching the filter data points | |
282 | -; IF count_filt ne 0 then begin | |
283 | -; for i=0L,count_filt-1 do begin | |
284 | -; j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt) | |
285 | -; if testfilt ne 0 then dustem_sed_x(ind_filt(i)) = dustem_sed(j(0)) | |
286 | -; endfor | |
287 | -; endif | |
288 | -; ;matching the spectrum data points | |
289 | -; IF count_fspec ne 0 then begin | |
290 | -; for i=0L,count_fspec-1 do begin | |
291 | -; j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec) | |
292 | -; if testspec ne 0 then dustem_sed_x((ind_fspec(i))) = dustem_sed(j(0)) | |
293 | -; ; endfor | |
294 | -; endif | |
295 | -; endif ELSE begin | |
296 | -; | |
297 | -; dustem_polsed_x = dustem_sed | |
298 | -; dustem_sed_x = dustem_sed ;meaning dustem_polsed needs to be modified | |
299 | -; ;matching the filter data points | |
300 | -; IF count_filt ne 0 then begin | |
301 | -; for i=0L,count_filt-1 do begin | |
302 | -; j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt) | |
303 | -; if testfilt ne 0 then dustem_polsed_x(ind_filt(i)) = dustem_polsed(j(0)) | |
304 | -; endfor | |
305 | -; endif | |
306 | -; ;matching the spectrum data points | |
307 | -; IF count_fspec ne 0 then begin | |
308 | -; for i=0L,count_fspec-1 do begin | |
309 | -; j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec) | |
310 | -; if testspec ne 0 then dustem_polsed_x((ind_fspec(i))) = dustem_polsed(j(0)) | |
311 | -; endfor | |
312 | -; endif | |
313 | -; | |
314 | -; ENDELSE | |
315 | -; endif ELSE BEGIN | |
316 | -; dustem_polsed_x = dustem_polsed | |
317 | -; dustem_sed_x = dustem_sed | |
318 | -; ENDELSE | |
255 | +;!!!!!!!!!!!!!YOU NEED TO RUN 'COMPUTE_SED' AGAIN because you have no idea if the sed block will be run. | |
256 | + | |
257 | + 'POLFRAC': BEGIN | |
258 | + if !run_lin then begin | |
259 | + if ~isa(dustem_sed) then dustem_sed = dustem_compute_sed(p_dim,st) | |
260 | + dustem_polsed = dustem_compute_polsed(p_dim,st) ; this quantity hasn't been computed yet that is why this line is present here. | |
261 | + ind_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',count_filt) ;locating the filters of polfrac=smallp in SED xcat | |
262 | + ind_fspec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',count_fspec) ;locating the spectrum points in polfrac data. Later testing will have to be on the wavelengths | |
319 | 263 | ; |
320 | -; dustem_polfrac = dustem_polsed_x/dustem_sed_x | |
321 | -; chi2_polfrac = total(((*!dustem_data.polfrac).values-dustem_polfrac)^2/(*!dustem_data.polfrac).sigma^2) | |
322 | -; n_polfrac = n_elements((*!dustem_data.polfrac).values) | |
323 | -; rchi2_polfrac = chi2_polfrac / n_polfrac | |
324 | -; wrchi2_polfrac = rchi2_polfrac * !fit_rchi2_weight.polfrac | |
325 | -; message,"chi2 POLFRAC = "+strtrim(chi2_polfrac,2)+" rchi2 POLFRAC = "+strtrim(rchi2_polfrac,2),/continue ;," weighted rchi2 POLFRAC=",wrchi2_polfrac | |
326 | -; dustem_out = [ dustem_out, dustem_polfrac ] | |
327 | -; ;fpol=dustem_polfrac ; problem because extra structure does not get updated so you actually need the 'extra' procedure you haven't finihed coding. | |
328 | -; endif | |
329 | - ; END | |
264 | +; ;dustem_sed and dustem_polsed might not have the same length thus this block. | |
265 | +; | |
266 | + If n_elements(dustem_sed) ne n_elements(dustem_polsed) then begin | |
267 | + if n_elements(dustem_sed) gt n_elements(dustem_polsed) then begin | |
268 | + dustem_polsed_x = dustem_polsed | |
269 | + dustem_sed_x = dustem_polsed ;meaning dustem_sed needs to be modified | |
270 | + ;matching the filter data points | |
271 | + IF count_filt ne 0 then begin | |
272 | + for i=0L,count_filt-1 do begin | |
273 | + j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt) | |
274 | + if testfilt ne 0 then dustem_sed_x(ind_filt(i)) = dustem_sed(j(0)) | |
275 | + endfor | |
276 | + endif | |
277 | + ;matching the spectrum data points | |
278 | + IF count_fspec ne 0 then begin | |
279 | + for i=0L,count_fspec-1 do begin | |
280 | + j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec) | |
281 | + if testspec ne 0 then dustem_sed_x((ind_fspec(i))) = dustem_sed(j(0)) | |
282 | + endfor | |
283 | + endif | |
284 | + endif ELSE begin | |
285 | + | |
286 | + dustem_polsed_x = dustem_sed | |
287 | + dustem_sed_x = dustem_sed ;meaning dustem_polsed needs to be modified | |
288 | + ;matching the filter data points | |
289 | + IF count_filt ne 0 then begin | |
290 | + for i=0L,count_filt-1 do begin | |
291 | + j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt) | |
292 | + if testfilt ne 0 then dustem_polsed_x(ind_filt(i)) = dustem_polsed(j(0)) | |
293 | + endfor | |
294 | + endif | |
295 | + ;matching the spectrum data points | |
296 | + IF count_fspec ne 0 then begin | |
297 | + for i=0L,count_fspec-1 do begin | |
298 | + j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec) | |
299 | + if testspec ne 0 then dustem_polsed_x((ind_fspec(i))) = dustem_polsed(j(0)) | |
300 | + endfor | |
301 | + endif | |
302 | + | |
303 | + ENDELSE | |
304 | + endif ELSE BEGIN | |
305 | + dustem_polsed_x = dustem_polsed | |
306 | + dustem_sed_x = dustem_sed | |
307 | + ENDELSE | |
308 | + | |
309 | + dustem_polfrac = dustem_polsed_x/dustem_sed_x | |
310 | + | |
311 | + ENDIF | |
312 | + ;stop | |
313 | + END | |
330 | 314 | |
331 | 315 | |
332 | 316 | ;----------------------------------------------------------------- |
... | ... | @@ -335,40 +319,16 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN |
335 | 319 | ;PLUGIN IS ADDED INSIDE DUSTEM_COMPUTE_SED |
336 | 320 | |
337 | 321 | IF !run_lin THEN BEGIN |
338 | - ;make polsed only used for when polsed is fitted. Otherwise it's the fitting of Q_SED AND USED that fits the polarization data | |
322 | + | |
339 | 323 | dustem_polsed = dustem_compute_polsed(p_dim,st);dustem_compute_polsed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron) |
340 | 324 | |
341 | - ;chi2_polsed = total(((*!dustem_data.polsed).values-dustem_polsed)^2/(*!dustem_data.polsed).sigma^2) | |
342 | - ;n_polsed = n_elements((*!dustem_data.polsed).values) | |
343 | - ;rchi2_polsed = chi2_polsed / n_polsed | |
344 | - ;wrchi2_polsed = rchi2_polsed * !fit_rchi2_weight.polsed | |
345 | - ;message,"chi2 POLSED = "+strtrim(chi2_polsed,2)+" rchi2 POLSED = "+strtrim(rchi2_polsed,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed | |
346 | - ;print,"chi2 per wl: ",((*!dustem_data.polsed).values-dustem_polsed)^2/(*!dustem_data.polsed).sigma^2 | |
347 | - ;print,"SNR per wl: ",(*!dustem_data.polsed).values/(*!dustem_data.polsed).sigma | |
348 | - | |
349 | - ;dustem_out = [ dustem_out, dustem_polsed ] ; classic command | |
350 | - ;----------------------------------------------- | |
351 | - | |
352 | - ; Plot if needed | |
353 | -; IF !dustem_show_plot NE 0 THEN BEGIN | |
354 | -; win+=1 | |
355 | -; ; | |
356 | -; xr=[10,8e3] | |
357 | -; yr=[1e-34,1e-28] | |
358 | -; | |
359 | -; dustem_plot_polsed,st,p_dim,dustem_polsed,aligned=st_model.align.grains.aligned,win=win | |
360 | -; ; dustem_plot_polar,st,p_dim,aligned=st_model.align.grains.aligned,/SED,ps=filename,win=win,cont=cont,freefree=freefree,synchrotron=synchrotron,xr=xr,yr=yr,/xsty,/donotclose,multi=1 | |
361 | -; ; dustem_plot_polar,st,p_dim,aligned=st_model.align.grains.aligned,/SED,ps=filename,win=win,cont=cont,freefree=freefree,synchrotron=synchrotron,xr=xr,yr=yr,/xsty,multi=2 | |
362 | -; | |
363 | -; | |
364 | -; | |
365 | -; ENDIF | |
366 | 325 | ENDIF |
367 | 326 | END |
368 | 327 | |
369 | 328 | 'QSED': BEGIN |
370 | 329 | |
371 | 330 | toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec) |
331 | + | |
372 | 332 | ;taking care of the color correction for spass ; SHOULD NOT LEAVE THIS ON |
373 | 333 | ;dustem_qsed(-1)=dustem_qsed(-2) |
374 | 334 | ; testspass1 = ((*!dustem_data.qsed).filt_names)(-1) eq 'SPASS1' |
... | ... | @@ -378,118 +338,24 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN |
378 | 338 | n_qsed = n_elements((*!dustem_data.qsed).values) |
379 | 339 | rchi2_qsed = chi2_qsed / n_qsed |
380 | 340 | wrchi2_qsed = rchi2_qsed * !fit_rchi2_weight.qsed |
381 | - dustem_out = [ dustem_out, dustem_qsed ] ; classic command | |
341 | + if isa(!dustem_data.qsed) then dustem_out = [ dustem_out, dustem_qsed ] ; classic command | |
382 | 342 | message,"chi2 QSED = "+strtrim(chi2_qsed,2)+" rchi2 QSED = "+strtrim(rchi2_qsed,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed |
383 | 343 | print,"chi2 per wl: ",((*!dustem_data.qsed).values-dustem_qsed)^2/(*!dustem_data.qsed).sigma^2 |
384 | 344 | |
385 | - ;stop | |
386 | - | |
387 | - ;stop | |
388 | -; if !dustem_show_plot NE 0 then begin | |
389 | -; fact = 1.00E-20;(3.e10/(1.e-4*(st.polsed.wav)))/1.d40 | |
390 | -; fact1 = 1.00E-20;(3.e10/(1.e-4*((*!dustem_data.qsed).wav)))/1.d40 ; for data plotting | |
391 | -; | |
392 | -; ; fact=1/(4.*!pi)/(3.e8/1.e-6/(st.polsed).wav)*1.00e17 | |
393 | -; ; fact1=1.E-20 | |
394 | -; ; | |
395 | -; win+=1 | |
396 | -; window ,win ,title='DUSTEM WRAP (QSED)' | |
397 | -; titstq='Stokes Q Polarization Intensity' | |
398 | -; ytitstq=textoidl('Q_\nu (W/m^2/Hz/sr) for N_H=10^{20} H/cm^2') | |
399 | -; xtit=textoidl('\lambda (\mum)') | |
400 | -; xr=[10,1e6] | |
401 | -; | |
402 | -; ;normpol1=(*!dustem_data.qsed).values*fact1 | |
403 | -; yr=[1e-28,1e-17] | |
404 | -; ;yr=[1e-34,1e-23] | |
405 | -; indq=where(Q_spec lt 0, countq) | |
406 | -; ;indq=where((*!dustem_data.qsed).values lt 0, countq) | |
407 | -; | |
408 | -; ylog=1 | |
409 | -; if countq ne 0 then begin | |
410 | -; ; ylog=0 | |
411 | -; ; yr=[-1E-23,-1e-19];e-31 | |
412 | -; Q_spec=-Q_spec | |
413 | -; dustem_qsed =-dustem_qsed | |
414 | -; ((*!dustem_data.qsed).values)=-((*!dustem_data.qsed).values) | |
415 | -; endif | |
416 | -; normpol=Q_spec*fact | |
417 | -; normpol1=dustem_qsed*fact1 | |
418 | -; | |
419 | -; | |
420 | -; cgplot,st.polsed.wav,Q_spec*fact,xtit='',ytit=ytitstq,tit=titstq,ylog=ylog,/xlog,xr=xr,yr=yr,/ys,/xs,position=[0.17,0.35,0.93,0.93],xtickformat='(A1)' | |
421 | -; cgoplot,st.polsed.wav,Q_spec*fact,color='black' | |
422 | -; cgoplot,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1,color='Tomato',psym=16,symsize=1,thick=2 | |
423 | -; err_bar,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1,yrms=3.*((*!dustem_data.qsed).sigma)/2.*fact1,color=cgColor('Tomato') | |
424 | -; cgoplot,(*!dustem_data.qsed).wav,dustem_qsed*fact1,psym=6,color='red',symsize=2 | |
425 | -; | |
426 | -; cgplot,st.polsed.wav,Q_spec*fact/normpol,xtit=xtit,ytit='Normalized',tit='',/xlog,xr=xr,/ys,/xs,yr=[0,2],ylog=0,position=[0.17,0.14,0.93,0.35],/noerase,yticks=2,ymino=5,xticklen=0.1 | |
427 | -; cgoplot,st.polsed.wav,Q_spec*fact/normpol,color='black' | |
428 | -; cgoplot,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1/normpol1,color='Tomato',psym=16,symsize=1,thick=2 | |
429 | -; err_bar,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1/normpol1,yrms=3.*((*!dustem_data.qsed).sigma)/2.*fact1/normpol1,color=cgColor('Tomato') | |
430 | -; | |
431 | -; endif | |
432 | 345 | END |
433 | 346 | |
434 | 347 | 'USED': BEGIN |
435 | - | |
436 | - ;toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec) | |
437 | - ;stop | |
348 | + ;THIS IMPLIES THAT QSED HAS BEEN RAN BEFORE | |
438 | 349 | chi2_used =total(((*!dustem_data.used).values-dustem_used)^2/(*!dustem_data.used).sigma^2) |
439 | 350 | n_used = n_elements((*!dustem_data.used).values) |
440 | 351 | rchi2_used = chi2_used / n_used |
441 | 352 | wrchi2_used = rchi2_used * !fit_rchi2_weight.used |
442 | - dustem_out = [ dustem_out, dustem_used] ; classic command | |
353 | + if isa(!dustem_data.used) then dustem_out = [ dustem_out, dustem_used] ; classic command | |
443 | 354 | message,"chi2 USED = "+strtrim(chi2_used,2)+" rchi2 USED = "+strtrim(rchi2_used,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed |
444 | 355 | print,"chi2 per wl: ",((*!dustem_data.used).values-dustem_used)^2/(*!dustem_data.used).sigma^2 |
445 | - dustemwrap_plot,p_dim,st,dustem_sed,dustem_qsed,dustem_used,dustem_polsed,_extra=_extra | |
446 | - | |
447 | - ;if !dustem_show_plot ne 0 then begin | |
448 | - ;fact = 1.00E-20;(3.e10/(1.e-4*(st.polsed.wav)))/1.d40 | |
449 | - ;fact1 =1.00E-20;(3.e10/(1.e-4*((*!dustem_data.used).wav)))/1.d40 ; for data plotting | |
450 | - | |
451 | - ;win+=1 | |
452 | - ;window ,win ,title='DUSTEM WRAP (USED)' | |
453 | - ;titstu='Stokes U Polarization Intensity' | |
454 | - ;ytitstu=textoidl('U_\nu (W/m^2/Hz/sr) for N_H=10^{20} H/cm^2') | |
455 | - ;xtit=textoidl('\lambda (\mum)') | |
456 | - ;xr=[10,1e6] | |
457 | - ;normpol2=U_spec*fact | |
458 | - ;normpol3=dustem_used*fact1 | |
459 | - ;yr=[min(normpol2)-min(normpol2)/10,max(normpol2)+max(normpol2)*10] | |
460 | - | |
461 | - ;conditions here are on computed spectra and they should be on the data itself. | |
462 | - ;This even impairs the visualization of the data. Correct this!!!!! | |
463 | - | |
464 | - ;yr=[1e-28,1e-17];[1e-34,1e-23] | |
465 | - ;indu=where(U_spec lt 0, countu) | |
466 | - ;indu=where((*!dustem_data.used).values lt 0, countu) | |
467 | - ;ylog=1 | |
468 | - ;if countu ne 0 then begin | |
469 | - ;ylog=0 | |
470 | - ;yr=[-2e-31,5e-31] | |
471 | - ;endif | |
472 | - | |
473 | - ;cgplot,st.polsed.wav,U_spec*fact,xtit='',ytit=ytitstu,tit=titstu,ylog=ylog,/xlog,xr=xr,yr=yr,/ys,/xs,position=[0.17,0.35,0.93,0.93],xtickformat='(A1)',color='black' | |
474 | - ;cgoplot,st.polsed.wav,U_spec*fact,color='black' | |
475 | - ;cgoplot,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1,color='Teal',psym=16,symsize=1,thick=2 | |
476 | - ;err_bar,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1,yrms=3.*((*!dustem_data.used).sigma)/2.*fact1,color=cgColor('Teal') | |
477 | - ;cgoplot,(*!dustem_data.used).wav,dustem_used*fact1,psym=6,color='red',symsize=2 | |
478 | - | |
479 | - | |
480 | - | |
481 | - ;cgplot,st.polsed.wav,U_spec*fact/normpol2,xtit=xtit,ytit='Normalized',tit='',/xlog,xr=xr,/ys,/xs,yr=[0,2],ylog=0,position=[0.17,0.14,0.93,0.35],/noerase,yticks=2,ymino=5,xticklen=0.1 | |
482 | - ;cgoplot,st.polsed.wav,U_spec*fact/normpol2,color='black' | |
483 | - ;cgoplot,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1/normpol3,color='Teal',psym=16,symsize=1,thick=2 | |
484 | - ;err_bar,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1/normpol3,yrms=3.*((*!dustem_data.used).sigma)/2.*fact1/normpol3,color=cgColor('Teal') | |
485 | - ; | |
486 | - ;cgwindow, 'plot', | |
487 | - | |
488 | - ;endif | |
356 | + dustemwrap_plot,p_dim,st,dustem_sed,dustem_qsed,dustem_used,dustem_polsed,dustem_polfrac,_extra=_extra | |
357 | + | |
489 | 358 | END |
490 | -; | |
491 | -; | |
492 | - | |
493 | 359 | |
494 | 360 | 'QEXT': BEGIN ; Q - EXTINCTION CROSS SECTION |
495 | 361 | |
... | ... | @@ -603,41 +469,27 @@ if !fit_rchi2_weight.sed ne 0 then begin |
603 | 469 | total_rchi2 += rchi2_sed |
604 | 470 | endif |
605 | 471 | if !run_pol then begin |
606 | -; if !fit_rchi2_weight.polext ne 0 then begin | |
607 | -; total_n += n_polext | |
608 | -; total_chi2 += chi2_polext | |
609 | -; total_rchi2 += rchi2_polext | |
610 | -; endif | |
611 | -; if !fit_rchi2_weight.polsed ne 0 then begin | |
612 | -; total_n += n_polsed | |
613 | -; total_chi2 += chi2_polsed | |
614 | -; total_rchi2 += rchi2_polsed | |
615 | -; endif | |
616 | -; if !fit_rchi2_weight.polfrac ne 0 then begin | |
617 | -; total_n += n_polfrac | |
618 | -; total_chi2 += chi2_polfrac | |
619 | -; total_rchi2 += rchi2_polfrac | |
620 | -; endif | |
621 | -if !fit_rchi2_weight.qsed ne 0 then begin | |
622 | - total_n += n_qsed | |
623 | - total_chi2 += chi2_qsed | |
624 | - total_rchi2 += rchi2_qsed | |
625 | -endif | |
626 | -if !fit_rchi2_weight.used ne 0 then begin | |
627 | - total_n += n_used | |
628 | - total_chi2 += chi2_used | |
629 | - total_rchi2 += rchi2_used | |
630 | -endif | |
631 | -if !fit_rchi2_weight.qext ne 0 then begin | |
632 | - total_n += n_qext | |
633 | - total_chi2 += chi2_qext | |
634 | - total_rchi2 += rchi2_qext | |
635 | -endif | |
636 | -if !fit_rchi2_weight.uext ne 0 then begin | |
637 | - total_n += n_uext | |
638 | - total_chi2 += chi2_uext | |
639 | - total_rchi2 += rchi2_uext | |
640 | -endif | |
472 | + | |
473 | + if !fit_rchi2_weight.qsed ne 0 then begin | |
474 | + total_n += n_qsed | |
475 | + total_chi2 += chi2_qsed | |
476 | + total_rchi2 += rchi2_qsed | |
477 | + endif | |
478 | + if !fit_rchi2_weight.used ne 0 then begin | |
479 | + total_n += n_used | |
480 | + total_chi2 += chi2_used | |
481 | + total_rchi2 += rchi2_used | |
482 | + endif | |
483 | + if !fit_rchi2_weight.qext ne 0 then begin | |
484 | + total_n += n_qext | |
485 | + total_chi2 += chi2_qext | |
486 | + total_rchi2 += rchi2_qext | |
487 | + endif | |
488 | + if !fit_rchi2_weight.uext ne 0 then begin | |
489 | + total_n += n_uext | |
490 | + total_chi2 += chi2_uext | |
491 | + total_rchi2 += rchi2_uext | |
492 | + endif | |
641 | 493 | |
642 | 494 | endif |
643 | 495 | ... | ... |
src/idl/dustem_plot_fit_sed.pro
... | ... | @@ -74,7 +74,7 @@ fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 |
74 | 74 | use_col_data_filt='blue' |
75 | 75 | |
76 | 76 | ;use_col_sed_spec='red' |
77 | -use_col_sed_spec='grey' | |
77 | +use_col_sed_spec='Powder Blue' | |
78 | 78 | |
79 | 79 | IF not keyword_set(col_sed) THEN BEGIN |
80 | 80 | ;use_col_sed_filt=250 ;red |
... | ... | @@ -150,7 +150,8 @@ if keyword_set(fpol) then begin |
150 | 150 | IF !d.name NE 'PS' THEN cgDisplay, 600, 500 |
151 | 151 | cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,xtit='',ytit=ytit,tit='',/ylog,/xlog,/ys,/xs,position=[0.12,0.25,0.96,0.76],xtickformat='(A1)',_extra=_extra,charsize=1.3,/noerase |
152 | 152 | endif |
153 | -endif ELSE cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,xtit='',ytit=ytit,tit=title,/ylog,/xlog,/ys,/xs,position=[0.12,0.35,0.96,0.90],xtickformat='(A1)',_extra=_extra,charsize=1.3 | |
153 | +endif ELSE cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,ytit=ytit,tit=title,/ylog,/xlog,/ys,/xs,position=[0.12,0.35,0.96,0.90],charsize=1.3,_extra=_extra,xtickformat='(A1)' | |
154 | +;stop | |
154 | 155 | ;############################### |
155 | 156 | |
156 | 157 | ;this is where you will add the normalized sed |
... | ... | @@ -167,7 +168,7 @@ IF count_spec NE 0 THEN BEGIN |
167 | 168 | xx=((*!dustem_data.sed).wav)[ind_spec] |
168 | 169 | yy=((*!dustem_data.sed).values)[ind_spec]/norm[ind_spec] |
169 | 170 | rms=3.*((*!dustem_data.sed).sigma)[ind_spec]/2./norm[ind_spec] |
170 | - cgoplot,xx,yy,psym=8,syms=0.5,color=use_col_sed_spec | |
171 | + cgoplot,xx,yy,psym=8,color=use_col_sed_spec | |
171 | 172 | IF not keyword_set(no_spec_error) THEN BEGIN |
172 | 173 | cgerrplot,xx,yy-rms,yy+rms,color=use_col_sed_spec |
173 | 174 | ;err_bar,((*!dustem_data.sed).wav)(ind_spec),((*!dustem_data.sed).values)(ind_spec)/norm(ind_spec),yrms=3.*((*!dustem_data.sed).sigma)(ind_spec)/2./norm(ind_spec) |
... | ... | @@ -183,7 +184,7 @@ IF count_filt NE 0 THEN BEGIN |
183 | 184 | ;err_bar,((*!dustem_data.sed).wav)(ind_filt),((*!dustem_data.sed).values)(ind_filt)/norm(ind_filt),yrms=3.*((*!dustem_data.sed).sigma)(ind_filt)/2./norm(ind_filt),color=use_col_data_filt |
184 | 185 | cgerrplot,xx,yy-rms,yy+rms,color='Dodger Blue';use_col_data_filt |
185 | 186 | ENDIF |
186 | -;=== Plot the computed SED - color corrected interpolates | |
187 | +;=== Plot the computed SED | |
187 | 188 | IF count_filt NE 0 THEN BEGIN |
188 | 189 | plotsym,8 |
189 | 190 | xx=((*!dustem_data.sed).wav)[ind_filt] |
... | ... | @@ -194,7 +195,7 @@ IF count_spec NE 0 THEN BEGIN |
194 | 195 | plotsym,0 |
195 | 196 | xx=((*!dustem_data.sed).wav)[ind_spec] |
196 | 197 | yy=sed[ind_spec]/norm[ind_spec] |
197 | - cgoplot,xx,yy,color=use_col_sed_filt,psym=6,syms=2 | |
198 | + cgoplot,xx,yy,color='Indian Red',psym=7,syms=1 | |
198 | 199 | ENDIF |
199 | 200 | |
200 | 201 | ... | ... |
src/idl/dustem_read_all_web3p8.pro
... | ... | @@ -50,7 +50,7 @@ file=dir_in_dat+(*!dustem_inputs).grain |
50 | 50 | ;st_grains=dustem_read_grain(file,silent=silent) |
51 | 51 | st_grains=dustem_read_grain(file,silent=silent,key_str=key_str,G0=G0) |
52 | 52 | Ngrains=n_elements(st_grains) |
53 | - | |
53 | + | |
54 | 54 | file=dir_in_dat+'ISRF.DAT' |
55 | 55 | st_isrf=dustem_read_isrf(file,silent=silent,Nisrf=Nisrf) |
56 | 56 | ... | ... |
src/idl/dustem_set_data.pro
... | ... | @@ -63,7 +63,7 @@ for i=0L,n_tags(!dustem_data)-1 do begin |
63 | 63 | endfor |
64 | 64 | |
65 | 65 | xx=dustem_check_data(data_sed=st_sed_fit,data_ext=st_ext_fit,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,psi_em=psi_em,qsed=qsed,used=used,qext=qext,uext=uext,psi_ext=psi_ext) |
66 | - | |
66 | +;stop | |
67 | 67 | ;outputs whatever the input structure has, into organized seperate structures formatted for the fitting process. |
68 | 68 | |
69 | 69 | ;If SED/EXT data is present in the structure it is fitted automatically. |
... | ... | @@ -91,42 +91,63 @@ if !run_pol then begin |
91 | 91 | |
92 | 92 | teststks = isa(qsed) and isa(used) |
93 | 93 | |
94 | - IF (not teststks) then message, 'Stokes parameters are not set correctly. Please check the input structure. Aborting...' | |
94 | + IF ~teststks then message, 'Stokes parameters are not set correctly. Please check the input structure. Aborting...' | |
95 | 95 | |
96 | 96 | ;EMISSION |
97 | - if teststks then nowfitting = 'QSED and USED' | |
98 | 97 | |
99 | - message, 'Polarization component(s) to fit: '+nowfitting ,/continue | |
98 | + message, 'Polarization component(s) to fit: QSED and USED' ,/continue | |
100 | 99 | |
101 | 100 | IF isa(qsed) THEN BEGIN |
102 | 101 | !dustem_data.qsed = ptr_new(qsed) |
103 | 102 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
104 | 103 | (*!dustem_data.qsed).values *= f_HI |
105 | 104 | ENDIF |
105 | + | |
106 | 106 | if isa(used) then BEGIN |
107 | 107 | !dustem_data.used = ptr_new(used) |
108 | 108 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
109 | 109 | (*!dustem_data.used).values *= f_HI |
110 | 110 | ENDIF |
111 | + | |
112 | + if isa(polsed) then BEGIN | |
113 | + | |
114 | + !dustem_data.polsed = ptr_new(polsed) | |
115 | + if keyword_set(f_HI) then if f_HI gt 0 then $ | |
116 | + (*!dustem_data.polsed).values *= f_HI | |
117 | + | |
118 | + ENDIF | |
119 | + | |
120 | + if isa(polfrac) then BEGIN | |
121 | + | |
122 | + !dustem_data.polfrac = ptr_new(polfrac) | |
123 | + if keyword_set(f_HI) then if f_HI gt 0 then $ | |
124 | + (*!dustem_data.polfrac).values *= f_HI | |
125 | + | |
126 | + ENDIF | |
127 | + | |
128 | + | |
129 | + if isa(psi_em) then BEGIN | |
130 | + | |
131 | + !dustem_data.psi_em = ptr_new(psi_em) | |
132 | + if keyword_set(f_HI) then if f_HI gt 0 then $ | |
133 | + (*!dustem_data.psi_em).values *= f_HI | |
134 | + | |
135 | + ENDIF | |
136 | + | |
137 | + | |
111 | 138 | endif |
112 | 139 | |
113 | 140 | if keyword_set(st_ext_fit) then begin |
114 | 141 | ;Two tests that determine what the user will eventually fit |
115 | 142 | |
116 | 143 | testexstks = isa(qext) and isa(uext) |
117 | - testpexstks = (isa(qext) and isa(uext) and isa(polext)) | |
118 | - | |
119 | - IF (not testexstks and not isa(polext)) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' | |
120 | - | |
121 | - IF testpexstks THEN $ | |
122 | - message, 'Presence of both extinction polarization and stokes parameter values. Fitting structure is not correctly filtered. Aborting...' | |
123 | 144 | |
145 | + IF ~testexstks then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' | |
146 | + | |
124 | 147 | ;EXTINCTION - allowed for the default fitting of both because I do not know if the same formalism should be applied to the extinction data because it also implies deviding extinction data into two components. |
125 | - if testexstks then nowfitting = 'QEXT and UEXT' else begin ;Serkowski is default | |
126 | - if isa(polext) then nowfitting = 'POLEXT' | |
127 | - endelse | |
128 | - | |
129 | - message, 'Extinction polarization component(s) to fit: '+nowfitting ,/continue | |
148 | + | |
149 | + message, 'Extinction polarization component(s) to fit: QEXT and UEXT',/continue | |
150 | + | |
130 | 151 | if isa(polext) then BEGIN |
131 | 152 | !dustem_data.polext = ptr_new(polext) |
132 | 153 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
... | ... | @@ -142,6 +163,7 @@ if !run_pol then begin |
142 | 163 | if keyword_set(f_HI) then if f_HI gt 0 then $ |
143 | 164 | (*!dustem_data.uext).values *= f_HI |
144 | 165 | ENDIF |
166 | + | |
145 | 167 | endif |
146 | 168 | endif |
147 | 169 | |
... | ... | @@ -149,8 +171,8 @@ endif |
149 | 171 | if not keyword_set(st_sed_show) then st_sed_show=st_sed_fit |
150 | 172 | |
151 | 173 | ;Setting of the structure that will be displayed |
152 | -yy=dustem_check_data(data_sed=st_sed_show,data_ext=st_ext_show,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,qsed=qsed,used=used,qext=qext,uext=uext) | |
153 | - | |
174 | +yy=dustem_check_data(data_sed=st_sed_show,data_ext=st_ext_show,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,qsed=qsed,used=used,qext=qext,uext=uext,psi_em=psi_em,psi_ext=psi_ext) | |
175 | +;stop | |
154 | 176 | IF isa(sed) THEN !dustem_show.sed = ptr_new(sed) |
155 | 177 | IF isa(ext) THEN !dustem_show.ext = ptr_new(ext) |
156 | 178 | |
... | ... | @@ -173,16 +195,16 @@ if !run_pol then begin |
173 | 195 | |
174 | 196 | teststks = isa(qsed) and isa(used) |
175 | 197 | |
176 | - IF (not teststks and not isa(polsed)) or (not teststks and not isa(polfrac)) then message, 'Stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' | |
198 | + IF (~teststks and ~isa(polsed)) or (~teststks and ~isa(polfrac)) then message, 'Stokes parameters/Polarization showing data is not set correctly. Please check the input structure. Aborting...' | |
177 | 199 | |
178 | - if teststks and isa(polsed) and not (isa(polfrac)) and not(isa(psi_em)) then nowshowing = 'QSED, USED and POLSED' | |
179 | - if teststks and isa(polsed) and not(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED, POLSED and PSI_EM' | |
180 | - if teststks and not(isa(polsed)) and isa(polfrac) and not(isa(psi_em)) then nowshowing = 'QSED, USED and POLFRAC' | |
181 | - if teststks and not(isa(polsed)) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC and PSI_EM' | |
182 | - if teststks and not(isa(polsed)) and not(isa(polfrac)) and not(isa(psi_em)) then nowshowing = 'QSED and USED' | |
183 | - if teststks and isa(polsed) and isa(polfrac) and not(isa(psi_em)) then nowshowing = 'QSED, USED, POLSED and POLFRAC' | |
200 | + if teststks and isa(polsed) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLSED' | |
201 | + if teststks and isa(polsed) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED, POLSED and PSI_EM' | |
202 | + if teststks and ~(isa(polsed)) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLFRAC' | |
203 | + if teststks and ~(isa(polsed)) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC and PSI_EM' | |
204 | + if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED and USED' | |
205 | + if teststks and isa(polsed) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED, POLSED and POLFRAC' | |
184 | 206 | if teststks and isa(polsed) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC, POLSED and PSI_EM' |
185 | - if teststks and not(isa(polsed)) and not(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM' | |
207 | + if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM' | |
186 | 208 | |
187 | 209 | |
188 | 210 | message, 'Polarization component(s) to show: '+nowshowing ,/continue |
... | ... | @@ -217,12 +239,12 @@ if !run_pol then begin |
217 | 239 | if isa(st_ext_show) then begin |
218 | 240 | teststks = isa(qext) and isa(uext) |
219 | 241 | |
220 | - IF (not teststks and not isa(polext)) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' | |
242 | + IF (~teststks) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...' | |
221 | 243 | |
222 | - if teststks and isa(polext) and not(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXT' | |
244 | + if teststks and isa(polext) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXT' | |
223 | 245 | if teststks and isa(polext) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXT and PSI_EXT' |
224 | - if teststks and not(isa(polext)) and isa(psi_ext) then nowshowing = 'QEXT,UEXT and PSI_EXT' | |
225 | - if teststks and not(isa(polext)) and not(isa(psi_ext)) then nowshowing = 'QEXT and UEXT' | |
246 | + if teststks and ~(isa(polext)) and isa(psi_ext) then nowshowing = 'QEXT,UEXT and PSI_EXT' | |
247 | + if teststks and ~(isa(polext)) and ~(isa(psi_ext)) then nowshowing = 'QEXT and UEXT' | |
226 | 248 | |
227 | 249 | message, 'Polarization component(s) to show: '+nowshowing ,/continue |
228 | 250 | |
... | ... | @@ -255,12 +277,10 @@ IF keyword_set(rchi2_weight) THEN BEGIN |
255 | 277 | !fit_rchi2_weight.ext = rchi2_weight.ext |
256 | 278 | |
257 | 279 | IF !run_pol THEN BEGIN |
258 | - ;IF isa(polsed) THEN !fit_rchi2_weight.polsed = rchi2_weight.polsed | |
259 | - ;IF isa(polfrac) THEN !fit_rchi2_weight.polfrac = rchi2_weight.polfrac | |
280 | + | |
260 | 281 | IF isa(qsed) THEN !fit_rchi2_weight.qsed = rchi2_weight.qsed |
261 | 282 | IF isa(used) THEN !fit_rchi2_weight.used = rchi2_weight.used |
262 | 283 | |
263 | - IF isa(polext) THEN !fit_rchi2_weight.polext = rchi2_weight.polext | |
264 | 284 | IF isa(qext) THEN !fit_rchi2_weight.qext = rchi2_weight.qext |
265 | 285 | IF isa(uext) THEN !fit_rchi2_weight.uext = rchi2_weight.uext |
266 | 286 | ENDIF |
... | ... | @@ -271,13 +291,13 @@ ENDIF ELSE BEGIN |
271 | 291 | !fit_rchi2_weight.ext=1. |
272 | 292 | |
273 | 293 | If !run_pol THEN BEGIN |
274 | - ;IF isa(polsed) THEN !fit_rchi2_weight.polsed=1. | |
275 | - ;IF isa(polfrac) THEN !fit_rchi2_weight.polfrac=1. | |
294 | + | |
276 | 295 | IF isa(qsed) THEN !fit_rchi2_weight.qsed=1. |
277 | 296 | IF isa(used) THEN !fit_rchi2_weight.used=1. |
278 | - IF isa(polext) THEN !fit_rchi2_weight.polext=1. | |
297 | + | |
279 | 298 | IF isa(qext) THEN !fit_rchi2_weight.qext=1. |
280 | 299 | IF isa(uext) THEN !fit_rchi2_weight.uext=1. |
300 | + | |
281 | 301 | ENDIF |
282 | 302 | |
283 | 303 | ENDELSE | ... | ... |
src/idl/dustemcgwin_dataset.pro
... | ... | @@ -44,10 +44,14 @@ if !run_pol then begin |
44 | 44 | |
45 | 45 | specpol = st.polsed.em_tot * fact |
46 | 46 | |
47 | +; stop | |
47 | 48 | ;Instead of matching the non-zero values in spec and specpol (dustem outputs), |
48 | 49 | ;I will only test on specpol as spec does not contain any null values FOR NOW. |
49 | 50 | ;If this happens to change, these lines will have to be adjusted. |
50 | 51 | |
52 | + ;CHECKING IF THIS IS CORRECT FOR EACH OF THE SPECIES SPECTRA = ? | |
53 | + | |
54 | + | |
51 | 55 | specpolfrac = specpol *0. |
52 | 56 | psi_em = specpol*0. |
53 | 57 | indpolsed = where(specpol ne 0, ct_nullpolsed) ;I am not using the counter for now as it serves me no direct purpose. |
... | ... | @@ -72,8 +76,12 @@ IF scopes[0] NE 'NONE' THEN BEGIN |
72 | 76 | |
73 | 77 | specq = (*(*!dustem_plugin).(i))[*,1] |
74 | 78 | specu = (*(*!dustem_plugin).(i))[*,2] |
75 | - ;specpol = sqrt(1.0E10*specq^2+1.0E10*specu^2) ;sqrt(((*(*!dustem_plugin).(i))[*,1])^2+(*(*!dustem_plugin).(i))[*,2]^2) | |
79 | + | |
80 | + ;STILL LACKING A WORKAROUND. | |
76 | 81 | specpol = (specq*1.0E10)^2+(specu*1.0E10)^2 & specpol=1.0E-10*sqrt(specpol) ;for some reason cgwindow couldn't handle these mathematical operations. It seems this is caused by values that are too close to zero |
82 | + | |
83 | + ;specpol = (specq^2 + specu^2) & specpol = sqrt(specpol) | |
84 | + | |
77 | 85 | specpolfrac[indpolsed] = specpol[indpolsed]/spec[indpolsed] |
78 | 86 | psi_em[indpolsed] = 0.5*atan(specu[indpolsed],specq[indpolsed])/degtorad |
79 | 87 | ;stop |
... | ... | @@ -293,7 +301,9 @@ if keyword_set(dataset) then begin |
293 | 301 | |
294 | 302 | end |
295 | 303 | |
296 | - 'POLSED': begin | |
304 | + 'POLSED': begin ;#NB: There seems to be an issue with the display of the dust species. 'Carbonaceous grains' 's emission exceeds the total emission. | |
305 | + ;MABE AN ISSUE WITH HOW 'SPECPOL' refreshes? | |
306 | + ;PROCEEDING TO POLFRAC | |
297 | 307 | |
298 | 308 | idx_filt=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',ct_filt) |
299 | 309 | idx_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',ct_spec) |
... | ... | @@ -426,7 +436,7 @@ if keyword_set(dataset) then begin |
426 | 436 | ;Locating all the hidden data points (spectrum+filter) |
427 | 437 | match2,((*!dustem_data.polsed).wav),((*!dustem_show.polsed).wav),fit_polsedpts,show_polsedpts ;only show_polsedpts is needed |
428 | 438 | idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide |
429 | - | |
439 | + ;stop | |
430 | 440 | if ct_hdnpts ne 0 then begin ;Hidden data points are present |
431 | 441 | ;stop |
432 | 442 | ;Locating the hidden spectrum and filter data points |
... | ... | @@ -442,7 +452,7 @@ if keyword_set(dataset) then begin |
442 | 452 | cgerrplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black' |
443 | 453 | endif |
444 | 454 | |
445 | - if ct_filt_hdn then begin | |
455 | + if ct_filt_hdn ne 0 then begin | |
446 | 456 | ;Plotting of hidden filter data points |
447 | 457 | cgplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8 |
448 | 458 | |
... | ... | @@ -466,7 +476,161 @@ if keyword_set(dataset) then begin |
466 | 476 | |
467 | 477 | end |
468 | 478 | |
469 | - 'POLFRAC': begin | |
479 | + 'POLFRAC': begin ; YOU NEED TO CODE THIS PART - TOU STILL HAVE'NT FINISHED. | |
480 | + idx_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',ct_filt) | |
481 | + idx_spec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',ct_spec) | |
482 | + | |
483 | + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready | |
484 | + | |
485 | + if keyword_set(nodata) then begin ;when the data is not present | |
486 | + | |
487 | + xtit = '' | |
488 | + cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[1.00E-03,50.00],/ylog,psym=8,syms=0.8 | |
489 | + xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.1 | |
490 | + | |
491 | + endif else begin ;when the data is present ; normal plot | |
492 | + | |
493 | + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed | |
494 | + | |
495 | + ;##################TAKEN FROM SED | |
496 | + | |
497 | + ;Plotting of the spectra of the dust species | |
498 | + | |
499 | + ;I THINK I WILL HAVE AN ERROR HERE BECAUSE I WILL HAVE TO DIVIDE TWO ARRAYS FOR EACH DUST SPECIES. | |
500 | + ; (st.polsed.(i+1)/st.sed.(i+1))*fact | |
501 | + ;There is an issue with the fact that there are grain species that are not polarized | |
502 | + ;test and set a counter? YES FOR NOW | |
503 | + ; | |
504 | + | |
505 | + FOR i=0L,Ngrains-1 DO BEGIN | |
506 | + | |
507 | + testneq = where(st.polsed.(i+1) ne 0, countneq) | |
508 | + | |
509 | + vecfin = st.polsed.(i+1)*0.0 | |
510 | + ;SET the condition later | |
511 | + if countneq ne 0 then vecfin[testneq] = (st.polsed.(i+1))[testneq]/(st.sed.(i+1))[testneq] | |
512 | + | |
513 | + cgoplot,st.polsed.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=[1.00E-03,50.00] | |
514 | + | |
515 | + ENDFOR | |
516 | + | |
517 | + ;Plotting of the plugins. | |
518 | + | |
519 | + ;NB: YOU HAVE YET TO TEST THIS BLOCK. DON'T FORGET TO ADD A POLARIZATION FRACTION TO FF for instance. | |
520 | + ; The thing is you've already had errors of that kind. | |
521 | + | |
522 | + ;PLUGINS SEEM TO HAVE ZERO NULL VALUES. THIS IS GOOD NEWS. LESS TESTING. | |
523 | + ;BUT if you get errors you know it has to be the division of the two arrays. | |
524 | + ;THE CHANGES SEEM LIKE THEY'RE GONNA WORK. | |
525 | + | |
526 | + | |
527 | + ;MISSING KEYWORDS? | |
528 | + for i=0L,n_plgns-1 do begin | |
529 | + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin | |
530 | + | |
531 | + cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)/((*(*!dustem_plugin).(i))[*,0])*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2 | |
532 | + | |
533 | + ENDIF | |
534 | + endfor | |
535 | + | |
536 | + | |
537 | + ;PLotting of the interpolates corresponding to spectrum and filter points | |
538 | + | |
539 | + IF ct_spec NE 0 THEN BEGIN | |
540 | + | |
541 | + xx=((*!dustem_data.polfrac).wav)[idx_spec] | |
542 | + yy=prediction[idx_spec] | |
543 | + cgoplot,xx,yy*100,color='red',pos=position,psym=7,syms=2,noerase=1 | |
544 | + ENDIF | |
545 | + | |
546 | + | |
547 | + IF ct_filt NE 0 THEN BEGIN | |
548 | + xx=((*!dustem_data.polfrac).wav)[idx_filt] | |
549 | + yy=prediction[idx_filt] | |
550 | + cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1 | |
551 | + ENDIF | |
552 | + | |
553 | + | |
554 | + ;Plotting of the total dust emission spectrum | |
555 | + cgoplot,st.polsed.wav,specpolfrac*100,pos=position,noerase=1,/xlog,/ys,/xs | |
556 | + | |
557 | + | |
558 | + endif else begin ;The data points in the plot that remain unchanged. | |
559 | + | |
560 | + | |
561 | + ;Plotting of frequency axis | |
562 | + ;cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),charsize=1.15,title=textoidl('\nu (GHz)') | |
563 | + | |
564 | + | |
565 | + ;Spectrum points are treated before for plotting reasons. | |
566 | + if ct_spec ne 0 then begin | |
567 | + | |
568 | + ;Plotting of spectrum data points (to be fitted) | |
569 | + cgplot,((*!dustem_data.polfrac).wav)(idx_spec),((*!dustem_data.polfrac).values)(idx_spec)*100,/xlog,/ylog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[1.00E-03,50.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp' | |
570 | + | |
571 | + ;Plotting of the spectrum error points | |
572 | + rms=3.*((*!dustem_data.polfrac).sigma)(idx_spec)/2. | |
573 | + cgerrplot,((*!dustem_data.polfrac).wav)(idx_spec),(((*!dustem_data.polfrac).values)(idx_spec)-rms)*100,(((*!dustem_data.polfrac).values)(idx_spec)+rms)*100,color='Powder Blue' | |
574 | + | |
575 | + endif | |
576 | + | |
577 | + if ct_filt ne 0 then begin | |
578 | + | |
579 | + ;Plotting of filter data points (to be fitted) + testing for prior plotting | |
580 | + if ct_spec ne 0 then cgoplot,((*!dustem_data.polfrac).wav)(idx_filt),((*!dustem_data.polfrac).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[1.00E-03,50.00],/xlog,/ylog else $;,ytickformat='dstmwrp_exp' | |
581 | + cgplot,((*!dustem_data.polfrac).wav)(idx_filt),((*!dustem_data.polfrac).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[1.00E-03,50.00],/xlog,/ylog;,ytickformat='dstmwrp_exp' | |
582 | + | |
583 | + | |
584 | + ;Plotting of the filter error points | |
585 | + rms=3.*((*!dustem_data.polfrac).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt) | |
586 | + cgerrplot,((*!dustem_data.polfrac).wav)(idx_filt),(((*!dustem_data.polfrac).values)(idx_filt)-rms)*100,(((*!dustem_data.polfrac).values)(idx_filt)+rms)*100,color='Dodger Blue' | |
587 | + | |
588 | + endif | |
589 | + | |
590 | + | |
591 | + | |
592 | + xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.1 | |
593 | + | |
594 | + ;Locating all the hidden data points (spectrum+filter) | |
595 | + | |
596 | + ;The filtering has been done prior (in the primary routine) | |
597 | + match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),fit_polfracpts,show_polfracpts ;only show_polfracpts is needed | |
598 | + idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide | |
599 | + ;stop | |
600 | + if ct_hdnpts ne 0 then begin ;Hidden data points are present | |
601 | + ;stop | |
602 | + | |
603 | + ;Locating the hidden spectrum and filter data points | |
604 | + idx_filt_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn) | |
605 | + idx_spec_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn) | |
606 | + | |
607 | + if ct_spec_hdn ne 0 then begin | |
608 | + ;Plotting of hidden spectrum data points | |
609 | + cgplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),(((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[1.00E-03,50.00],psym=8,syms=0.8 | |
610 | + | |
611 | + ;Plotting of hidden spectrum error points | |
612 | + rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2. | |
613 | + cgerrplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black' | |
614 | + endif | |
615 | + | |
616 | + if ct_filt_hdn ne 0 then begin | |
617 | + ;stop | |
618 | + plotsym,0, /fill | |
619 | + ;Plotting of hidden filter data points | |
620 | + cgplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),(((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[1.00E-03,50.00],psym=8,syms=0.8 | |
621 | + ;stop | |
622 | + ;Plotting of hidden filter error point | |
623 | + rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2. | |
624 | + cgerrplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black' | |
625 | + | |
626 | + endif | |
627 | + | |
628 | + endif | |
629 | + | |
630 | + | |
631 | + endelse | |
632 | + | |
633 | + endelse | |
470 | 634 | |
471 | 635 | end |
472 | 636 | |
... | ... | @@ -694,8 +858,8 @@ if keyword_set(dataset) then begin |
694 | 858 | endif else begin ;The data points in the plot that remain unchanged |
695 | 859 | ;stop |
696 | 860 | xtit=textoidl('\lambda (\mum)') |
697 | - if !run_pol then xtit = '' | |
698 | - cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 | |
861 | + ;if !run_pol then xtit = '' | |
862 | + cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 | |
699 | 863 | xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1 |
700 | 864 | |
701 | 865 | endelse |
... | ... | @@ -1053,8 +1217,8 @@ if keyword_set(dataset) then begin |
1053 | 1217 | endif else begin ;The data points in the plot that remain unchanged |
1054 | 1218 | ;stop |
1055 | 1219 | xtit=textoidl('\lambda (\mum)') |
1056 | - if !run_pol then xtit = '' | |
1057 | - cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 | |
1220 | + ;if !run_pol then xtit = '' | |
1221 | + cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 | |
1058 | 1222 | xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1 |
1059 | 1223 | |
1060 | 1224 | endelse | ... | ... |
src/idl_misc/JPBLib_for_Dustemwrap/General/modify_extra.pro