Commit 9aceb88844f5403877322db41889737c93f5f69c

Authored by Ilyes Choubani
1 parent d90f1b78
Exists in master

Updating the non-OOP plotting routine.

src/idl/dustemwrap_plot.pro
@@ -438,7 +438,7 @@ if test_m then begin @@ -438,7 +438,7 @@ if test_m then begin
438 438
439 ;This block needs to be replicated inside the dustem_plot_dataset routine 439 ;This block needs to be replicated inside the dustem_plot_dataset routine
440 440
441 - if !run_pol and tag_exist(*!dustem_show,'qsed') then begin 441 + if !run_pol then begin
442 442
443 ;position arrays for plot and normalized graph 443 ;position arrays for plot and normalized graph
444 444
src/idl/dustemwrap_plot_noobj.pro
1 -PRO dustemwrap_plot_noobj,p_dim,st, $  
2 - dustem_sed,SED_spec, $  
3 - dustem_qsed,Q_spec, $  
4 - dustem_used,U_spec, $  
5 - dustem_polsed,P_spec, $  
6 - dustem_polfrac,SP_spec, $  
7 - dustem_psi_em,PSI_spec, $  
8 - dustem_ext,EXT_spec, $  
9 - dustem_qext,QEXT_spec, $  
10 - dustem_uext,UEXT_spec, $  
11 - dustem_polext,POLEXT_spec, $  
12 - dustem_fpolext,SPEXT_spec, $  
13 - dustem_psi_ext,PSIEXT_spec, $  
14 - _extra=_extra,help=help 1 +PRO dustemwrap_plot_noobj, p_dim, $
  2 + st = st, $
  3 + dustem_sed = dustem_sed, $
  4 + SED_spec = SED_spec, $
  5 + dustem_qsed = dustem_qsed, $
  6 + Q_spec = Q_spec, $
  7 + dustem_used = dustem_used, $
  8 + U_spec = U_spec, $
  9 + dustem_polsed = dustem_polsed, $
  10 + P_spec = P_spec, $
  11 + dustem_polfrac = dustem_polfrac, $
  12 + SP_spec = SP_spec, $
  13 + dustem_psi_em = dustem_psi_em, $
  14 + PSI_spec = PSI_spec, $
  15 + dustem_ext = dustem_ext, $
  16 + EXT_spec = EXT_spec, $
  17 + dustem_qext = dustem_qext, $
  18 + QEXT_spec = QEXT_spec, $
  19 + dustem_uext = dustem_uext, $
  20 + UEXT_spec = UEXT_spec, $
  21 + dustem_polext = dustem_polext, $
  22 + POLEXT_spec = POLEXT_spec, $
  23 + dustem_fpolext = dustem_fpolext, $
  24 + SPEXT_spec = SPEXT_spec, $
  25 + dustem_psi_ext = dustem_psi_ext, $
  26 + PSIEXT_spec = PSIEXT_spec, $
  27 + _extra = _extra, $
  28 + help = help
15 29
16 ;+ 30 ;+
17 ; NAME: 31 ; NAME:
@@ -102,7 +116,7 @@ if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin ;better t @@ -102,7 +116,7 @@ if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin ;better t
102 116
103 dustem_sed = dustem_compute_sed(p_dim,st=st,SED_spec=SED_spec) 117 dustem_sed = dustem_compute_sed(p_dim,st=st,SED_spec=SED_spec)
104 118
105 - if !run_pol && !run_lin then begin 119 + if !run_pol && !run_lin and tag_exist(*!dustem_show,'qsed') then begin
106 dustem_polsed = dustem_compute_polsed(p_dim,st=st,P_spec=P_spec,SP_spec=SP_spec,dustem_polfrac=dustem_polfrac) 120 dustem_polsed = dustem_compute_polsed(p_dim,st=st,P_spec=P_spec,SP_spec=SP_spec,dustem_polfrac=dustem_polfrac)
107 toto = dustem_compute_stokes(p_dim,st=st,Q_spec=Q_spec,U_spec=U_spec,PSI_spec=PSI_spec,dustem_psi_em=dustem_psi_em) 121 toto = dustem_compute_stokes(p_dim,st=st,Q_spec=Q_spec,U_spec=U_spec,PSI_spec=PSI_spec,dustem_psi_em=dustem_psi_em)
108 dustem_qsed = toto[0] 122 dustem_qsed = toto[0]
@@ -115,7 +129,7 @@ endif @@ -115,7 +129,7 @@ endif
115 if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin 129 if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin
116 dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec) 130 dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec)
117 131
118 - if !run_pol && !run_lin then begin 132 + if !run_pol && !run_lin and tag_exist(*!dustem_show,'qext') then begin
119 133
120 dustem_polext = dustem_compute_polext(p_dim,st=st,polext_spec=POLEXT_spec,spext_spec=SPEXT_spec,dustem_fpolext=dustem_fpolext) 134 dustem_polext = dustem_compute_polext(p_dim,st=st,polext_spec=POLEXT_spec,spext_spec=SPEXT_spec,dustem_fpolext=dustem_fpolext)
121 135
@@ -154,23 +168,40 @@ new_mouchard.rchi2=(*!dustem_fit).rchi2 @@ -154,23 +168,40 @@ new_mouchard.rchi2=(*!dustem_fit).rchi2
154 mouchard=[mouchard,new_mouchard] 168 mouchard=[mouchard,new_mouchard]
155 !iteration_mouchard=ptr_new(mouchard) 169 !iteration_mouchard=ptr_new(mouchard)
156 170
157 -;LIST OF TESTS THAT NEED TO BE RAN SO THAT THE PLOTTING OF THE MODEL SPECTRA OCCURS 171 +;===========Initializing tests
  172 +test_sed = isa((*!dustem_data).sed)
  173 +test_ext = isa((*!dustem_data).ext)
158 174
159 -test_sed = isa((*!dustem_show).sed)  
160 -test_ext = isa((*!dustem_show).ext) 175 +;===========Bunch of tests that are not important now but that
  176 +;might be in future releases. To adjust the layout of the dashboard for instance
161 if !run_pol then begin 177 if !run_pol then begin
162 - test_polext = isa((*!dustem_show).polext)  
163 - test_polsed = isa((*!dustem_show).polsed)  
164 - test_polfrac = isa((*!dustem_show).polfrac)  
165 - test_fpolext = isa((*!dustem_show).fpolext)  
166 - test_psi_em = isa((*!dustem_show).psi_em)  
167 - test_psi_ext = isa((*!dustem_show).psi_ext)  
168 - test_qsed = isa((*!dustem_show).qsed)  
169 - test_used = isa((*!dustem_show).used)  
170 - test_qext = isa((*!dustem_show).qext)  
171 - test_uext = isa((*!dustem_show).uext)  
172 - test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em  
173 - test_x = test_ext or test_polext or test_fpolext or test_qext or test_uext or test_psi_ext 178 + if tag_exist(*!dustem_show,'qsed') then begin ;testing to account for the fact that the user can activate the !run_pol keyword without knowing
  179 + ;ie: using a dust model with polarization w/o polarization data present...
  180 + test_polsed = isa((*!dustem_show).polsed)
  181 + test_polfrac = isa((*!dustem_show).polfrac)
  182 + test_qsed = isa((*!dustem_show).qsed)
  183 + test_used = isa((*!dustem_show).used)
  184 + test_psi_em = isa((*!dustem_show).psi_em)
  185 + endif
  186 +
  187 + if tag_exist(*!dustem_show,'qext') then begin
  188 + test_polext = isa((*!dustem_show).polext)
  189 + test_psi_ext = isa((*!dustem_show).psi_ext)
  190 + test_fpolext = isa((*!dustem_show).fpolext)
  191 + test_qext = isa((*!dustem_show).qext)
  192 + test_uext = isa((*!dustem_show).uext)
  193 + endif
  194 +
  195 + if tag_exist(*!dustem_show,'qsed') then test_m = test_sed or test_polsed $
  196 + or test_polfrac or test_qsed $
  197 + or test_used or test_psi_em
  198 + if tag_exist(*!dustem_show,'qext') then test_x = test_ext or test_polext $
  199 + or test_fpolext or test_qext $
  200 + or test_uext or test_psi_ext
  201 +
  202 + if ~tag_exist(*!dustem_show,'qsed') then test_m = test_sed
  203 + if ~tag_exist(*!dustem_show,'qext') then test_x = test_ext
  204 +
174 endif else begin 205 endif else begin
175 test_m = test_sed 206 test_m = test_sed
176 test_x = test_ext 207 test_x = test_ext
@@ -185,31 +216,35 @@ frmt1='(1E10.2)' @@ -185,31 +216,35 @@ frmt1='(1E10.2)'
185 frmt2='(10F10.2)' 216 frmt2='(10F10.2)'
186 217
187 ;Instead of setting the extra tags for plotting in dustemcgwin, we'll place them in this (parent) procedure. 218 ;Instead of setting the extra tags for plotting in dustemcgwin, we'll place them in this (parent) procedure.
188 -tgnms_extra = tag_names(_extra) 219 +;tgnms_extra = tag_names(_extra)
189 220
190 dustem_set_plot_range,test_sed, test_ext,_extra= _extra 221 dustem_set_plot_range,test_sed, test_ext,_extra= _extra
191 222
  223 +;change starts form here!!!!
  224 +
  225 +
  226 +;===========Retrieving some data relevant to the plotting
192 if isa((*!dustem_fit).current_param_errors) then begin 227 if isa((*!dustem_fit).current_param_errors) then begin
193 - errors = (*(*!dustem_fit).current_param_errors) 228 + errors = (*(*!dustem_fit).current_param_errors) ;* (*(*!dustem_fit).param_init_values) ;multiplied internally in dustem_mpfit. Should maybe be changed.
194 endif else begin 229 endif else begin
195 - errors = (*(*!dustem_fit).param_init_values)*0. 230 + errors = (*(*!dustem_fit).param_init_values)*0.;+la_undef();Initialized to 0 instead of la_undef()
196 ENDELSE 231 ENDELSE
197 232
198 if isa((*!dustem_fit).chi2) then begin 233 if isa((*!dustem_fit).chi2) then begin
199 chi2 = (*!dustem_fit).chi2 234 chi2 = (*!dustem_fit).chi2
200 endif else begin 235 endif else begin
201 - chi2 = la_undef() 236 + chi2 = la_undef();maybe not the best initialization
202 endelse 237 endelse
203 238
204 if isa((*!dustem_fit).rchi2) then begin 239 if isa((*!dustem_fit).rchi2) then begin
205 rchi2 = (*!dustem_fit).rchi2 240 rchi2 = (*!dustem_fit).rchi2
206 endif else begin 241 endif else begin
207 - rchi2 = la_undef() 242 + rchi2 = la_undef();maybe not the best initialization
208 endelse 243 endelse
209 244
210 245
211 -;==== These are arameters for window positioning  
212 -if !run_pol then BEGIN 246 +;===========Window positionning parameters
  247 +if !run_pol and tag_exist(*!dustem_show,'qsed') then BEGIN
213 wdelta_x=60 248 wdelta_x=60
214 main_wxsize=910 249 main_wxsize=910
215 main_wysize=658 250 main_wysize=658
@@ -248,12 +283,8 @@ TVLCT, 255, 255, 255, 254 ; White color @@ -248,12 +283,8 @@ TVLCT, 255, 255, 255, 254 ; White color
248 if test_m then begin 283 if test_m then begin
249 ;Generating emission window and saving window ID 284 ;Generating emission window and saving window ID
250 285
251 - IF !d.name NE 'PS' THEN BEGIN  
252 - IF !run_pol THEN BEGIN  
253 - window,0, xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)',xpos=0,ypos=0  
254 - ENDIF else BEGIN  
255 - window,0,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)',xpos=0, ypos=0;, wback='grey';,wobject=winobj_m  
256 - ENDELSE 286 + IF !d.name NE 'PS' THEN BEGIN ;What if we're trying to create a ps file with the exact display of the dashboard?
  287 + window,0, xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)',xpos=0,ypos=0
257 ENDIF 288 ENDIF
258 289
259 ;Plotting model string (legend) 290 ;Plotting model string (legend)
@@ -286,7 +317,7 @@ if test_m then begin @@ -286,7 +317,7 @@ if test_m then begin
286 ;Displaying fixed part 317 ;Displaying fixed part
287 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1 318 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
288 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35 319 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35
289 - ;Displaying refreshed part (first run . This is the command that will be replaced) 320 + ;Displaying refreshed part
290 cgtext, xxpos + widthtext*1.35 + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0 321 cgtext, xxpos + widthtext*1.35 + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0
291 322
292 ;plotting of (mostly) fixed data for rchi2 323 ;plotting of (mostly) fixed data for rchi2
@@ -302,7 +333,7 @@ if test_m then begin @@ -302,7 +333,7 @@ if test_m then begin
302 ;Getting the width of the refresh.ed string 333 ;Getting the width of the refresh.ed string
303 cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth 334 cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth
304 widthtot+= thiswidth;varying width 335 widthtot+= thiswidth;varying width
305 - ;saving the command string width to replace it 336 +
306 337
307 xxpos = 1.0 - widthtot - 0.03 338 xxpos = 1.0 - widthtot - 0.03
308 339
@@ -310,7 +341,7 @@ if test_m then begin @@ -310,7 +341,7 @@ if test_m then begin
310 341
311 ;Displaying fixed part 342 ;Displaying fixed part
312 cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0 343 cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0
313 - ;Displaying refreshed part (first run . This is the command that will be replaced) 344 +
314 345
315 cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0 346 cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0
316 347
@@ -334,10 +365,10 @@ if test_m then begin @@ -334,10 +365,10 @@ if test_m then begin
334 365
335 ;Displaying fixed part 366 ;Displaying fixed part
336 cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35 367 cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35
337 - ;Displaying refreshed part (first run . This is the command that will be replaced)  
338 - cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0  
339 - ;saving the command id to replace it  
340 368
  369 +
  370 + cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0
  371 +
341 ;Plotting of the title of the dashboard (plot(s)) 372 ;Plotting of the title of the dashboard (plot(s))
342 373
343 374
@@ -359,7 +390,7 @@ if test_m then begin @@ -359,7 +390,7 @@ if test_m then begin
359 if !dustem_end EQ 1 then cgtext, xxpos , yypos,tit+' (FINAL RUN)',color=0,/normal,charsize = 1.6,alignment=0.5 390 if !dustem_end EQ 1 then cgtext, xxpos , yypos,tit+' (FINAL RUN)',color=0,/normal,charsize = 1.6,alignment=0.5
360 391
361 392
362 - if !run_pol then begin 393 + if !run_pol and tag_exist(*!dustem_show,'qsed') then begin
363 ;,wback='grey' 394 ;,wback='grey'
364 395
365 ;position arrays for plot and normalized graph 396 ;position arrays for plot and normalized graph
@@ -398,119 +429,41 @@ if test_m then begin @@ -398,119 +429,41 @@ if test_m then begin
398 429
399 endelse 430 endelse
400 431
401 - ;Plotting of sed data axes (whether or not data is present)  
402 - plotsym,0,/fill ;you might need to execute this again. hmm...  
403 -;stop  
404 -  
405 - ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters  
406 - if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1  
407 -  
408 - dustem_plot_dataset, st, dataset='SED', /nodata, position=p_sed, _extra=_extra  
409 - dustem_plot_dataset, st, dataset='SED', /nodata, /norm, position=np_sed, _extra=_extra  
410 -  
411 - endif else begin ;SED exists  
412 - ;this plots the observed SED  
413 - dustem_plot_dataset, st, dataset='SED', position=p_sed, _extra=_extra  
414 - ;this plots the predicted spectrum and predicted SED  
415 - dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, _extra=_extra  
416 - ;This plots an empty normalized plot  
417 - dustem_plot_dataset, st, dataset='SED',/norm, position=np_sed, _extra=_extra ;I think nodata can also be used too  
418 - ;This plots the normalized observed SED - best fit  
419 - dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, _extra=_extra  
420 - endelse 432 + plotsym,0,/fill
421 433
422 -  
423 - if !run_pol then begin ;then goto, end_m 434 + ;block for the collective plotting of the datasets - copied as is
  435 + if !run_pol and tag_exist(*!dustem_show,'qsed') then begin
  436 + ;This part can be adjusted for future releases if the user wants to plot
  437 + ;specific datasets
424 438
425 - if ~test_qsed then begin ;Qsed is not present  
426 -  
427 - dustem_plot_dataset, st, dataset='QSED', /nodata, position=p_qsed, _extra=_extra  
428 - dustem_plot_dataset, st, dataset='QSED', /nodata, /norm, position=np_qsed, _extra=_extra 439 + ;lists because elements have different dimensions and/or we want entire arrays as elements
  440 + dustem_interp = list(dustem_sed,dustem_polfrac,dustem_qsed,dustem_used,dustem_psi_em,dustem_polsed) ;DustEmWrap SED predictions
  441 + dustem_spec = list(SED_spec,SP_spec,Q_spec,U_spec,PSI_spec,P_spec) ;DustEM spectra predictions
  442 + extra_spec = list(0,SED_spec,0,0,0,0) ;extra spectra that the dataset needs in order to be plotted.
  443 + ;This (extra_spec use) actually should not be generalized since the only case we need an extra spectrum is when plotting the polarization fraction.
  444 + position = list(list(p_sed,np_sed),list(p_spsed),list(p_qsed,np_qsed),list(p_used,np_used),list(p_psised),list(p_psed,np_psed))
429 445
430 - endif else begin ;Qsed data is present  
431 -  
432 - ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)  
433 - dustem_plot_dataset, st, dataset='QSED', position=p_qsed,/positive_only, _extra=_extra  
434 - ;Refreshing the positive_only plot ONLY if there is data. If not do nothing  
435 - dustem_plot_dataset, st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, _extra=_extra  
436 -  
437 -  
438 - dustem_plot_dataset, st, dataset='QSED', position=p_qsed, /addcmd,/negative_only, _extra=_extra  
439 - ;Refreshing the negative_only plot ONLY if there is data. If not do nothing  
440 - dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, _extra=_extra  
441 -  
442 -  
443 - dustem_plot_dataset, st, dataset='QSED',/norm, position=np_qsed, _extra=_extra ;I think nodata can also be uqsed too  
444 - dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, _extra=_extra  
445 -  
446 - endelse  
447 -  
448 -  
449 -  
450 - if ~test_used then begin ;used is not present  
451 -  
452 - dustem_plot_dataset, st, dataset='USED', /nodata, position=p_used, _extra=_extra  
453 - dustem_plot_dataset, st, dataset='USED', /nodata, /norm, position=np_used, _extra=_extra  
454 -  
455 - endif else begin ;used data is present  
456 -  
457 - ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)  
458 - dustem_plot_dataset, st, dataset='USED', position=p_used,/positive_only, _extra=_extra  
459 - ;Refreshing the positive_only plot ONLY if there is data. If not do nothing  
460 - dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, _extra=_extra  
461 -  
462 - dustem_plot_dataset, st, dataset='USED', position=p_used, winid=winid_m,/negative_only, _extra=_extra  
463 - ;Refreshing the negative_only plot ONLY if there is data. If not do nothing  
464 - dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, _extra=_extra  
465 -  
466 - dustem_plot_dataset, st, dataset='USED',/norm, position=np_used, _extra=_extra ;I think nodata can also be uused too  
467 - dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, _extra=_extra  
468 -  
469 - endelse  
470 -  
471 - if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1  
472 -  
473 - dustem_plot_dataset, st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra  
474 -  
475 - endif else begin ;psi_em exists  
476 -  
477 - dustem_plot_dataset, st, dataset='psi_em', position=p_psised, _extra=_extra  
478 - dustem_plot_dataset, st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, _extra=_extra  
479 -  
480 - endelse 446 + ;these don't have to be lists
  447 + datasets = ['SED','POLFRAC','QSED','USED','PSI_EM','POLSED']
  448 + ;but these can be combined using a list but we're leaving it as is for the moment...
  449 + positiveonly = [0,0,1,1,0,0] ;used for q and u
  450 + negativeonly = [0,0,1,1,0,0] ;used for q and u
  451 + ENDIF ELSE BEGIN
  452 +
  453 + dustem_interp = list(dustem_sed) ;DustEmWrap SED predictions .
  454 + dustem_spec = list(SED_spec) ;DustEM spectra predictions
  455 + position = list(p_sed,np_sed);list(list(p_sed,np_sed)) ; I think I need this ...
  456 + ;position_n =list(np_sed)
  457 + datasets = ['SED']
  458 + ;replace by one keyword?
  459 + positiveonly=[0] ;kept it for completeness. Also this loop reminds me that JP also wants the user to be able to display one dataset.
  460 + negativeonly=[0]
  461 + ENDELSE
481 462
482 -  
483 - if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1  
484 -  
485 - dustem_plot_dataset, st, dataset='polsed', /nodata, position=p_psed, _extra=_extra  
486 - dustem_plot_dataset, st, dataset='polsed', /nodata, /norm, position=np_psed, _extra=_extra  
487 -  
488 - endif else begin  
489 -  
490 - dustem_plot_dataset, st, dataset='polsed', position=p_psed, _extra=_extra  
491 - dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, _extra=_extra  
492 -  
493 - dustem_plot_dataset, st, dataset='polsed',/norm, position=np_psed, _extra=_extra ;I think nodata can also be upolsed too  
494 - dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, _extra=_extra  
495 -  
496 - endelse  
497 -  
498 -  
499 - if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1  
500 -  
501 - dustem_plot_dataset, st, dataset='polfrac', /nodata, position=p_spsed, _extra=_extra  
502 -  
503 - endif else begin ;polfrac exists  
504 -  
505 -  
506 - dustem_plot_dataset, st, dataset='polfrac', position=p_spsed, _extra=_extra  
507 - dustem_plot_dataset, st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, _extra=_extra  
508 -  
509 - endelse  
510 -  
511 -  
512 - ENDIF  
513 - 463 + ; PLOTTING OF DATA THAT IS UNCHAED
  464 + dustem_plot_dataset, st, dataset=datasets, position=position,positive_only=positiveonly,negative_only=negativeonly, _extra=_extra
  465 + ; REFRESHING DATA - to plot the refreshed data for the first time.
  466 + dustem_plot_dataset, st, dustem_interp,dustem_spec,extra_spec=extra_spec,dataset=datasets,positive_only=positiveonly,negative_only=negativeonly, /refresh ,position=position, _extra=_extra
514 467
515 ENDIF 468 ENDIF
516 469
@@ -519,8 +472,10 @@ ENDIF @@ -519,8 +472,10 @@ ENDIF
519 ;stop 472 ;stop
520 if test_x then begin 473 if test_x then begin
521 ;Generating extinction window and saving window ID 474 ;Generating extinction window and saving window ID
522 - if !run_pol then window,1,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)' else window,1,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)';, wback='grey';,wobject=winobj_m  
523 475
  476 + ;the 'PS' condition pertaining to fawlty debugging is not present here...
  477 + window,1,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)'
  478 +
524 479
525 ;Plotting model string (legend) 480 ;Plotting model string (legend)
526 xxpos = 0.015 481 xxpos = 0.015
@@ -551,11 +506,10 @@ if test_x then begin @@ -551,11 +506,10 @@ if test_x then begin
551 ;Displaying fixed part 506 ;Displaying fixed part
552 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1 507 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1
553 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35 508 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35
554 - ;Displaying refreshed part (first run . This is the command that will be replaced)  
555 - cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0  
556 - ;saving the command id to replace it  
557 509
558 510
  511 + cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0
  512 +
559 ;plotting of (mostly) fixed data for rchi2 513 ;plotting of (mostly) fixed data for rchi2
560 ;Since the format of the strings is specified, the length/width of the string in thex direction is fixed. 514 ;Since the format of the strings is specified, the length/width of the string in thex direction is fixed.
561 515
@@ -569,7 +523,6 @@ if test_x then begin @@ -569,7 +523,6 @@ if test_x then begin
569 ;Getting the width of the refresh.ed string 523 ;Getting the width of the refresh.ed string
570 cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth 524 cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth
571 widthtot+= thiswidth;varying width 525 widthtot+= thiswidth;varying width
572 - ;saving the command string width to replace it  
573 526
574 527
575 xxpos = 1.0 - widthtot - 0.03 528 xxpos = 1.0 - widthtot - 0.03
@@ -578,14 +531,9 @@ if test_x then begin @@ -578,14 +531,9 @@ if test_x then begin
578 531
579 ;Displaying fixed part 532 ;Displaying fixed part
580 cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0 533 cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0
581 - ;Displaying refreshed part (first run . This is the command that will be replaced)  
582 534
583 cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0 535 cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0
584 536
585 - ;saving the command id to replace it  
586 -  
587 -  
588 -  
589 ;plotting of (mostly) fixed data for rchi2 537 ;plotting of (mostly) fixed data for rchi2
590 538
591 ;Getting the width of the unrefreshed string 539 ;Getting the width of the unrefreshed string
@@ -604,10 +552,9 @@ if test_x then begin @@ -604,10 +552,9 @@ if test_x then begin
604 552
605 ;Displaying fixed part 553 ;Displaying fixed part
606 cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35 554 cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35
607 - ;Displaying refreshed part (first run . This is the command that will be replaced) 555 +
608 cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0 556 cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0
609 - ;saving the command id to replace it  
610 - 557 +
611 ;plotting of title 558 ;plotting of title
612 tit=!dustem_plot_range.title_x 559 tit=!dustem_plot_range.title_x
613 560
@@ -624,7 +571,7 @@ if test_x then begin @@ -624,7 +571,7 @@ if test_x then begin
624 if !dustem_end EQ 1 then cgtext, xxpos , yypos,tit+' (FINAL RUN)',color=0,/normal,charsize = 1.6,alignment=0.5 571 if !dustem_end EQ 1 then cgtext, xxpos , yypos,tit+' (FINAL RUN)',color=0,/normal,charsize = 1.6,alignment=0.5
625 572
626 573
627 - if !run_pol then begin 574 + if !run_pol and tag_exist(*!dustem_show,'qext') then begin
628 575
629 ;position arrays for plot and normalized graph 576 ;position arrays for plot and normalized graph
630 577
@@ -662,125 +609,42 @@ if test_x then begin @@ -662,125 +609,42 @@ if test_x then begin
662 609
663 endelse 610 endelse
664 611
665 - ;Plotting of sed data axes (whether or not data is present)  
666 - plotsym,0,/fill ;you might need to execute this again. hmm...  
667 -  
668 -  
669 - ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters  
670 - if ~test_ext then begin ; EXT data is not present (For completeness) # This is only valid when !run_pol=1  
671 -  
672 - dustem_plot_dataset, st, dataset='EXT', /nodata, position=p_ext, _extra=_extra  
673 - dustem_plot_dataset, st, dataset='EXT', /nodata, /norm, position=np_ext, _extra=_extra  
674 -  
675 - endif else begin ;EXT exists  
676 -  
677 - dustem_plot_dataset, st, dataset='EXT', position=p_ext, _extra=_extra  
678 - dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, _extra=_extra  
679 -  
680 - dustem_plot_dataset, st, dataset='EXT',/norm, position=np_ext, _extra=_extra ;I think nodata can also be used too  
681 -  
682 - dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, _extra=_extra  
683 -  
684 - endelse  
685 612
686 -  
687 - if !run_pol then begin  
688 -  
689 - if ~test_qext then begin ;Qext is not present  
690 -  
691 - dustem_plot_dataset, st, dataset='QEXT', /nodata, position=p_qext, _extra=_extra  
692 - dustem_plot_dataset, st, dataset='QEXT', /nodata, /norm, position=np_qext, _extra=_extra  
693 -  
694 - endif else begin ;Qext data is present  
695 -  
696 - ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)  
697 - dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/positive_only, _extra=_extra  
698 - ;Refreshing the positive_only plot ONLY if there is data. If not do nothing  
699 -  
700 - dustem_plot_dataset, st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, _extra=_extra  
701 -  
702 - dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/negative_only, _extra=_extra  
703 - ;Refreshing the negative_only plot ONLY if there is data. If not do nothing  
704 - dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, _extra=_extra  
705 -  
706 - dustem_plot_dataset, st, dataset='QEXT',/norm, position=np_qext, _extra=_extra ;I think nodata can also be uqsed too  
707 - dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, _extra=_extra  
708 -  
709 - endelse  
710 - ;stop  
711 - if ~test_uext then begin ;uext is not present  
712 -  
713 - dustem_plot_dataset, st, dataset='UEXT', /nodata, position=p_uext, _extra=_extra  
714 - dustem_plot_dataset, st, dataset='UEXT', /nodata, /norm, position=np_uext, _extra=_extra  
715 -  
716 - endif else begin ;uext data is present  
717 -  
718 - ;stop  
719 - ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)  
720 - dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/positive_only, _extra=_extra  
721 -  
722 - ;Refreshing the positive_only plot ONLY if there is data. If not do nothing  
723 - dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, _extra=_extra  
724 -  
725 -  
726 - dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/negative_only, _extra=_extra  
727 - ;Refreshing the negative_only plot ONLY if there is data. If not do nothing  
728 - dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, _extra=_extra  
729 -  
730 -  
731 - dustem_plot_dataset, st, dataset='UEXT',/norm, position=np_uext, _extra=_extra ;I think nodata can also be uused too  
732 - dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, _extra=_extra  
733 -  
734 -  
735 - endelse  
736 -  
737 - if ~test_psi_ext then begin ; psi_ext data is not present (For completeness) # This is only valid when !run_pol=1  
738 -  
739 - dustem_plot_dataset, st, dataset='PSI_EXT', /nodata, position=p_psiext, _extra=_extra 613 + plotsym,0,/fill ; what's the reason behind this?
740 614
741 - endif else begin ;psi_ext exists  
742 -  
743 - dustem_plot_dataset, st, dataset='psi_ext', position=p_psiext, _extra=_extra  
744 - dustem_plot_dataset, st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, _extra=_extra  
745 -  
746 -  
747 - endelse 615 + if !run_pol and tag_exist(*!dustem_show,'qext') then begin
  616 + ;This part can be adjusted for future releases if the user wants to plot
  617 + ;specific datasets
748 618
749 -  
750 - if ~test_polext then begin ; polext data is not present (For completeness) # This is only valid when !run_pol=1  
751 -  
752 - dustem_plot_dataset, st, dataset='polext', /nodata, position=p_pext, _extra=_extra  
753 - dustem_plot_dataset, st, dataset='polext', /nodata, /norm, position=np_pext, _extra=_extra  
754 -  
755 - endif else begin ;polext exists  
756 -  
757 - dustem_plot_dataset, st, dataset='polext', position=p_pext, _extra=_extra  
758 - dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, _extra=_extra  
759 -  
760 - dustem_plot_dataset, st, dataset='polext',/norm, position=np_pext, _extra=_extra ;I think nodata can also be upolsed too  
761 - dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, _extra=_extra  
762 -  
763 - endelse  
764 -  
765 -  
766 - if ~test_fpolext then begin ; fpolext data is not present (For completeness) # This is only valid when !run_pol=1  
767 -  
768 - dustem_plot_dataset, st, dataset='fpolext', /nodata, position=p_spext, _extra=_extra  
769 -  
770 -  
771 - endif else begin ;fpolext exists  
772 - 619 + ;lists because elements have different dimensions and/or we want entire arrays as elements
  620 + dustem_interp = list(dustem_ext,dustem_fpolext,dustem_qext,dustem_uext,dustem_psi_ext,dustem_polext) ;DustEmWrap SED predictions
  621 + dustem_spec = list(EXT_spec,SPEXT_spec,QEXT_spec,UEXT_spec,PSIEXT_spec,POLEXT_spec) ;DustEM spectra predictions
  622 + extra_spec = list(0,EXT_spec,0,0,0,0) ;extra spectra that the dataset needs in order to be plotted.
  623 + ;This (extra_spec use) actually should not be generalized since the only case we need an extra spectrum is when plotting the polarization fraction.
  624 + position = list(list(p_ext,np_ext),list(p_spext),list(p_qext,np_qext),list(p_uext,np_uext),list(p_psiext),list(p_pext,np_pext))
773 625
774 - dustem_plot_dataset, st, dataset='fpolext', position=p_spext, _extra=_extra  
775 - dustem_plot_dataset, st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, _extra=_extra  
776 -  
777 -  
778 - endelse 626 + ;these don't have to be lists
  627 + datasets = ['EXT','FPOLEXT','QEXT','UEXT','PSI_EXT','POLEXT']
  628 + ;but these can be combined using a list but we're leaving it as is for the moment...
  629 + positiveonly = [0,0,1,1,0,0] ;used for q and u
  630 + negativeonly = [0,0,1,1,0,0] ;used for q and u
  631 + ENDIF ELSE BEGIN
  632 +
  633 + dustem_interp = list(dustem_ext) ;DustEmWrap EXT predictions .
  634 + dustem_spec = list(EXT_spec) ;DustEM spectra predictions
  635 + position = list(p_ext,np_ext);list(list(p_sed,np_sed)) ; I think I need this ...
  636 + ;position_n =list(np_sed)
  637 + datasets = ['EXT']
  638 + ;replace by one keyword?
  639 + positiveonly=[0] ;kept it for completeness. Also this loop reminds me that JP also wants the user to be able to display one dataset.
  640 + negativeonly=[0]
  641 + ENDELSE
779 642
780 -  
781 - ENDIF  
782 -  
783 - 643 + ; PLOTTING OF DATA THAT IS UNCHAED
  644 + dustem_plot_dataset, st, dataset=datasets, position=position,positive_only=positiveonly,negative_only=negativeonly, _extra=_extra
  645 +
  646 + ; REFRESHING DATA - to plot the refreshed data for the first time.
  647 + dustem_plot_dataset, st, dustem_interp,dustem_spec,extra_spec=extra_spec,dataset=datasets,positive_only=positiveonly,negative_only=negativeonly, /refresh ,position=position, _extra=_extra
784 648
785 ENDIF 649 ENDIF
786 650
@@ -788,19 +652,21 @@ ENDIF @@ -788,19 +652,21 @@ ENDIF
788 if !dustem_end then !dustem_end = -1 ;so that the last iteration is only plotted once. 652 if !dustem_end then !dustem_end = -1 ;so that the last iteration is only plotted once.
789 653
790 ;PLOTTING OF THE PARAMETERS 654 ;PLOTTING OF THE PARAMETERS
791 -IF !d.name NE 'PS' THEN BEGIN 655 +
  656 +IF !d.name NE 'PS' THEN BEGIN ;What happens when we want to create a ps file of the exact content of the parameters' window?
792 window,2,xpos=param_wxpos,ypos=param_wypos,xsize=param_wxsize,ysize=param_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot? 657 window,2,xpos=param_wxpos,ypos=param_wypos,xsize=param_wxsize,ysize=param_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot?
793 ENDIF 658 ENDIF
794 -dustem_plot_dataset, st, p_dim, errors,dataset='PARAMETERS',_extra=_extra ;& cmdind_prms+=1  
795 -dustem_plot_dataset, st, p_dim,errors,dataset='PARAMETERS',/refresh, _extra=_extra 659 +
  660 +dustem_plot_dataset, st, p_dim, errors,dataset=['PARAMETERS'],_extra=_extra
  661 +dustem_plot_dataset, st, p_dim,errors,dataset=['PARAMETERS'],/refresh, _extra=_extra
796 662
797 ;PLOTTING OF THE PLUGINS 663 ;PLOTTING OF THE PLUGINS
798 IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN 664 IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN
799 IF !d.name NE 'PS' THEN BEGIN 665 IF !d.name NE 'PS' THEN BEGIN
800 window,3,xpos=plugin_wxpos,ypos=plugin_wypos,xsize=plugin_wxsize,ysize=plugin_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot? 666 window,3,xpos=plugin_wxpos,ypos=plugin_wypos,xsize=plugin_wxsize,ysize=plugin_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot?
801 ENDIF 667 ENDIF
802 - dustem_plot_dataset, st, p_dim, errors,dataset='PLUGINS',_extra=_extra ;& cmdind_prms+=1  
803 - dustem_plot_dataset, st, p_dim, errors,dataset='PLUGINS', /refresh , winid=winid_plgns, _extra=_extra 668 + dustem_plot_dataset, st, p_dim, errors,dataset=['PLUGINS'],_extra=_extra ;& cmdind_prms+=1
  669 + dustem_plot_dataset, st, p_dim, errors,dataset=['PLUGINS'], /refresh , winid=winid_plgns, _extra=_extra
804 670
805 ENDIF 671 ENDIF
806 672