Commit 18e4331f10e487e0c4ddb2f35f810f406d45017e

Authored by Ilyes Choubani
1 parent 45960dac
Exists in master

general update (focused on plotting)

src/idl/dustem_check_data.pro
1 1 FUNCTION dustem_check_data,data_sed=data_sed,data_ext=data_ext,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
2 2  
3 3  
4   -;NOTA BENE: No testing is done on the covariances. These will be used when debiasing the large P.
  4 +;NOTA BENE: No testing is done on the covariances. These will be used when debiasing the large P.
5 5  
6 6  
7 7 ;CHECKING THE FORMAT OF THE SED STRUCTURE
... ... @@ -88,7 +88,7 @@ IF KEYWORD_SET(data_sed) THEN BEGIN
88 88 sigma = polsed.sigma(testp)
89 89 polsed={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma}
90 90 ENDIF
91   - ENDELSE ; The deprecation of the fitting of POLFRAC does not happen here. But rather in dustem_mpfit_run
  91 + ENDELSE
92 92 psiemzone:
93 93 ans=''
94 94 psi_em.values = data_sed.psi
... ...
src/idl/dustem_init.pro
... ... @@ -181,7 +181,24 @@ defsysv, '!dustemcgwin_id', { $ ;IDs of windows to plot
181 181 sed: la_undef(), $
182 182 ext: la_undef() $
183 183 }
184   -;I am not sure about the layout of this system variable/structure
  184 +;I am doing this to save time instead of filtering the _extra structure
  185 +
  186 +defsysv, '!dustemcgwin_extra', { $ ;extra structures for each plot
  187 +
  188 + sed: ptr_new(), $
  189 + ext: ptr_new(), $
  190 + polext: ptr_new(), $
  191 + polsed: ptr_new(), $
  192 + polfrac: ptr_new(), $
  193 + psi_em: ptr_new(), $
  194 + psi_ext: ptr_new(), $
  195 + qsed: ptr_new(), $
  196 + used: ptr_new(), $
  197 + qext: ptr_new(), $
  198 + uext: ptr_new() $
  199 + }
  200 +
  201 +
185 202  
186 203 defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run.
187 204 sed: {pl:0, nrm:0}, $
... ... @@ -189,8 +206,8 @@ defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run.
189 206 polext: {pl:0, nrm:0}, $
190 207 polsed: {pl:0, nrm:0}, $
191 208 polfrac: {pl:0, nrm:0}, $
192   - psi_em: {pl:0, nrm:0}, $
193   - psi_ext: {pl:0, nrm:0}, $
  209 + psi_em: {pl:0}, $
  210 + psi_ext: {pl:0}, $
194 211 qsed: {pl:0, nrm:0}, $
195 212 used: {pl:0, nrm:0}, $
196 213 qext: {pl:0, nrm:0}, $
... ...
src/idl/dustem_mask_data.pro
... ... @@ -90,10 +90,10 @@ IF keyword_set(data_struct) and keyword_set(omit) THEN BEGIN
90 90 endfor
91 91 ind0[i] = arr_i ;Indices of the filters to be removed in the data structure
92 92 endfor
93   -
94   - eq_tags = ['STOKESI','EXT_I','EXT_P','','','','','STOKESQ','STOKESU','EXT_Q','EXT_U']
95   - errvec = ['SIGMAII','SIGEXTI','SIGEXTP','','','','','SIGMAQQ','SIGMAUU','SIGEXTQ','SIGEXTU']
96   -
  93 + ;PSI is present two times and you have to fix this.
  94 + eq_tags = ['STOKESI','EXT_I','EXT_P','LARGEP','SMALLP','PSI','PSI','STOKESQ','STOKESU','EXT_Q','EXT_U']
  95 + errvec = ['SIGMAII','SIGEXTI','SIGEXTP','SIGMA_LARGEP','SIGMA_SMALLP','SIGMA_PSI','SIGMA_PSI','SIGMAQQ','SIGMAUU','SIGEXTQ','SIGEXTU']
  96 +
97 97 IF keyword_set(data_set) then begin
98 98 for i=0L,n_elements(data_set)-1 do begin
99 99 ind_set = where(tagnames EQ data_set(i),ctset)
... ... @@ -102,11 +102,13 @@ IF keyword_set(data_struct) and keyword_set(omit) THEN BEGIN
102 102 if ctset ne 0 then begin
103 103 inderr = where(eq_tags EQ data_set(i)) ;no need for counters this is supposedly true at all times plus the error message is below in the next test
104 104 ind_errset = where(tagnames EQ errvec[inderr[0]])
  105 + ;stop
105 106 endif else begin
106 107 ind_set1 = where(tag_names(!dustem_data) EQ data_set(i),ctset)
107 108 if ctset eq 0 then message, 'Aborting. The supplied data set is not found in the DustemWrap database.'
108 109 ind_set = where(tagnames EQ eq_tags(ind_set1[0]))
109 110 ind_errset = where(tagnames EQ errvec(ind_set1[0]))
  111 + ;stop
110 112 endelse
111 113  
112 114 if typename(ind0) EQ 'LIST' then begin
... ...
src/idl/dustem_mpfit_run.pro
... ... @@ -57,36 +57,27 @@ st_model=dustem_read_all(!dustem_soft_dir)
57 57  
58 58 chi2_sed = 0
59 59 chi2_ext = 0
60   -chi2_polext = 0
61   -;chi2_polsed = 0
62   -;chi2_polfrac = 0
63 60 chi2_qsed =0
64 61 chi2_used =0
65 62 chi2_qext =0
66 63 chi2_uext =0
  64 +
67 65 rchi2_sed = 0
68 66 rchi2_ext = 0
69   -rchi2_polext = 0
70   -;rchi2_polsed = 0
71   -;rchi2_polfrac = 0
72 67 rchi2_qsed =0
73 68 rchi2_used =0
74 69 rchi2_qext =0
75 70 rchi2_uext =0
  71 +
76 72 wrchi2_sed = 0
77 73 wrchi2_ext = 0
78   -wrchi2_polext = 0
79   -;wrchi2_polsed = 0
80   -;wrchi2_polfrac = 0
81 74 wrchi2_qsed =0
82 75 wrich2_used =0
83 76 wrchi2_qext =0
84 77 wrich2_uext =0
  78 +
85 79 n_sed = 0
86 80 n_ext = 0
87   -n_polext = 0
88   -;n_polsed = 0
89   -;n_polfrac = 0
90 81 n_qsed =0
91 82 n_used =0
92 83 n_qext =0
... ... @@ -98,15 +89,8 @@ tagnames=tag_names(!dustem_data)
98 89 dustem_out = [0]
99 90 ind_data_tag=dustem_data_tag(count=count_data_tag)
100 91  
101   -;if exist('./noplot') then !dustem_show_plot = 0 else if !dustem_show_plot eq 0 then !dustem_show_plot = 1
102   -;stop
103 92 FOR i_tag=0,count_data_tag-1 DO BEGIN
104 93  
105   -;stop
106   -
107   -;print,i_tag,ind_data_tag(i_tag)
108   -;print,tagnames(ind_data_tag(i_tag))
109   -
110 94 CASE tagnames(ind_data_tag(i_tag)) OF
111 95  
112 96 'SED' : BEGIN
... ... @@ -136,7 +120,8 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
136 120 ;cgwindow,WMULTI=[2,2,1],/CURRENT
137 121  
138 122  
139   - dustemwrap_plot,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra
  123 +
  124 + ;stop
140 125 ;dustemwrap_plott,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra
141 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
142 127  
... ... @@ -207,10 +192,10 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
207 192 ;compute_polext needs updating. It's been months.
208 193 dustem_polext = dustem_compute_polext(p_dim,st,dustem_qext,dustem_uext,Q_ext,U_ext)
209 194 chi2_polext = total(((*!dustem_data.polext).values-dustem_polext)^2/(*!dustem_data.polext).sigma^2)
210   - n_polext = n_elements((*!dustem_data.polext).values)
211   - rchi2_polext = chi2_polext / n_polext
212   - wrchi2_polext = rchi2_polext * !fit_rchi2_weight.polext
213   - print,"chi2 POLEXT = ",chi2_polext," rchi2 POLEXT = ",rchi2_polext;," weighted rchi2 POLEXT=",wrchi2_polext
  195 +; n_polext = n_elements((*!dustem_data.polext).values)
  196 +; rchi2_polext = chi2_polext / n_polext
  197 +; wrchi2_polext = rchi2_polext * !fit_rchi2_weight.polext
  198 +; print,"chi2 POLEXT = ",chi2_polext," rchi2 POLEXT = ",rchi2_polext;," weighted rchi2 POLEXT=",wrchi2_polext
214 199 ;print,"chi2 per wl: ",((*!dustem_data.polext).values-dustem_polext)^2/(*!dustem_data.polext).sigma^2
215 200  
216 201 ; Fit in (pmax,lmax,K)
... ... @@ -281,31 +266,31 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
281 266  
282 267 END
283 268  
284   -; 'POLFRAC': BEGIN ;Deprecate this. Fitting POLFRAC does not make any sense. It is a biased quantity.
285   -; if !run_lin then begin
286   -; dustem_polsed = dustem_compute_polsed(p_dim,st) ; this quantity hasn't been computed yet that is why this line is present here.
287   -; ind_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',count_filt) ;locating the filters of polfrac=smallp in SED xcat
288   -; 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
289   -;
290   -; ;dustem_sed and dustem_polsed might not have the same length thus this block.
291   -;
292   -; If n_elements(dustem_sed) ne n_elements(dustem_polsed) then begin
293   -; if n_elements(dustem_sed) gt n_elements(dustem_polsed) then begin
294   -; dustem_polsed_x = dustem_polsed
295   -; dustem_sed_x = dustem_polsed ;meaning dustem_sed needs to be modified
296   -; ;matching the filter data points
297   -; IF count_filt ne 0 then begin
298   -; for i=0L,count_filt-1 do begin
299   -; j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt)
300   -; if testfilt ne 0 then dustem_sed_x(ind_filt(i)) = dustem_sed(j(0))
301   -; endfor
302   -; endif
303   -; ;matching the spectrum data points
304   -; IF count_fspec ne 0 then begin
305   -; for i=0L,count_fspec-1 do begin
306   -; j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec)
307   -; if testspec ne 0 then dustem_sed_x((ind_fspec(i))) = dustem_sed(j(0))
308   -; endfor
  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
309 294 ; endif
310 295 ; endif ELSE begin
311 296 ;
... ... @@ -340,91 +325,55 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
340 325 ; message,"chi2 POLFRAC = "+strtrim(chi2_polfrac,2)+" rchi2 POLFRAC = "+strtrim(rchi2_polfrac,2),/continue ;," weighted rchi2 POLFRAC=",wrchi2_polfrac
341 326 ; dustem_out = [ dustem_out, dustem_polfrac ]
342 327 ; ;fpol=dustem_polfrac ; problem because extra structure does not get updated so you actually need the 'extra' procedure you haven't finihed coding.
343   -; endif
344   -;OLD DEPRECATED VERSION.
345   -;
346   -; IF !run_lin then begin
347   -;
348   -; dustem_polsed = dustem_compute_polsed(p_dim,st);dustem_compute_polsed(p_dim,st.polsed,cont=cont,freefree=freefree,synchrotron=synchrotron)
349   -; dustem_sed_tmp = dustem_compute_sed(p_dim,st);dustem_compute_sed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron)
350   -; dustem_sed = dustem_polsed
351   -; ind_filt=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',count_filt)
352   -; for i = 0, count_filt-1 do begin
353   -; j=where((*!dustem_data.polsed).filt_names(ind_filt(i)) eq (*!dustem_data.sed).filt_names,count)
354   -; if count eq 1 then dustem_sed(i) = dustem_sed_tmp(j(0))
355   -; endfor
356   -; dustem_polfrac = dustem_polsed/dustem_sed
357   -;
358   -; ; We normalize at 353GHz
359   -; ;x=min(((*!dustem_data.polfrac).wav-850)^2,j353)
360   -; ;dustem_polfrac = dustem_polfrac/dustem_polfrac(j353)*(*!dustem_data.polfrac).values(j353)
361   -;
362   -; chi2_polfrac = total(((*!dustem_data.polfrac).values-dustem_polfrac)^2/(*!dustem_data.polfrac).sigma^2)
363   -; n_polfrac = n_elements((*!dustem_data.polfrac).values)
364   -; rchi2_polfrac = chi2_polfrac / n_polfrac
365   -; wrchi2_polfrac = rchi2_polfrac * !fit_rchi2_weight.polfrac
366   -; print,"chi2 POLFRAC = ",chi2_polfrac," rchi2 POLFRAC = ",rchi2_polfrac;," weighted rchi2 POLFRAC=",wrchi2_polfrac
367   -; ;print,"chi2 per wl: ",((*!dustem_data.polfrac).values-dustem_polfrac)^2/(*!dustem_data.polfrac).sigma^2
368   -;
369   -; dustem_out = [ dustem_out, dustem_polfrac ]
370   -;
371   -; ; Plot if needed
372   -; IF !dustem_show_plot NE 0 THEN BEGIN
373   -;
374   -; ; Also show prediction for polarized P/I
375   -; win+=1
376   -; dustem_plot_polar,st,aligned=st_model.align.grains.aligned,/Pfrac,win=win,yr=[0,0.25],/ysty,xr=[10,5d3];dustem_plot_polar,st,aligned=st_model.align.grains.aligned,/Pfrac,win=win,cont=cont,freefree=freefree,synchrotron=synchrotron,yr=[0,0.25],/ysty,xr=[10,5d3]
377   -;
378   -; ENDIF
379   -;
380   -; ENDIF
381   -;
382   -; END
  328 +; endif
  329 + ; END
383 330  
384 331  
385 332 ;-----------------------------------------------------------------
386   -; 'POLSED': BEGIN
387   -;
388   -; ;PLUGIN IS ADDED INSIDE DUSTEM_COMPUTE_SED
389   -;
390   -; IF !run_lin THEN BEGIN
391   -; ;make polsed only used for when polsed is fitted. Otherwise it's the fitting of Q_SED AND USED that fits the polarization data
392   -; dustem_polsed = dustem_compute_polsed(p_dim,st);dustem_compute_polsed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron)
393   -;
394   -; chi2_polsed = total(((*!dustem_data.polsed).values-dustem_polsed)^2/(*!dustem_data.polsed).sigma^2)
395   -; n_polsed = n_elements((*!dustem_data.polsed).values)
396   -; rchi2_polsed = chi2_polsed / n_polsed
397   -; wrchi2_polsed = rchi2_polsed * !fit_rchi2_weight.polsed
398   -; message,"chi2 POLSED = "+strtrim(chi2_polsed,2)+" rchi2 POLSED = "+strtrim(rchi2_polsed,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed
399   -; print,"chi2 per wl: ",((*!dustem_data.polsed).values-dustem_polsed)^2/(*!dustem_data.polsed).sigma^2
400   -; ;print,"SNR per wl: ",(*!dustem_data.polsed).values/(*!dustem_data.polsed).sigma
401   -;
402   -; dustem_out = [ dustem_out, dustem_polsed ] ; classic command
403   -; ;-----------------------------------------------
404   -;
405   -; ; Plot if needed
  333 + 'POLSED': BEGIN
  334 +
  335 + ;PLUGIN IS ADDED INSIDE DUSTEM_COMPUTE_SED
  336 +
  337 + 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
  339 + dustem_polsed = dustem_compute_polsed(p_dim,st);dustem_compute_polsed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron)
  340 +
  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
406 353 ; IF !dustem_show_plot NE 0 THEN BEGIN
407   -; win+=1
  354 +; win+=1
408 355 ; ;
409   -; xr=[10,8e3]
410   -; yr=[1e-34,1e-28]
411   -;
412   -; dustem_plot_polsed,st,p_dim,dustem_polsed,aligned=st_model.align.grains.aligned,win=win
  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
413 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
414 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
415 362 ;
416   -;
417   -;
  363 +;
  364 +;
418 365 ; ENDIF
419   -; ENDIF
420   -; END
  366 + ENDIF
  367 + END
421 368  
422 369 'QSED': BEGIN
423   -
  370 +
424 371 toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec)
425 372 ;taking care of the color correction for spass ; SHOULD NOT LEAVE THIS ON
426   - dustem_qsed(-1)=dustem_qsed(-2)
427   - stop
  373 + ;dustem_qsed(-1)=dustem_qsed(-2)
  374 +; testspass1 = ((*!dustem_data.qsed).filt_names)(-1) eq 'SPASS1'
  375 +; if testspass1 then dustem_qsed(-1)=dustem_qsed(-2)
  376 +;
428 377 chi2_qsed =total(((*!dustem_data.qsed).values-dustem_qsed)^2/(*!dustem_data.qsed).sigma^2)
429 378 n_qsed = n_elements((*!dustem_data.qsed).values)
430 379 rchi2_qsed = chi2_qsed / n_qsed
... ... @@ -433,58 +382,59 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
433 382 message,"chi2 QSED = "+strtrim(chi2_qsed,2)+" rchi2 QSED = "+strtrim(rchi2_qsed,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed
434 383 print,"chi2 per wl: ",((*!dustem_data.qsed).values-dustem_qsed)^2/(*!dustem_data.qsed).sigma^2
435 384  
436   -
437   -
438   - if !dustem_show_plot NE 0 then begin
439   - fact = 1.00E-20;(3.e10/(1.e-4*(st.polsed.wav)))/1.d40
440   - fact1 = 1.00E-20;(3.e10/(1.e-4*((*!dustem_data.qsed).wav)))/1.d40 ; for data plotting
441   -
442   -; fact=1/(4.*!pi)/(3.e8/1.e-6/(st.polsed).wav)*1.00e17
443   -; fact1=1.E-20
  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
444 391 ;
445   - win+=1
446   - window ,win ,title='DUSTEM WRAP (QSED)'
447   - titstq='Stokes Q Polarization Intensity'
448   - ytitstq=textoidl('Q_\nu (W/m^2/Hz/sr) for N_H=10^{20} H/cm^2')
449   - xtit=textoidl('\lambda (\mum)')
450   - xr=[10,1e6]
451   -
452   - ;normpol1=(*!dustem_data.qsed).values*fact1
453   - yr=[1e-28,1e-17]
454   - ;yr=[1e-34,1e-23]
455   - indq=where(Q_spec lt 0, countq)
456   - ;indq=where((*!dustem_data.qsed).values lt 0, countq)
457   -
458   - ylog=1
459   - if countq ne 0 then begin
460   -; ylog=0
461   -; yr=[-1E-23,-1e-19];e-31
462   - Q_spec=-Q_spec
463   - dustem_qsed =-dustem_qsed
464   - ((*!dustem_data.qsed).values)=-((*!dustem_data.qsed).values)
465   - endif
466   - normpol=Q_spec*fact
467   - normpol1=dustem_qsed*fact1
468   -
469   -
470   - 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)'
471   - cgoplot,st.polsed.wav,Q_spec*fact,color='black'
472   - cgoplot,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1,color='Tomato',psym=16,symsize=1,thick=2
473   - err_bar,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1,yrms=3.*((*!dustem_data.qsed).sigma)/2.*fact1,color=cgColor('Tomato')
474   - cgoplot,(*!dustem_data.qsed).wav,dustem_qsed*fact1,psym=6,color='red',symsize=2
475   -
476   - 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
477   - cgoplot,st.polsed.wav,Q_spec*fact/normpol,color='black'
478   - cgoplot,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1/normpol1,color='Tomato',psym=16,symsize=1,thick=2
479   - err_bar,(*!dustem_data.qsed).wav,(*!dustem_data.qsed).values*fact1/normpol1,yrms=3.*((*!dustem_data.qsed).sigma)/2.*fact1/normpol1,color=cgColor('Tomato')
480   -
481   - endif
  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
482 432 END
483 433  
484 434 'USED': BEGIN
485 435  
486   - toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec)
487   - stop
  436 + ;toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec)
  437 + ;stop
488 438 chi2_used =total(((*!dustem_data.used).values-dustem_used)^2/(*!dustem_data.used).sigma^2)
489 439 n_used = n_elements((*!dustem_data.used).values)
490 440 rchi2_used = chi2_used / n_used
... ... @@ -492,50 +442,50 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
492 442 dustem_out = [ dustem_out, dustem_used] ; classic command
493 443 message,"chi2 USED = "+strtrim(chi2_used,2)+" rchi2 USED = "+strtrim(rchi2_used,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed
494 444 print,"chi2 per wl: ",((*!dustem_data.used).values-dustem_used)^2/(*!dustem_data.used).sigma^2
495   -
  445 + dustemwrap_plot,p_dim,st,dustem_sed,dustem_qsed,dustem_used,dustem_polsed,_extra=_extra
496 446  
497   - if !dustem_show_plot ne 0 then begin
498   - fact = 1.00E-20;(3.e10/(1.e-4*(st.polsed.wav)))/1.d40
499   - fact1 =1.00E-20;(3.e10/(1.e-4*((*!dustem_data.used).wav)))/1.d40 ; for data plotting
  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
500 450  
501   - win+=1
502   - window ,win ,title='DUSTEM WRAP (USED)'
503   - titstu='Stokes U Polarization Intensity'
504   - ytitstu=textoidl('U_\nu (W/m^2/Hz/sr) for N_H=10^{20} H/cm^2')
505   - xtit=textoidl('\lambda (\mum)')
506   - xr=[10,1e6]
507   - normpol2=U_spec*fact
508   - normpol3=dustem_used*fact1
  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
509 459 ;yr=[min(normpol2)-min(normpol2)/10,max(normpol2)+max(normpol2)*10]
510 460  
511 461 ;conditions here are on computed spectra and they should be on the data itself.
512 462 ;This even impairs the visualization of the data. Correct this!!!!!
513 463  
514   - yr=[1e-28,1e-17];[1e-34,1e-23]
515   - indu=where(U_spec lt 0, countu)
  464 + ;yr=[1e-28,1e-17];[1e-34,1e-23]
  465 + ;indu=where(U_spec lt 0, countu)
516 466 ;indu=where((*!dustem_data.used).values lt 0, countu)
517   - ylog=1
518   - if countu ne 0 then begin
519   - ylog=0
520   - yr=[-2e-31,5e-31]
521   - endif
  467 + ;ylog=1
  468 + ;if countu ne 0 then begin
  469 + ;ylog=0
  470 + ;yr=[-2e-31,5e-31]
  471 + ;endif
522 472  
523   - 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'
524   - cgoplot,st.polsed.wav,U_spec*fact,color='black'
525   - cgoplot,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1,color='Teal',psym=16,symsize=1,thick=2
526   - err_bar,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1,yrms=3.*((*!dustem_data.used).sigma)/2.*fact1,color=cgColor('Teal')
527   - cgoplot,(*!dustem_data.used).wav,dustem_used*fact1,psym=6,color='red',symsize=2
528   -
  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 +
529 479  
530 480  
531   - 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
532   - cgoplot,st.polsed.wav,U_spec*fact/normpol2,color='black'
533   - cgoplot,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1/normpol3,color='Teal',psym=16,symsize=1,thick=2
534   - err_bar,(*!dustem_data.used).wav,(*!dustem_data.used).values*fact1/normpol3,yrms=3.*((*!dustem_data.used).sigma)/2.*fact1/normpol3,color=cgColor('Teal')
535   -
  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 + ;
536 486 ;cgwindow, 'plot',
537 487  
538   - endif
  488 + ;endif
539 489 END
540 490 ;
541 491 ;
... ... @@ -633,7 +583,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
633 583  
634 584 END
635 585  
636   - ELSE : IF tagnames(ind_data_tag(i_tag)) NE 'POLFRAC' THEN stop
  586 + ELSE :;IF tagnames(ind_data_tag(i_tag)) NE 'POLFRAC' THEN stop
637 587 ENDCASE
638 588  
639 589 ENDFOR
... ... @@ -653,11 +603,11 @@ if !fit_rchi2_weight.sed ne 0 then begin
653 603 total_rchi2 += rchi2_sed
654 604 endif
655 605 if !run_pol then begin
656   -if !fit_rchi2_weight.polext ne 0 then begin
657   - total_n += n_polext
658   - total_chi2 += chi2_polext
659   - total_rchi2 += rchi2_polext
660   -endif
  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
661 611 ; if !fit_rchi2_weight.polsed ne 0 then begin
662 612 ; total_n += n_polsed
663 613 ; total_chi2 += chi2_polsed
... ... @@ -695,7 +645,7 @@ endif
695 645 total_wchi2 = chi2_ext * !fit_rchi2_weight.ext $
696 646 + chi2_sed * !fit_rchi2_weight.sed
697 647 if !run_pol then begin
698   - total_wchi2 += chi2_polext * !fit_rchi2_weight.polext $
  648 + total_wchi2 += $;chi2_polext * !fit_rchi2_weight.polext $
699 649 ; + chi2_polsed * !fit_rchi2_weight.polsed $
700 650 ; + chi2_polfrac * !fit_rchi2_weight.polfrac $
701 651 + chi2_qsed * !fit_rchi2_weight.qsed $
... ... @@ -708,9 +658,9 @@ message,'======================================================================'
708 658 print,"Total weighted chi2 driving mpfitfun = ", total_wchi2
709 659 print,"Nb of data points = ", total_n
710 660 print,"DOF = ", DOF
711   -print,"Reduced chi2 EXT/SED/POLEXT/POLSED/POLFRAC",rchi2_ext,rchi2_sed,rchi2_polext;,rchi2_polsed,rchi2_polfrac
712   -print,"Weighted reduced chi2 EXT/SED/POLEXT/POLSED/POLFRAC",wrchi2_ext,wrchi2_sed,wrchi2_polext;,wrchi2_polsed,wrchi2_polfrac
713   -if !run_pol then print,"Weights",!fit_rchi2_weight.ext,!fit_rchi2_weight.sed,!fit_rchi2_weight.polext $;,!fit_rchi2_weight.polsed,!fit_rchi2_weight.polfrac $
  661 +print,"Reduced chi2 EXT/SED/POLEXT/POLSED/POLFRAC",rchi2_ext,rchi2_sed;,rchi2_polext;,rchi2_polsed,rchi2_polfrac
  662 +print,"Weighted reduced chi2 EXT/SED/POLEXT/POLSED/POLFRAC",wrchi2_ext,wrchi2_sed;,wrchi2_polext;,wrchi2_polsed,wrchi2_polfrac
  663 +if !run_pol then print,"Weights",!fit_rchi2_weight.ext,!fit_rchi2_weight.sed $;,!fit_rchi2_weight.polext $;,!fit_rchi2_weight.polsed,!fit_rchi2_weight.polfrac $
714 664 else print,"Weights",!fit_rchi2_weight.ext,!fit_rchi2_weight.sed
715 665 print,"Mean weighted reduced chi2 = ", total_wchi2/(total_n-DOF)
716 666 print,"Unweighted reduced Total chi2 = ", total_chi2/(total_n-DOF)
... ...
src/idl/dustem_plot_mlog.pro
1   -PRO dustem_plot_mlog, x,y,help=help,ppositions=ppositions,dy=dy,positive_only=positive_only,negative_only=negative_only,overplot=overplot,_extra=_extra
  1 +PRO dustem_plot_mlog,x,y,help=help,ppositions=ppositions,dy=dy,positive_only=positive_only,negative_only=negative_only,rms=rms,overplot=overplot,color=color,nodata=nodata,_extra=_extra;,overplot=overplot,nodata=nodata
2 2  
3 3 ;+
4 4 ; NAME:
... ... @@ -61,8 +61,8 @@ ENDIF ELSE BEGIN
61 61 x0=ppositions[0] & y0=ppositions[1]
62 62 x1=ppositions[2] & y1=ppositions[3]
63 63 ENDELSE
64   -dx=0.15 ;not used anywy for this plot
65   -use_dy=0.01;.05
  64 +dx=0.;15 ;not used anywy for this plot
  65 +use_dy=0.005;.05
66 66 IF keyword_set(dy) THEN BEGIN
67 67 use_dy=dy
68 68 ENDIF
... ... @@ -70,41 +70,76 @@ ENDIF
70 70 pp=make_ppositions(x0,y0,x1,y1,dx,use_dy,Nx,Ny,xtit_plot=xtit_plot,ytit_plot=ytit_plot, $
71 71 noerase=noerase,xcharsize=xcharsize,ycharsize=ycharsize);,/silent)
72 72  
73   -i=0L
  73 +;noerase=[1,1]
  74 +
  75 +;stop
  76 +;i=0L
74 77 IF countpos NE 0 THEN BEGIN
75 78 IF not keyword_set(negative_only) THEN BEGIN
76   - !p.position=pp[*,i]
77   - if keyword_set(overplot) then goto zone1 else cgplot,x[indpos],y[indpos],noerase=noerase[i],xcharsize=xcharsize[i],ycharsize=ycharsize[i],xtit=xtit,ytit=ytit,_extra=_extra,/ylog,/nodata,ytickformat='dstmwrp_exp';'("-","dstmwrp_exp")'
78   - zone1:
79   - FOR k=0L,count_pos_regions-1 DO BEGIN
80   - cgoplot,x[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]],_extra=_extra
81   - ENDFOR
82   -
83   - ENDIF
84   - i=i+1
85   -ENDIF
86   -
87   -
88   -yrange=!y.crange
89   -
90   -!previous_yrange=ptr_new(yrange)
91   -
92   -new_yrange=10^[(*!previous_yrange)[1],(*!previous_yrange)[0]]
93   -
94   -IF keyword_set(_extra) THEN BEGIN
95   - _extrabis=modify_extra(_extra=_extra,'YRANGE',new_yrange,/replace)
96   -ENDIF
  79 + pos=pp[*,0]
  80 + ;if keyword_set(color) then _extrabis.color=color
  81 +
  82 + if keyword_set(overplot) then begin
  83 + FOR k=0L,count_pos_regions-1 DO BEGIN
  84 +
  85 + if keyword_set(rms) then begin ;Should this be combined with the overplot command?
  86 + cgerrplot,x[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]]-rms,y[df_pos[k,0]:df_pos[k,1]]+rms,color=color;,_extra=_extra
  87 + endif else cgoplot,x[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]],color=color,_extra=_extra
  88 +
  89 + ENDFOR
  90 +
  91 + endif else begin
  92 +
  93 +
  94 + if keyword_set(nodata) then begin
  95 + cgplot,x[indpos],y[indpos],pos=pos,xs=1,yr=yr,noerase=1,xcharsize=xcharsize[0],ycharsize=ycharsize[0],/ylog,/nodata,ytickformat='dstmwrp_exp',_extra=_extra
  96 + endif else begin
  97 + cgplot,x[indpos],y[indpos],pos=pos,xs=1,yr=yr,noerase=1,xcharsize=xcharsize[0],ycharsize=ycharsize[0],/ylog,color=color,ytickformat='dstmwrp_exp',_extra=_extra
  98 + endelse
  99 +
  100 +
  101 + endelse
  102 +
  103 +
  104 + ENDIF
  105 +endif
97 106  
98 107 IF countneg NE 0 THEN BEGIN
99 108 IF not keyword_set(positive_only) THEN BEGIN
100   - !p.position=pp[*,i]
101   - !dustem_mlog=1
102   - if keyword_set(overplot) then goto, zone2 else cgplot,x[indneg],-1.*y[indneg],noerase=noerase[i],xcharsize=xcharsize[i],ycharsize=ycharsize[i],xtit=xtit,ytit=ytit,_extra=_extrabis,/ylog,/nodata,yrange=new_yrange,ytickformat='dstmwrp_exp'
103   - zone2:
104   - FOR k=0L,count_neg_regions-1 DO BEGIN
105   - cgoplot,x[df_neg[k,0]:df_neg[k,1]],-1.*y[df_neg[k,0]:df_neg[k,1]],_extra=_extra
106   - ENDFOR
107   - !dustem_mlog=0
  109 + pos=pp[*,1]
  110 + ;stop
  111 + yrange=!y.crange
  112 + !previous_yrange=ptr_new(yrange)
  113 +
  114 + new_yrange=10^[(*!previous_yrange)[1],(*!previous_yrange)[0]]
  115 +
  116 + IF keyword_set(_extra) THEN BEGIN
  117 +
  118 + _extrabis=modify_extra('YR',new_yrange,/replace,_extra=_extra) ; add exchange option
  119 +
  120 + ENDIF
  121 +
  122 + if keyword_set(overplot) then begin
  123 + FOR k=0L,count_neg_regions-1 DO BEGIN
  124 +
  125 + if keyword_set(rms) then begin ;Should this be combined with the overplot command?
  126 + cgerrplot,x[df_neg[k,0]:df_neg[k,1]],-1*y[df_neg[k,0]:df_neg[k,1]]+rms,-1*y[df_neg[k,0]:df_neg[k,1]]-rms,color=color;,ytickformat='(A)'
  127 + ;color by default otherwise it's _extra supercedes. Let's see how this reacts to the plotting of U
  128 + endif else cgoplot,x[df_neg[k,0]:df_neg[k,1]],-1.*y[df_neg[k,0]:df_neg[k,1]],color=color,_extra=_extra
  129 +
  130 + ENDFOR
  131 +
  132 + endif else begin
  133 +
  134 + !dustem_mlog=1
  135 + if keyword_set(nodata) then begin
  136 + cgplot,x[indneg],-1.*y[indneg],pos=pos,xs=1,noerase=1,xcharsize=xcharsize[1],ycharsize=ycharsize[1],/ylog,/nodata,yrange=new_yrange,ytickformat='dstmwrp_exp',_extra=_extrabis
  137 + endif else begin
  138 + cgplot,x[indneg],-1.*y[indneg],pos=pos,xs=1,noerase=1,xcharsize=xcharsize[1],ycharsize=ycharsize[1],/ylog,yrange=new_yrange,ytickformat='dstmwrp_exp',_extra=_extrabis
  139 + endelse
  140 + !dustem_mlog=0
  141 + endelse
  142 +
108 143 ENDIF
109 144 ENDIF
110 145  
... ...
src/idl/dustemcgwin_dataset.pro
1   -PRO dustemcgwin_dataset, st, prediction, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position, _extra=_extra
  1 +PRO dustemcgwin_dataset, st, prediction, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position,positive_only=positive_only, negative_only=negative_only, _extra=_extra
2 2  
3 3 ;######DRAFT HELP SECTION######
4 4  
... ... @@ -20,11 +20,10 @@ PRO dustemcgwin_dataset, st, prediction, dataset=dataset, norm=norm, refresh=ref
20 20  
21 21 ;except for when nodata is used, the 'prediction' array should always be present for errors not to occur.
22 22  
23   -;YOU NEED THE INFORMATION INSIDE THE _EXTRA STRUCTURE
  23 +;YOU NEED THE INFORMATION INSIDE THE _EXTRA STRUCTURE
24 24  
25 25 ;NB: this procedures uses both !dustem_data/!dustem_show to locate hidden filter/spectrum data points
26 26  
27   -
28 27 ;positions for xyouts on the plots - not using any widgets for now
29 28 ;using same margins for (placement of xyouts plot titles (ie: I_nu, Q_nu, U_nu etc...)) normalized plots and normal ones.
30 29  
... ... @@ -38,38 +37,63 @@ use_cols=dustem_grains_colors(Ngrains,/cgplot)
38 37 use_cols[1]='Cornflower'
39 38 fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 ; st.sed.wav and st.polsed.wav should remain the same
40 39 spec = st.sed.em_tot * fact
  40 +degtorad = !pi/180 ;factor that the arctan will be devided by in order to have an axis in degrees. Talk to JP maybe he wants angle in radians.
41 41  
42   - if !run_pol then begin
43   -
44   - specpol = st.polsed.em_tot * fact
45   - spec[0:11] = 1.00e-40 ; I can't even test for nans because cgwin won't accept the presence of nans in this ratio.
46   - specpolfrac = specpol/spec
47   - polar_ippsi2iqu,spec,specq,specu,specpolfrac,replicate(!dustem_psi,n_elements(spec)) ;(Q & U) were generated this way to save time. This sysv fixes my problem but still...
48   -
49   - endif
50   -
  42 +
  43 +if !run_pol then begin
  44 +
  45 + specpol = st.polsed.em_tot * fact
  46 +
  47 + ;Instead of matching the non-zero values in spec and specpol (dustem outputs),
  48 + ;I will only test on specpol as spec does not contain any null values FOR NOW.
  49 + ;If this happens to change, these lines will have to be adjusted.
  50 +
  51 + specpolfrac = specpol *0.
  52 + psi_em = specpol*0.
  53 + indpolsed = where(specpol ne 0, ct_nullpolsed) ;I am not using the counter for now as it serves me no direct purpose.
  54 + specpolfrac[indpolsed] = specpol[indpolsed]/spec[indpolsed]
  55 +
  56 + ;spec[0:11] = 1.00e-40 ; I can't even test for nans because cgwin won't accept the presence of nans in this ratio.
  57 + ;specpolfrac = specpol/spec
  58 + polar_ippsi2iqu,spec,specq,specu,specpolfrac,replicate(!dustem_psi,n_elements(spec)) ;(Q & U) were generated this way to save time. This sysv fixes my problem but still...
  59 + ;psi_em[indpolsed] = 0.5*atan(specu[indpolsed],specq[indpolsed])/degtorad
  60 + ;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
  61 + ;stop
  62 +endif
  63 +;stop
51 64 clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
52 65 scopes=tag_names((*!dustem_scope))
53 66  
54 67 IF scopes[0] NE 'NONE' THEN BEGIN
55 68 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
56 69 IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0]
57   - If !run_pol then begin
58   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_POLSED') THEN begin
59   - specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
60   - specq=(*(*!dustem_plugin).(i))[*,1]
61   - specu=(*(*!dustem_plugin).(i))[*,2]
62   - endif
63   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
64   - specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
65   - specq+=(*(*!dustem_plugin).(i))[*,1]
66   - specu+=(*(*!dustem_plugin).(i))[*,2]
67   - endif
68   - ENDIF
  70 + If !run_pol then begin
  71 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_POLSED') THEN begin
  72 +
  73 + specq = (*(*!dustem_plugin).(i))[*,1]
  74 + 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)
  76 + 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
  77 + specpolfrac[indpolsed] = specpol[indpolsed]/spec[indpolsed]
  78 + psi_em[indpolsed] = 0.5*atan(specu[indpolsed],specq[indpolsed])/degtorad
  79 + ;stop
  80 + endif
  81 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  82 +
  83 + specq+= (*(*!dustem_plugin).(i))[*,1]
  84 + specu+= (*(*!dustem_plugin).(i))[*,2]
  85 + specpol+= sqrt(((*(*!dustem_plugin).(i))[*,1])^2+(*(*!dustem_plugin).(i))[*,2]^2)
  86 + specpolfrac[indpolsed]+= (sqrt(((*(*!dustem_plugin).(i))[*,1])^2+(*(*!dustem_plugin).(i))[*,2]^2))[indpolsed]/((*(*!dustem_plugin).(i))[*,0])[indpolsed]
  87 + psi_em[indpolsed]+= 0.5*atan(((*(*!dustem_plugin).(i))[*,2])[indpolsed],((*(*!dustem_plugin).(i))[*,1])[indpolsed])/degtorad
  88 +
  89 + endif
  90 +
  91 + ENDIF
69 92  
70   - ENDFOR
71   -
  93 + ENDFOR
72 94 ENDIF
  95 +
  96 +;stop
73 97 tgnms_extra = tag_names(_extra)
74 98 ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR')
75 99 ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR')
... ... @@ -118,7 +142,6 @@ if keyword_set(dataset) then begin
118 142  
119 143 if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
120 144  
121   -
122 145 IF ct_spec NE 0 THEN BEGIN
123 146 xx=((*!dustem_data.sed).wav)[idx_spec]
124 147 yy=prediction[idx_spec]
... ... @@ -127,13 +150,12 @@ if keyword_set(dataset) then begin
127 150 cgerrplot,((*!dustem_data.sed).wav)(idx_spec),(((*!dustem_data.sed).values)[idx_spec]-rms)/yy,(((*!dustem_data.sed).values)[idx_spec]+rms)/yy,color='Powder Blue'
128 151 ENDIF
129 152  
130   -
131 153 IF ct_filt NE 0 THEN BEGIN
132 154 xx=((*!dustem_data.sed).wav)[idx_filt]
133 155 yy=prediction[idx_filt]
134 156 rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.
135 157 cgoplot,xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
136   - cgerrplot,((*!dustem_data.sed).wav)(idx_filt),(((*!dustem_data.sed).values)[idx_filt]-rms)/yy,(((*!dustem_data.sed).values)[idx_filt]+rms)/yy,color='Dodger Blue'
  158 + cgerrplot,((*!dustem_data.sed).wav)(idx_filt),(((*!dustem_data.sed).values)[idx_filt]-rms)/yy,(((*!dustem_data.sed).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot
137 159 ENDIF
138 160  
139 161  
... ... @@ -159,7 +181,9 @@ if keyword_set(dataset) then begin
159 181  
160 182 ;Plotting of the plugins.
161 183 for i=0L,n_plgns-1 do begin
162   - cgoplot,st.sed.wav,(*(*!dustem_plugin).(i)),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  184 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN begin
  185 + cgoplot,st.sed.wav,((*(*!dustem_plugin).(i))[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  186 + ENDIF
163 187 endfor
164 188  
165 189 ;PLotting of the interpolates corresponding to spectrum and filter points
... ... @@ -223,24 +247,29 @@ if keyword_set(dataset) then begin
223 247 idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
224 248  
225 249 if ct_hdnpts ne 0 then begin ;Hidden data points are present
226   -
  250 + ;stop
227 251 ;Locating the hidden spectrum and filter data points
228   - idx_filt_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  252 + idx_filt_hdn = where((((*!dustem_show.sed).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
229 253 idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
230 254  
231   - ;Plotting of hidden spectrum data points
232   - cgoplot,((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_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
  255 + if ct_spec_hdn ne 0 then begin
  256 + ;Plotting of hidden spectrum data points
  257 + cgoplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_spec_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_spec_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
  258 +
  259 + ;Plotting of hidden spectrum error points
  260 + rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
  261 + cgerrplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_spec_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
  262 + endif
233 263  
234   - ;Plotting of hidden spectrum error points
235   - rms=3.*((*!dustem_show.sed).sigma)(idx_spec_hdn)/2.
236   - cgerrplot,((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_hdn)-rms,((*!dustem_show.sed).values)(idx_spec_hdn)+rms,color='Black'
237   -
  264 + if ct_filt_hdn then begin
238 265 ;Plotting of hidden filter data points
239   - cgoplot,((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(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
240   -
241   - ;Plotting of hidden filter error point
242   - rms=3.*((*!dustem_show.sed).sigma)(idx_filt_hdn)/2.
243   - cgerrplot,((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn)-rms,((*!dustem_show.sed).values)(idx_filt_hdn)+rms,color='Black'
  266 + cgoplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_filt_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(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
  267 +
  268 + ;Plotting of hidden filter error point
  269 + rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
  270 + cgerrplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_filt_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
  271 +
  272 + endif
244 273  
245 274 endif
246 275  
... ... @@ -253,7 +282,7 @@ if keyword_set(dataset) then begin
253 282 endelse
254 283  
255 284 endelse
256   -
  285 + ;stop
257 286 end
258 287  
259 288 'EXT': begin
... ... @@ -266,17 +295,331 @@ if keyword_set(dataset) then begin
266 295  
267 296 'POLSED': begin
268 297  
  298 + idx_filt=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',ct_filt)
  299 + idx_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',ct_spec)
  300 +
  301 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  302 +
  303 + if keyword_set(nodata) then begin ;when the data is not present
  304 +
  305 + if keyword_set(norm) then begin ;normalized plot
  306 +
  307 + xtit=textoidl('\lambda (\mum)')
  308 + if !run_pol then xtit = ''
  309 + 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
  310 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  311 +
  312 + endif else begin ;normal plot
  313 +
  314 + cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8
  315 + cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  316 + xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  317 +
  318 + endelse
  319 +
  320 +
  321 + endif else begin ;when the data is present
  322 +
  323 + if keyword_set(norm) then begin
  324 +
  325 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  326 +
  327 + IF ct_spec NE 0 THEN BEGIN
  328 + xx=((*!dustem_data.polsed).wav)[idx_spec]
  329 + yy=prediction[idx_spec]
  330 + rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
  331 + cgoplot,xx,((*!dustem_data.polsed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  332 + cgerrplot,((*!dustem_data.polsed).wav)(idx_spec),(((*!dustem_data.polsed).values)[idx_spec]-rms)/yy,(((*!dustem_data.polsed).values)[idx_spec]+rms)/yy,color='Powder Blue'
  333 + ENDIF
  334 +
  335 + IF ct_filt NE 0 THEN BEGIN
  336 + xx=((*!dustem_data.polsed).wav)[idx_filt]
  337 + yy=prediction[idx_filt]
  338 + rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2.
  339 + cgoplot,xx,((*!dustem_data.polsed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
  340 + cgerrplot,((*!dustem_data.polsed).wav)(idx_filt),(((*!dustem_data.polsed).values)[idx_filt]-rms)/yy,(((*!dustem_data.polsed).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot
  341 + ENDIF
  342 +
  343 +
  344 + endif else begin ;The data points in the plot that remain unchanged ; UNNECESSARY BLOCK but needede to limit erros when calls are made with missing keywords.
  345 +
  346 + xtit=textoidl('\lambda (\mum)')
  347 + if !run_pol then xtit = ''
  348 + 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
  349 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  350 +
  351 + endelse
  352 +
  353 +
  354 + endif else begin ; normal plot
  355 +
  356 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  357 +
  358 + ;Plotting of the spectra of the dust species
  359 + FOR i=0L,Ngrains-1 DO BEGIN
  360 + cgoplot,st.polsed.wav,st.polsed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
  361 + ENDFOR
  362 +
  363 + ;stop
  364 +
  365 + ;Plotting of the plugins.
  366 + for i=0L,n_plgns-1 do begin
  367 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_polsed') THEN begin
  368 + cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  369 + ENDIF
  370 + endfor
  371 +
  372 + ;PLotting of the interpolates corresponding to spectrum and filter points
  373 +
  374 + IF ct_spec NE 0 THEN BEGIN
  375 +
  376 + xx=((*!dustem_data.polsed).wav)[idx_spec]
  377 + yy=prediction[idx_spec]
  378 + cgoplot,xx,yy,color='red',pos=position,psym=7,syms=2,noerase=1
  379 + ENDIF
  380 +
  381 +
  382 + IF ct_filt NE 0 THEN BEGIN
  383 + xx=((*!dustem_data.polsed).wav)[idx_filt]
  384 + yy=prediction[idx_filt]
  385 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  386 + ENDIF
  387 +
  388 + ;Plotting of the total dust emission spectru
  389 + cgoplot,st.polsed.wav,specpol,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  390 +
  391 +
  392 +
  393 + endif else begin ;The data points in the plot that remain unchanged.
  394 +
  395 + ;Spectrum points are treated before for plotting reasons.
  396 + if ct_spec ne 0 then begin
  397 +
  398 + ;Plotting of spectrum data points (to be fitted)
  399 + cgplot,((*!dustem_data.polsed).wav)(idx_spec),((*!dustem_data.polsed).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=8,syms=0.8,ytickformat='dstmwrp_exp'
  400 +
  401 + ;Plotting of the spectrum error points
  402 + rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
  403 + cgerrplot,((*!dustem_data.polsed).wav)(idx_spec),((*!dustem_data.polsed).values)(idx_spec)-rms,((*!dustem_data.polsed).values)(idx_spec)+rms,color='Powder Blue'
  404 +
  405 + endif
  406 +
  407 + if ct_filt ne 0 then begin
  408 + plotsym,0,/fill
  409 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  410 + if ct_spec ne 0 then cgoplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
  411 + cgplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
  412 +
  413 +
  414 + ;Plotting of the filter error points
  415 + rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
  416 + cgerrplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt)-rms,((*!dustem_data.polsed).values)(idx_filt)+rms,color='Dodger Blue'
  417 +
  418 + endif
  419 +
  420 +
  421 + ;Plotting of frequency axis
  422 + 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)')
  423 +
  424 + xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  425 +
  426 + ;Locating all the hidden data points (spectrum+filter)
  427 + match2,((*!dustem_data.polsed).wav),((*!dustem_show.polsed).wav),fit_polsedpts,show_polsedpts ;only show_polsedpts is needed
  428 + idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
  429 +
  430 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  431 + ;stop
  432 + ;Locating the hidden spectrum and filter data points
  433 + idx_filt_hdn = where((((*!dustem_show.polsed).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
  434 + idx_spec_hdn = where(((*!dustem_show.polsed).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
  435 +
  436 + if ct_spec_hdn ne 0 then begin
  437 + ;Plotting of hidden spectrum data points
  438 + cgplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_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
  439 +
  440 + ;Plotting of hidden spectrum error points
  441 + rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
  442 + 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 + endif
  444 +
  445 + if ct_filt_hdn then begin
  446 + ;Plotting of hidden filter data points
  447 + 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 +
  449 + ;Plotting of hidden filter error point
  450 + rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
  451 + cgerrplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
  452 +
  453 + endif
  454 +
  455 + endif
  456 +
  457 +
  458 +
  459 + endelse
  460 +
  461 +
  462 +
  463 + endelse
  464 +
  465 + endelse
  466 +
269 467 end
270 468  
271 469 'POLFRAC': begin
272 470  
273 471 end
274 472  
275   - 'PSI_EM': begin
276   -
  473 + 'PSI_EM': begin ;will be copying code from qsed and hopefully it will work. NB: THIS IS FALSE . YOU DO NOT NEED A LOGARITHMIC AXIS
  474 +
  475 + idx_filt=where((*!dustem_data.psi_em).filt_names NE 'SPECTRUM',ct_filt)
  476 + idx_spec=where((*!dustem_data.psi_em).filt_names EQ 'SPECTRUM',ct_spec)
  477 +
  478 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  479 +
  480 + if keyword_set(nodata) then begin ;when the data is not present
  481 +
  482 + xtit = ''
  483 + 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=[-90.00,90.00],psym=8,syms=0.8
  484 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.1
  485 +
  486 + endif else begin ;when the data is present ; normal plot
  487 +
  488 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  489 +
  490 + ;##################TAKEN FROM SED
  491 +
  492 + ;Plotting of the spectra of the dust species
  493 + FOR i=0L,Ngrains-1 DO BEGIN
  494 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  495 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  496 + cgoplot,st.polsed.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
  497 + ENDFOR
  498 +
  499 + ;Plotting of the plugins.
  500 + for i=0L,n_plgns-1 do begin
  501 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  502 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  503 + cgoplot_mlog,st.polsed.wav,0.5*atan((*(*!dustem_plugin).(i))[*,2],(*(*!dustem_plugin).(i))[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
  504 + ENDIF
  505 + endfor
  506 +
  507 + ;PLotting of the interpolates corresponding to spectrum and filter points
  508 +
  509 + IF ct_spec NE 0 THEN BEGIN
  510 +
  511 + xx=((*!dustem_data.psi_em).wav)[idx_spec]
  512 + yy=prediction[idx_spec]
  513 + cgoplot,xx,yy,color='red',pos=position,psym=7,syms=2,noerase=1
  514 + ENDIF
  515 +
  516 +
  517 + IF ct_filt NE 0 THEN BEGIN
  518 + xx=((*!dustem_data.psi_em).wav)[idx_filt]
  519 + yy=prediction[idx_filt]
  520 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  521 + ENDIF
  522 +
  523 +
  524 + ;Plotting of the total dust emission spectrum
  525 + cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
  526 +
  527 +
  528 + endif else begin ;The data points in the plot that remain unchanged.
  529 +
  530 +
  531 + ;Plotting of frequency axis
  532 + ;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)')
  533 +
  534 +
  535 + ;Spectrum points are treated before for plotting reasons.
  536 + if ct_spec ne 0 then begin
  537 +
  538 + ;Plotting of spectrum data points (to be fitted)
  539 + cgplot,((*!dustem_data.psi_em).wav)(idx_spec),((*!dustem_data.psi_em).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'
  540 +
  541 + ;Plotting of the spectrum error points
  542 + rms=3.*((*!dustem_data.psi_em).sigma)(idx_spec)/2.
  543 + cgerrplot,((*!dustem_data.psi_em).wav)(idx_spec),((*!dustem_data.psi_em).values)(idx_spec)-rms,((*!dustem_data.psi_em).values)(idx_spec)+rms,color='Powder Blue'
  544 +
  545 + endif
  546 +
  547 + if ct_filt ne 0 then begin
  548 +
  549 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  550 + if ct_spec ne 0 then cgoplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[-90.00,90.00],/xlog else $;,ytickformat='dstmwrp_exp'
  551 + cgplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[-90.00,90.00],/xlog;,ytickformat='dstmwrp_exp'
  552 +
  553 +
  554 + ;Plotting of the filter error points
  555 + rms=3.*((*!dustem_data.psi_em).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
  556 + cgerrplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt)-rms,((*!dustem_data.psi_em).values)(idx_filt)+rms,color='Dodger Blue'
  557 +
  558 + endif
  559 +
  560 +
  561 +
  562 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.1
  563 +
  564 + ;Locating all the hidden data points (spectrum+filter)
  565 +
  566 + ;The filtering has been done prior (in the primary routine)
  567 + match2,((*!dustem_data.psi_em).wav),((*!dustem_show.psi_em).wav),fit_psi_empts,show_psi_empts ;only show_psi_empts is needed
  568 + idx_rmv_psi_em=where(show_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
  569 + ;stop
  570 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  571 + ;stop
  572 +
  573 + ;Locating the hidden spectrum and filter data points
  574 + idx_filt_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn)
  575 + idx_spec_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
  576 +
  577 + if ct_spec_hdn ne 0 then begin
  578 + ;Plotting of hidden spectrum data points
  579 + cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8
  580 +
  581 + ;Plotting of hidden spectrum error points
  582 + rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
  583 + cgerrplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn)-rms,(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn)+rms,color='Black'
  584 + endif
  585 +
  586 + if ct_filt_hdn ne 0 then begin
  587 + ;stop
  588 + plotsym,0, /fill
  589 + ;Plotting of hidden filter data points
  590 + cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8
  591 + ;stop
  592 + ;Plotting of hidden filter error point
  593 + rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
  594 + cgerrplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn)-rms,(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn)+rms,color='Black'
  595 +
  596 + endif
  597 +
  598 + endif
  599 +
  600 +
  601 +
  602 + ;stop
  603 +
  604 +
  605 +
  606 +
  607 +
  608 +
  609 +
  610 + endelse
  611 +
  612 +
  613 +
  614 + ;endelse
  615 +
  616 + endelse
  617 + ;stop
  618 +
  619 +
277 620 end
278 621  
279   - 'PSI_EXT': begin
  622 + 'PSI_EXT': begin
280 623  
281 624 end
282 625  
... ... @@ -284,9 +627,17 @@ if keyword_set(dataset) then begin
284 627  
285 628 ;SIGN-RELATED PARAMETERS/LOOPS HERE?
286 629 ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
287   - varvar=where(specq LT 0, testsgq)
  630 + varvar=where((*!dustem_data.qsed).values LT 0, testsgq)
  631 + ;stop
288 632 idx_filt=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM', ct_filt)
289 633 idx_spec=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM' , ct_spec)
  634 + ;Plotting of frequency axis
  635 + ;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)')
  636 +
  637 + ;stop
  638 + ;Locating all the hidden data points (spectrum+filter)
  639 + match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
  640 + idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
290 641  
291 642  
292 643 ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
... ... @@ -302,43 +653,46 @@ if keyword_set(dataset) then begin
302 653  
303 654 endif else begin ;normal plot
304 655  
305   - cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8
306   - cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  656 + cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8
  657 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
307 658 xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
308 659  
309 660 endelse
310 661  
311 662  
312 663 endif else begin ;when the data is present
313   - ;NOTA BENE: DIVDE THE POSITIONS BY A FACTOR :'(
  664 +
314 665 if keyword_set(norm) then begin
315 666  
316 667 if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
317 668  
318 669 ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
319 670  
  671 + IF ct_spec NE 0 THEN BEGIN
  672 + xx=((*!dustem_data.qsed).wav)[idx_spec]
  673 + yy=prediction[idx_spec]
  674 + rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
  675 +; if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
  676 +; dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
  677 + cgoplot,xx,((*!dustem_data.qsed).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  678 + cgerrplot,((*!dustem_data.qsed).wav)(idx_spec),(((*!dustem_data.qsed).values)[idx_spec]-rms)/yy,(((*!dustem_data.qsed).values)[idx_spec]+rms)/yy,color='Powder Blue'
  679 +
  680 + ENDIF
  681 +
320 682 IF ct_filt NE 0 THEN BEGIN
  683 + ;stop
321 684 xx=((*!dustem_data.qsed).wav)[idx_filt]
322 685 yy=prediction[idx_filt]
323 686 rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
324   - if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,((*!dustem_data.qsed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
325   - dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,((*!dustem_data.qsed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
  687 +; if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
  688 +; dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
  689 + cgoplot,xx,((*!dustem_data.qsed).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
326 690 cgerrplot,((*!dustem_data.qsed).wav)(idx_filt),(((*!dustem_data.qsed).values)[idx_filt]-rms)/yy,(((*!dustem_data.qsed).values)[idx_filt]+rms)/yy,color='Dodger Blue'
327 691 ENDIF
328 692  
329 693  
330   - IF ct_spec NE 0 THEN BEGIN
331   - xx=((*!dustem_data.qsed).wav)[idx_spec]
332   - yy=prediction[idx_spec]
333   - rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
334   - if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
335   - dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
336   - cgerrplot,((*!dustem_data.qsed).wav)(idx_spec),(((*!dustem_data.qsed).values)[idx_spec]-rms)/yy,(((*!dustem_data.qsed).values)[idx_spec]+rms)/yy,color='Powder Blue'
337   -
338   - ENDIF
339   -
340 694 endif else begin ;The data points in the plot that remain unchanged
341   -
  695 + ;stop
342 696 xtit=textoidl('\lambda (\mum)')
343 697 if !run_pol then xtit = ''
344 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
... ... @@ -351,105 +705,646 @@ if keyword_set(dataset) then begin
351 705  
352 706 if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
353 707  
354   - ;Plotting of the spectra of the dust species
355   - FOR i=0L,Ngrains-1 DO BEGIN
356   - polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
357   - if testsgq ne 0 then dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i] else $
358   - dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i]
359   - ENDFOR
  708 + if keyword_set(positive_only) then begin
  709 +
  710 + if testsgq eq 0 then begin
  711 +
  712 + FOR i=0L,Ngrains-1 DO BEGIN
  713 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  714 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  715 + dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  716 + ENDFOR
  717 +
  718 + for i=0L,n_plgns-1 do begin
  719 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  720 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  721 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  722 + ENDIF
  723 + endfor
  724 +
  725 + IF ct_spec NE 0 THEN BEGIN
  726 + xx=((*!dustem_data.qsed).wav)[idx_spec]
  727 + yy=prediction[idx_spec]
  728 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  729 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  730 + ENDIF
  731 +
  732 + IF ct_filt NE 0 THEN BEGIN
  733 + xx=((*!dustem_data.qsed).wav)[idx_filt]
  734 + yy=prediction[idx_filt]
  735 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  736 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  737 + ENDIF
  738 +
  739 + dustem_plot_mlog,st.polsed.wav,specq,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  740 +
  741 + endif
  742 +
360 743  
361   - ;Plotting of the plugins.
362   - for i=0L,n_plgns-1 do begin
363   - if testsgq ne 0 then dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position,/negative_only, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2 else $
364   - dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position,/positive_only, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2
365   - endfor
  744 + endif
366 745  
367   - ;PLotting of the interpolates corresponding to spectrum and filter points
368   - IF ct_filt NE 0 THEN BEGIN
369   - xx=((*!dustem_data.qsed).wav)[idx_filt]
370   - yy=prediction[idx_filt]
371   - if testsgq ne 0 then dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2 else $
372   - dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2
  746 +
  747 + if keyword_set(negative_only) then begin
  748 +
  749 + if testsgq ne 0 then begin
373 750  
374   - ENDIF
375   -
376   - IF ct_spec NE 0 THEN BEGIN
  751 + ;Plotting of the spectra of the dust species
  752 + FOR i=0L,Ngrains-1 DO BEGIN
  753 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  754 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  755 + dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  756 + ENDFOR
  757 + ;Plotting of the plugins
  758 + for i=0L,n_plgns-1 do begin
  759 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  760 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  761 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  762 + ENDIF
  763 + endfor
  764 + ;PLotting of the interpolates corresponding to spectrum and filter points
  765 + IF ct_spec NE 0 THEN BEGIN
  766 + xx=((*!dustem_data.qsed).wav)[idx_spec]
  767 + yy=prediction[idx_spec]
  768 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  769 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  770 + ENDIF
  771 +
  772 + IF ct_filt NE 0 THEN BEGIN
  773 + xx=((*!dustem_data.qsed).wav)[idx_filt]
  774 + yy=prediction[idx_filt]
  775 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  776 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  777 + ENDIF
  778 + ;Plotting of the total dust emission spectrum
  779 + dustem_plot_mlog,st.polsed.wav,specq,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  780 +
  781 + endif
  782 +
377 783  
378   - xx=((*!dustem_data.qsed).wav)[idx_spec]
379   - yy=prediction[idx_spec]
380   - if testsgq ne 0 then dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=7,syms=2 else $
381   - dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=7,syms=2
382   - ENDIF
  784 + endif
  785 +
  786 + ;stop
  787 + endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE.
  788 + ;stop
  789 + ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
  790 + xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  791 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  792 +
  793 + ;Locating the hidden spectrum and filter data points
  794 + ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.
  795 + ;idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  796 + ;idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  797 + idx_filt_hdn_pstv = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.qsed).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
  798 + idx_spec_hdn_pstv = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.qsed).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
  799 + idx_filt_hdn_ngtv = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.qsed).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
  800 + idx_spec_hdn_ngtv = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.qsed).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
  801 + endif
383 802  
384   - ;Plotting of the total dust emission spectrum
385   - if testsgq ne 0 then dustem_plot_mlog,st.polsed.wav,specq,ppositions=position,/negative_only, /overplot, noerase=1 else $
386   - dustem_plot_mlog,st.polsed.wav,specq,ppositions=position,/positive_only, /overplot, noerase=1
387 803  
  804 + if keyword_set(positive_only) then begin
  805 + ;stop
  806 + if testsgq eq 0 then begin
  807 + ;stop
  808 + plotsym, 0
  809 + if ct_spec_hdn_pstv ne 0 then begin
  810 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  811 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  812 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  813 +
  814 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  815 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  816 +
  817 + endif
  818 +
  819 + if ct_filt_hdn_pstv ne 0 then begin
  820 +
  821 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  822 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  823 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  824 +
  825 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  826 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  827 +
  828 + endif
  829 +
  830 + if ct_spec ne 0 then begin
  831 +
  832 + rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
  833 + ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  834 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  835 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  836 +
  837 + endif
  838 +
  839 + if ct_filt ne 0 then begin
  840 +
  841 + rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
  842 + ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  843 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  844 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  845 +
  846 + endif
  847 + endif else begin
  848 +
  849 + if ct_spec_hdn_pstv ne 0 then begin
  850 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  851 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  852 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  853 +
  854 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  855 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  856 +
  857 + endif
  858 +
  859 + if ct_filt_hdn_pstv ne 0 then begin
  860 +
  861 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  862 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  863 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  864 +
  865 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  866 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  867 +
  868 + endif
  869 +
  870 + if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
  871 +
  872 + if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  873 +
  874 +
  875 + if ct_filt ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-((*!dustem_data.qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  876 +
  877 +
  878 + endif
  879 +
  880 +
  881 + endelse
388 882  
  883 + endif
389 884  
390   - endif else begin ;The data points in the plot that remain unchanged.
  885 + ;STOPPED COPYING FOR PSI_EM
391 886  
392   - ;Spectrum points are treated before for plotting reasons.
393   - if ct_spec ne 0 then begin
  887 + if keyword_set(negative_only) then begin
394 888  
395   - ;Plotting of spectrum data points (to be fitted)
396   - if testsgq ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,/negative_only, noerase=1,xtit='',charsize=1.15,xtickformat='(A1)',color='Powder Blue',/ys,xs=9,psym=8,syms=0.8 else $
397   - dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,/positive_only, noerase=1,xtit='',charsize=1.15,xtickformat='(A1)',color='Powder Blue',/ys,xs=9,psym=8,syms=0.8
398   -
399   - ;Plotting of the spectrum error points
400   - rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
401   - cgerrplot,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec)-rms,((*!dustem_data.qsed).values)(idx_spec)+rms,color='Powder Blue'
  889 + if testsgq ne 0 then begin
  890 +
  891 + plotsym, 0
  892 + if ct_spec_hdn_ngtv ne 0 then begin
  893 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  894 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  895 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  896 +
  897 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  898 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  899 +
  900 + endif
  901 +
  902 + if ct_filt_hdn_ngtv ne 0 then begin
  903 +
  904 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  905 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  906 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  907 +
  908 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  909 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  910 +
  911 + endif
402 912  
403   - endif
404   -
405   - if ct_filt ne 0 then begin
406   - ;Plotting of filter data points (to be fitted) + testing for prior plotting
407   - if ct_spec ne 0 then begin
  913 + if ct_spec ne 0 then begin
  914 +
  915 + rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
  916 + ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  917 + if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  918 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  919 + endelse;,ytickformat='(A1)'
  920 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  921 +
  922 + endif
  923 +
  924 + if ct_filt ne 0 then begin
  925 +
  926 + rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
  927 + ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  928 + if ct_filt_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  929 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  930 + endelse ;,ytickformat='(A1)'
  931 +
  932 + dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  933 +
  934 + endif
408 935  
409   - if testsgq ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9, /overplot, /negative_only else $
410   - dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9, /overplot, /positive_only
411 936 endif else begin
412 937  
413   - cgoplot,,,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
  938 + if ct_spec_hdn_ngtv ne 0 then begin
  939 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  940 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  941 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  942 +
  943 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  944 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  945 +
  946 + endif
  947 +
  948 + if ct_filt_hdn_ngtv ne 0 then begin
  949 +
  950 + xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  951 + yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  952 + rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  953 +
  954 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  955 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  956 +
  957 + endif
  958 +
  959 + if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
  960 +
  961 + if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  962 +
  963 +
  964 + if ct_filt ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-((*!dustem_data.qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  965 +
  966 +
  967 + endif
  968 +
  969 +
  970 + endelse
  971 +
  972 + endif
  973 +
  974 +
  975 + endelse
  976 +
  977 +
  978 +
  979 + endelse
  980 +
  981 + endelse ;
  982 +
  983 +
  984 + END
  985 +
  986 + 'USED': begin
  987 + ;SIGN-RELATED PARAMETERS/LOOPS HERE?
  988 + ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
  989 + varvar=where((*!dustem_data.used).values LT 0, testsgq)
  990 + ;stop
  991 + idx_filt=where((*!dustem_data.used).filt_names NE 'SPECTRUM', ct_filt)
  992 + idx_spec=where((*!dustem_data.used).filt_names EQ 'SPECTRUM' , ct_spec)
  993 + ;Plotting of frequency axis
  994 + ;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)')
  995 +
  996 + ;stop
  997 + ;Locating all the hidden data points (spectrum+filter)
  998 + match2,((*!dustem_data.used).wav),((*!dustem_show.used).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
  999 + idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  1000 +
  1001 +
  1002 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  1003 +
  1004 + if keyword_set(nodata) then begin ;when the data is not present
  1005 +
  1006 + if keyword_set(norm) then begin ;normalized plot
  1007 +
  1008 + xtit=textoidl('\lambda (\mum)')
  1009 + if !run_pol then xtit = ''
  1010 + 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
  1011 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  1012 +
  1013 + endif else begin ;normal plot
  1014 +
  1015 + cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8
  1016 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  1017 + xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  1018 +
  1019 + endelse
  1020 +
  1021 +
  1022 + endif else begin ;when the data is present
  1023 +
  1024 + if keyword_set(norm) then begin
  1025 +
  1026 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  1027 +
  1028 + ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  1029 +
  1030 + IF ct_spec NE 0 THEN BEGIN
  1031 + xx=((*!dustem_data.used).wav)[idx_spec]
  1032 + yy=prediction[idx_spec]
  1033 + rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
  1034 +; if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
  1035 +; dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_spec),ppositions=position,((*!dustem_data.used).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
  1036 + cgoplot,xx,((*!dustem_data.used).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  1037 + cgerrplot,((*!dustem_data.used).wav)(idx_spec),(((*!dustem_data.used).values)[idx_spec]-rms)/yy,(((*!dustem_data.used).values)[idx_spec]+rms)/yy,color='Powder Blue'
  1038 +
  1039 + ENDIF
  1040 +
  1041 + IF ct_filt NE 0 THEN BEGIN
  1042 + ;stop
  1043 + xx=((*!dustem_data.used).wav)[idx_filt]
  1044 + yy=prediction[idx_filt]
  1045 + rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
  1046 +; if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
  1047 +; dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
  1048 + cgoplot,xx,((*!dustem_data.used).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
  1049 + cgerrplot,((*!dustem_data.used).wav)(idx_filt),(((*!dustem_data.used).values)[idx_filt]-rms)/yy,(((*!dustem_data.used).values)[idx_filt]+rms)/yy,color='Dodger Blue'
  1050 + ENDIF
  1051 +
  1052 +
  1053 + endif else begin ;The data points in the plot that remain unchanged
  1054 + ;stop
  1055 + 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
  1058 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  1059 +
  1060 + endelse
  1061 +
  1062 +
  1063 + endif else begin ; normal plot - STOPPED HERE FOR used
  1064 +
  1065 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  1066 +
  1067 + if keyword_set(positive_only) then begin
  1068 +
  1069 + if testsgq eq 0 then begin
  1070 +
  1071 + FOR i=0L,Ngrains-1 DO BEGIN
  1072 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  1073 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  1074 + dustem_plot_mlog,st.polsed.wav,specugrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1075 + ENDFOR
  1076 +
  1077 + for i=0L,n_plgns-1 do begin
  1078 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  1079 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1080 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1081 + ENDIF
  1082 + endfor
  1083 +
  1084 + IF ct_spec NE 0 THEN BEGIN
  1085 + xx=((*!dustem_data.used).wav)[idx_spec]
  1086 + yy=prediction[idx_spec]
  1087 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  1088 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1089 + ENDIF
  1090 +
  1091 + IF ct_filt NE 0 THEN BEGIN
  1092 + xx=((*!dustem_data.used).wav)[idx_filt]
  1093 + yy=prediction[idx_filt]
  1094 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  1095 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1096 + ENDIF
  1097 +
  1098 + dustem_plot_mlog,st.polsed.wav,specu,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1099 +
  1100 + endif
  1101 +
  1102 +
  1103 + endif
  1104 +
  1105 +
  1106 + if keyword_set(negative_only) then begin
  1107 +
  1108 + if testsgq ne 0 then begin
414 1109  
415   - endelse
416   - cgplot,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit='',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
  1110 + ;Plotting of the spectra of the dust species
  1111 + FOR i=0L,Ngrains-1 DO BEGIN
  1112 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  1113 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  1114 + dustem_plot_mlog,st.polsed.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1115 + ENDFOR
  1116 + ;Plotting of the plugins
  1117 + for i=0L,n_plgns-1 do begin
  1118 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
  1119 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1120 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1121 + ENDIF
  1122 + endfor
  1123 + ;PLotting of the interpolates corresponding to spectrum and filter points
  1124 + IF ct_spec NE 0 THEN BEGIN
  1125 + xx=((*!dustem_data.used).wav)[idx_spec]
  1126 + yy=prediction[idx_spec]
  1127 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  1128 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1129 + ENDIF
  1130 +
  1131 + IF ct_filt NE 0 THEN BEGIN
  1132 + xx=((*!dustem_data.used).wav)[idx_filt]
  1133 + yy=prediction[idx_filt]
  1134 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  1135 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1136 + ENDIF
  1137 + ;Plotting of the total dust emission spectrum
  1138 + dustem_plot_mlog,st.polsed.wav,specu,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
417 1139  
418   - ;Plotting of the filter error points
419   - rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
420   - cgerrplot,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt)-rms,((*!dustem_data.qsed).values)(idx_filt)+rms,color='Dodger Blue'
  1140 + endif
  1141 +
421 1142  
422 1143 endif
423   - ;Plotting of frequency axis
424   - 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)')
425   - xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  1144 +
  1145 + ;stop
  1146 + endif else begin ;The data points in the plot that remain unchanged.
426 1147 ;stop
427   - ;Locating all the hidden data points (spectrum+filter)
428   - match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
429   - idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
430   -
  1148 + ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
  1149 + xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
431 1150 if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1151 +
  1152 + ;Locating the hidden spectrum and filter data points
  1153 + ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.
  1154 + ;idx_filt_hdn = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  1155 + ;idx_spec_hdn = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  1156 + idx_filt_hdn_pstv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
  1157 + idx_spec_hdn_pstv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
  1158 + idx_filt_hdn_ngtv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
  1159 + idx_spec_hdn_ngtv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
  1160 + endif
432 1161  
433   - ;Locating the hidden spectrum and filter data points
434   - idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
435   - idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  1162 +
  1163 + if keyword_set(positive_only) then begin
  1164 + ;stop
  1165 + if testsgq eq 0 then begin
  1166 + ;stop
  1167 + plotsym, 0
  1168 +
  1169 +
  1170 + if ct_spec ne 0 then begin
  1171 +
  1172 + rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
  1173 + ;dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1174 + if ct_spec_hdn_pstv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,/overplot,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  1175 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
  1176 + endelse;,ytickformat='(A1)'
  1177 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)' ;,charsize=1.15,psym=16,syms=0.8
  1178 +
  1179 + endif
  1180 +
  1181 + if ct_filt ne 0 then begin
  1182 +
  1183 + rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
  1184 + ; dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-1.*((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1185 + if ct_filt_hdn_pstv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),/overplot,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  1186 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
  1187 + endelse;,ytickformat='(A1)'
  1188 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,charsize=1.15,psym=16,syms=0.8
  1189 +
  1190 + endif
  1191 +
  1192 + if ct_spec_hdn_pstv ne 0 then begin
  1193 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1194 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1195 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  1196 +
  1197 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1198 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  1199 +
  1200 + endif
  1201 +
  1202 + if ct_filt_hdn_pstv ne 0 then begin
  1203 +
  1204 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1205 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1206 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  1207 +
  1208 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1209 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  1210 +
  1211 + endif
  1212 +
  1213 + endif
  1214 + ;stop;
  1215 + if testsgq ne 0 then begin
  1216 +
  1217 + if ct_spec_hdn_pstv ne 0 then begin
  1218 +
  1219 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1220 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1221 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  1222 +
  1223 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1224 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  1225 +
  1226 + endif
  1227 +
  1228 + if ct_filt_hdn_pstv ne 0 then begin
  1229 +
  1230 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1231 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1232 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  1233 +
  1234 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1235 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  1236 +
  1237 + endif
  1238 +
  1239 + if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
  1240 +
  1241 + if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1242 +
  1243 +
  1244 + if ct_filt ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-((*!dustem_data.used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1245 +
  1246 +
  1247 + endif
  1248 +
  1249 +
  1250 + endif
  1251 +
  1252 + endif
  1253 +
  1254 + if keyword_set(negative_only) then begin
436 1255  
437   - ;Plotting of hidden spectrum data points
438   - cgoplot,((*!dustem_show.qsed).wav)(idx_spec_hdn),((*!dustem_show.qsed).values)(idx_spec_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
  1256 + if testsgq ne 0 then begin
  1257 +
  1258 + plotsym, 0
  1259 +
  1260 +
  1261 + if ct_spec ne 0 then begin
  1262 +
  1263 + rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
  1264 + ;dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1265 + if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  1266 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1267 + endelse;,ytickformat='(A1)'
  1268 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1269 +
  1270 + endif
  1271 +
  1272 + if ct_filt ne 0 then begin
  1273 +
  1274 + rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
  1275 + ; dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-1.*((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1276 + if ct_filt_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
  1277 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1278 + endelse ;,ytickformat='(A1)'
  1279 +
  1280 + dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1281 +
  1282 + endif
  1283 +
  1284 +
  1285 +
  1286 + if ct_spec_hdn_ngtv ne 0 then begin
  1287 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1288 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1289 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  1290 +
  1291 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1292 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  1293 +
  1294 + endif
  1295 +
  1296 + if ct_filt_hdn_ngtv ne 0 then begin
  1297 +
  1298 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1299 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1300 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  1301 +
  1302 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1303 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  1304 +
  1305 + endif
  1306 +
  1307 +
439 1308  
440   - ;Plotting of hidden spectrum error points
441   - rms=3.*((*!dustem_show.qsed).sigma)(idx_spec_hdn)/2.
442   - cgerrplot,((*!dustem_show.qsed).wav)(idx_spec_hdn),((*!dustem_show.qsed).values)(idx_spec_hdn)-rms,((*!dustem_show.qsed).values)(idx_spec_hdn)+rms,color='Black'
443   -
444   - ;Plotting of hidden filter data points
445   - cgoplot,((*!dustem_show.qsed).wav)(idx_filt_hdn),((*!dustem_show.qsed).values)(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
  1309 + endif
446 1310  
447   - ;Plotting of hidden filter error point
448   - rms=3.*((*!dustem_show.qsed).sigma)(idx_filt_hdn)/2.
449   - cgerrplot,((*!dustem_show.qsed).wav)(idx_filt_hdn),((*!dustem_show.qsed).values)(idx_filt_hdn)-rms,((*!dustem_show.qsed).values)(idx_filt_hdn)+rms,color='Black'
450   -
451   - endif
  1311 + if testsgq eq 0 then begin
  1312 +
  1313 + if ct_spec_hdn_ngtv ne 0 then begin
  1314 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1315 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1316 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  1317 +
  1318 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1319 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
  1320 +
  1321 + endif
  1322 +
  1323 + if ct_filt_hdn_ngtv ne 0 then begin
  1324 +
  1325 + xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1326 + yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1327 + rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  1328 +
  1329 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  1330 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
  1331 +
  1332 + endif
  1333 +
  1334 + if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
  1335 +
  1336 + if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1337 +
  1338 +
  1339 + if ct_filt ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-((*!dustem_data.used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1340 +
  1341 +
  1342 + endif
  1343 +
  1344 + ;stop
  1345 + endif
452 1346  
  1347 + endif
453 1348  
454 1349  
455 1350 endelse
... ... @@ -459,10 +1354,7 @@ if keyword_set(dataset) then begin
459 1354 endelse
460 1355  
461 1356 endelse ;
462   -
463   - end
464   -
465   - 'USED': begin
  1357 +
466 1358  
467 1359 end
468 1360  
... ...
src/idl/dustemwrap_plot.pro
1   -PRO dustemwrap_plot,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra
  1 +PRO dustemwrap_plot,p_dim,st,dustem_sed,dustem_qsed,dustem_used,dustem_polsed,_extra=_extra ;, dustem_polfrac
2 2  
3 3 ;NB/ the old POLFRAC treatment from mpfit_run will have to be copied over here when plotting the polarization fraction.
4 4  
... ... @@ -64,6 +64,8 @@ endif else begin
64 64 test_m = test_sed
65 65 test_x = test_ext
66 66 endelse
  67 +
  68 +
67 69 ;testing on the fitting of emission vs extinction data
68 70  
69 71 ;I could create a procedure for colors for the plugins but I am just going to define an array for now
... ... @@ -86,6 +88,10 @@ cmdind_x = 0 ;for extinction
86 88 iswinsed = !dustemcgwin_id.sed EQ la_undef()
87 89 iswinext = !dustemcgwin_id.ext EQ la_undef()
88 90  
  91 +;plotstrct = !p
  92 +degtorad = !pi/180 ;factor that the arctan will be devided by in order to have an axis in degrees. Talk to JP maybe he wants angle in radians.
  93 +
  94 +dustem_psi_em = 0.5*atan(dustem_used,dustem_qsed)/degtorad
89 95  
90 96 ;if iswinsed then begin ;I believe the iswin test should be below the case condition because I am not copying all the first 'HUGE LOOP' but rather replacing the positional arrays.
91 97 if test_m then begin
... ... @@ -112,13 +118,15 @@ if test_m then begin
112 118 p_sed = [0.05,0.67,0.475,0.90]
113 119 p_psed = [0.525,0.67,0.95,0.90]
114 120 ;p_spsed = [0.07,0.42,0.5,0.57]
115   - ;p_psised = [,,,]
116   - p_qsed = [0.05,0.26,0.475,0.49] ;FIX THESE POSITIONS.
117   - ;p_used = [,,,]
  121 + p_psised = [0.525,0.375,0.95,0.575]
  122 +
  123 + p_qsed = [0.05,0.12,0.475,0.35] ;FIX THESE POSITIONS.
  124 + p_used = [0.525,0.12,0.95,0.35]
  125 +
118 126 np_sed = [0.05,0.60,0.475,0.67]
119   - ;np_psed = [0.525,0.60,0.95,0.67]
120   - np_qsed = [0.05,0.19,0.5,0.27]
121   - ;np_used = [,,,]
  127 + np_psed = [0.525,0.60,0.95,0.67]
  128 + np_qsed = [0.05,0.05,0.475,0.12]
  129 + np_used = [0.525,0.05,0.95,0.12]
122 130  
123 131 endif else begin
124 132 p_sed = [0.07,0.30,0.97,0.85]
... ... @@ -131,8 +139,6 @@ if test_m then begin
131 139  
132 140 cgcontrol, execute=0
133 141  
134   -
135   -
136 142 ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
137 143 if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
138 144  
... ... @@ -140,92 +146,150 @@ if test_m then begin
140 146 cgwindow,'dustemcgwin_dataset', st, dataset='SED', /norm, /nodata, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
141 147  
142 148 endif else begin ;SED exists
143   - if ~iswinsed and test_sed then goto, zone1
  149 +
  150 + if ~iswinsed then begin
  151 + cmdind_m = !dustemcgwin_ncmds.sed.pl
  152 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  153 + cmdind_m = !dustemcgwin_ncmds.sed.nrm
  154 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  155 + endif else begin
  156 + ; stop
  157 + cgwindow,'dustemcgwin_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra
  158 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  159 + !dustemcgwin_ncmds.sed.pl = cmdind_m
  160 + cgwindow,'dustemcgwin_dataset', st, dataset='SED',/norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
  161 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  162 + !dustemcgwin_ncmds.sed.nrm = cmdind_m
  163 + endelse
  164 + endelse
  165 +
  166 + ;if ~!run_pol then begin;I don't think the order of the ;goto, end_m
  167 + if !run_pol then begin ;then goto, end_m
144 168  
145   - cgwindow,'dustemcgwin_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra
  169 + if ~test_qsed then begin ;Qsed is not present
  170 +
  171 + cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /nodata, position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  172 + cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /norm, /nodata, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
146 173  
147   - cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  174 + endif else begin ;Qsed data is present
  175 +
  176 + if ~iswinsed then begin
  177 + cmdind_m = !dustemcgwin_ncmds.qsed.pl
  178 + ;refreshing the positive_only and negative_only plots if data is present in them
  179 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED',/positive_only, /refresh, nodata=0 ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  180 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED',/negative_only, /refresh, nodata=0 ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  181 + cmdind_m = !dustemcgwin_ncmds.qsed.nrm
  182 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh, nodata=0, /norm,position=np_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  183 + endif else begin
  184 + ;stop
  185 + ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
  186 + cgwindow,'dustemcgwin_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
  187 + ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
  188 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED',/positive_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  189 +
  190 + cgwindow,'dustemcgwin_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
  191 + ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
  192 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED',/negative_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  193 +
  194 + !dustemcgwin_ncmds.qsed.pl = cmdind_m
  195 +
  196 + cgwindow,'dustemcgwin_dataset', st, dataset='QSED',/norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be uqsed too
  197 + cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh, /norm,position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  198 + !dustemcgwin_ncmds.qsed.nrm = cmdind_m
  199 + endelse
  200 + endelse
  201 + ;
  202 + if ~test_used then begin ;used is not present
  203 +
  204 + cgwindow,'dustemcgwin_dataset', st, dataset='USED', /nodata, position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  205 + cgwindow,'dustemcgwin_dataset', st, dataset='USED', /norm, /nodata, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
148 206  
149   - !dustemcgwin_ncmds.sed.pl = cmdind_m
150   - zone1:
151   - if ~iswinsed then begin
152   - cmdind_m = !dustemcgwin_ncmds.sed.pl
153   - cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
154   - goto, zone2
155   - endif
  207 + endif else begin ;used data is present
  208 +
  209 + if ~iswinsed then begin
  210 + cmdind_m = !dustemcgwin_ncmds.used.pl
  211 + ;refreshing the positive_only and negative_only plots if data is present in them
  212 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED',/positive_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  213 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED',/negative_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  214 + cmdind_m = !dustemcgwin_ncmds.used.nrm
  215 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh, nodata=0, /norm,position=np_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  216 + endif else begin
  217 + ;stop
  218 + ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
  219 + cgwindow,'dustemcgwin_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
  220 + ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
  221 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED',/positive_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  222 +
  223 + cgwindow,'dustemcgwin_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
  224 + ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
  225 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED',/negative_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  226 +
  227 + !dustemcgwin_ncmds.used.pl = cmdind_m
  228 +
  229 + cgwindow,'dustemcgwin_dataset', st, dataset='USED',/norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be uused too
  230 + cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh, /norm,position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  231 + !dustemcgwin_ncmds.used.nrm = cmdind_m
  232 + endelse
  233 + endelse
  234 +
  235 + if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1
  236 +
  237 + cgwindow,'dustemcgwin_dataset', st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  238 + ;cgwindow,'dustemcgwin_dataset', st, dataset='psi_em', /norm, /nodata, position=np_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  239 +
  240 + endif else begin ;psi_em exists
  241 +
  242 + if ~iswinsed then begin
  243 + cmdind_m = !dustemcgwin_ncmds.psi_em.pl
  244 + cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='psi_em', /refresh ,position=p_psised, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  245 + ;cmdind_m = !dustemcgwin_ncmds.psi_em.nrm
  246 + ;cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='psi_em', /refresh, /norm,position=np_psised, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  247 + endif else begin
  248 + ;stop
  249 + cgwindow,'dustemcgwin_dataset', st, dataset='psi_em', position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  250 + cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='psi_em', /refresh ,position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  251 + !dustemcgwin_ncmds.psi_em.pl = cmdind_m
  252 +; cgwindow,'dustemcgwin_dataset', st, dataset='psi_em',/norm, position=np_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be upsi_em too
  253 +; cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='psi_em', /refresh, /norm,position=np_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  254 +; !dustemcgwin_ncmds.psi_em.nrm = cmdind_m
  255 + endelse
  256 + endelse
156 257  
157   - cgwindow,'dustemcgwin_dataset', st, dataset='SED',/norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
  258 +
  259 + if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1
  260 +
  261 + cgwindow,'dustemcgwin_dataset', st, dataset='polsed', /nodata, position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  262 + cgwindow,'dustemcgwin_dataset', st, dataset='polsed', /norm, /nodata, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  263 +
  264 + endif else begin ;polsed exists
  265 +
  266 + if ~iswinsed then begin
  267 + cmdind_m = !dustemcgwin_ncmds.polsed.pl
  268 + cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='polsed', /refresh ,position=p_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  269 + cmdind_m = !dustemcgwin_ncmds.polsed.nrm
  270 + cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='polsed', /refresh, /norm,position=np_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  271 + endif else begin
  272 + ;stop
  273 + cgwindow,'dustemcgwin_dataset', st, dataset='polsed', position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  274 + cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='polsed', /refresh ,position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  275 + !dustemcgwin_ncmds.polsed.pl = cmdind_m
  276 + cgwindow,'dustemcgwin_dataset', st, dataset='polsed',/norm, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be upolsed too
  277 + cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='polsed', /refresh, /norm,position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  278 + !dustemcgwin_ncmds.polsed.nrm = cmdind_m
  279 + endelse
  280 + endelse
158 281  
159   - cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
160   - !dustemcgwin_ncmds.sed.nrm = cmdind_m
  282 +
  283 +
  284 +;#############################################################################
  285 +;!!!!!!!!!NOTA BENE : Do not forget to modify the value of 'prediction' and adjust it to the computation of the polarization angle using
  286 +;the two stokes paramters model prediction interpolates provided as output by the wrapper.
  287 +;#############################################################################
161 288  
162   - zone2:
163   - if ~iswinsed then begin
164   - cmdind_m = !dustemcgwin_ncmds.sed.nrm
165   - cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
166   - endif
167   -
168   - endelse
169   -
170   - ;if ~!run_pol then begin;I don't think the order of the ;goto, end_m
171   -; if !run_pol then goto, end_m; begin
172   -;
173   -; if ~iswinsed and test_qsed then goto, zone3
174   -;
175   -; if ~test_qsed then begin ;Qsed is not present
176   -;
177   -; cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /nodata, position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
178   -; cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /norm, /nodata, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
179   -;
180   -; endif else begin ;Qsed data is present
181   -; cgwindow,'dustemcgwin_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
182   -; cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
183   -; !dustemcgwin_ncmds.qsed.pl = cmdind_m
184   -; zone3:
185   -; if ~iswinsed then begin
186   -; cmdind_m = !dustemcgwin_ncmds.qsed.pl
187   -; cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh ,position=p_qsed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
188   -; goto, zone4
189   -; endif
190   -; cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
191   -; cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh, /norm,position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
192   -; !dustemcgwin_ncmds.qsed.nrm = cmdind_m
193   -; zone4:
194   -; if ~iswinsed then begin
195   -; cmdind_m = !dustemcgwin_ncmds.qsed.nrm
196   -; cgwindow,'dustemcgwin_dataset', st, dustem_qsed, dataset='QSED', /refresh, /norm,position=np_qsed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
197   -; endif
198   -;
199   -; endelse
200   -;
201   -; if ~iswinsed and test_used then goto, zone5
202   -;
203   -; if ~test_used then begin ;Used is not present
204   -;
205   -; cgwindow,'dustemcgwin_dataset', st, dataset='USED', /nodata, position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
206   -; cgwindow,'dustemcgwin_dataset', st, dataset='USED', /norm, /nodata, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
207   -;
208   -; endif else begin ;Used data is present
209   -; cgwindow,'dustemcgwin_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
210   -; cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
211   -; !dustemcgwin_ncmds.used.pl = cmdind_m
212   -; zone5:
213   -; if ~iswinsed then begin
214   -; cmdind_m = !dustemcgwin_ncmds.used.pl
215   -; cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh ,position=p_used, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
216   -; goto, zone6
217   -; endif
218   -; cgwindow,'dustemcgwin_dataset', st, dataset='USED', /norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
219   -; cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh, /norm,position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
220   -; !dustemcgwin_ncmds.used.nrm = cmdind_m
221   -; zone6:
222   -; if ~iswinsed then begin
223   -; cmdind_m = !dustemcgwin_ncmds.used.nrm
224   -; cgwindow,'dustemcgwin_dataset', st, dustem_used, dataset='USED', /refresh, /norm,position=np_used, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
225   -; endif
226   -;
227   -; endelse
228   -;
  289 +
  290 +
  291 +
  292 +
229 293 ; if ~iswinsed and test_polsed then goto, zone7
230 294 ;
231 295 ; if ~test_polsed then begin ;Polsed is not present
... ... @@ -282,7 +346,7 @@ if test_m then begin
282 346 ;
283 347 ; endelse
284 348 ;
285   -; if ~iswinsed and test_psi_em then goto, zone11
  349 +; if ~iswinsed and test_psi_em then goto, zone11 DO NOT FORGET
286 350 ;
287 351 ; if ~test_psi_em then begin ;Polfrac is not present
288 352 ;
... ... @@ -311,7 +375,7 @@ if test_m then begin
311 375 ; endelse
312 376 ;
313 377 ;
314   -; endif
  378 + endif
315 379  
316 380 end_m:
317 381  
... ... @@ -332,7 +396,7 @@ if test_m then begin
332 396 ;cgcontrol, update=0
333 397 ;cgcontrol, update=1
334 398 ;varr=cgquery(dimensions=dim_m,objectref=winobj_m)
335   - stop
  399 + ;stop
336 400  
337 401 endif
338 402 ;endif
... ...