Commit 45960dacae657a4f4ad1fe7edf17958d70facb42

Authored by Jean-Philippe Bernard
2 parents 86431bbe a1cd0f1d
Exists in master

Merge branch 'master' of https://gitlab.irap.omp.eu/OV-GSO-DC/dustem-wrapper_idl

src/idl/dstmwrp_exp.pro
... ... @@ -21,12 +21,16 @@ FUNCTION dstmwrp_exp, axis, index, number
21 21 sign = ''
22 22 thisExponent = '0'
23 23 ENDIF
24   -
  24 +
  25 +
  26 + frmt = '10!U'
  27 + IF !dustem_mlog then frmt='-'+frmt
25 28 ; Make the exponent a superscript.
26 29 IF sign EQ '-' THEN BEGIN
27   - IF first EQ 1 then RETURN, '10!U' + sign + thisExponent + '!N' ELSE RETURN, first + 'x10!U' + sign + thisExponent + '!N'
  30 + IF first EQ 1 then RETURN, frmt + sign + thisExponent + '!N' ELSE RETURN, first + 'x' + frmt + sign + thisExponent + '!N'
28 31 ENDIF ELSE BEGIN
29   - IF first EQ 1 then RETURN, '10!U' + thisExponent + '!N' ELSE RETURN, first + 'x10!U' + thisExponent + '!N'
  32 + IF first EQ 1 then RETURN, frmt + thisExponent + '!N' ELSE RETURN, first + 'x' + frmt + thisExponent + '!N'
30 33 ENDELSE
  34 +
31 35  
32 36 END
33 37 \ No newline at end of file
... ...
src/idl/dustem_compute_polsed.pro
... ... @@ -68,14 +68,12 @@ IF scopes[0] NE 'NONE' THEN BEGIN
68 68  
69 69 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
70 70  
71   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN BEGIN
  71 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_POLSED') THEN BEGIN
72 72  
73 73 Q_spec=(*(*!dustem_plugin).(i))[*,1]
74   - ENDIF
75   -
76   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_USED') THEN BEGIN
77 74 U_spec=(*(*!dustem_plugin).(i))[*,2]
78   - ENDIF
  75 +
  76 + ENDIF
79 77  
80 78 ENDFOR
81 79  
... ... @@ -85,14 +83,11 @@ IF ~isa(Q_spec) && ~isa(U_spec) THEN polar_ippsi2iqu,stI,Q_spec,U_spec,frac,repl
85 83  
86 84 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
87 85  
88   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN BEGIN
  86 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN BEGIN
89 87 Q_spec+=(*(*!dustem_plugin).(i))[*,1]
90   - ENDIF
91   -
92   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_USED') THEN BEGIN
93 88 U_spec+=(*(*!dustem_plugin).(i))[*,2]
94   - ENDIF
95   -
  89 + ENDIF
  90 +
96 91 ENDFOR
97 92  
98 93 P=sqrt(Q_spec^2+U_spec^2)
... ...
src/idl/dustem_compute_sed.pro
... ... @@ -76,6 +76,7 @@ ENDIF
76 76 if not isarray(spec) THEN stop
77 77  
78 78 ;COMPUTE THE MODEL SED
  79 +
79 80 dustem_sed = (*!dustem_data.sed).values * 0.
80 81  
81 82 IF !dustem_do_cc NE 0 AND !dustem_never_do_cc EQ 0 THEN BEGIN
... ...
src/idl/dustem_compute_stokes.pro
... ... @@ -65,37 +65,27 @@ frac(tes)=0.
65 65  
66 66 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
67 67  
68   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN BEGIN
  68 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_POLSED') THEN BEGIN
69 69  
70 70 Q_spec=(*(*!dustem_plugin).(i))[*,1]
71   - ENDIF
72   -
73   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_USED') THEN BEGIN
74 71 U_spec=(*(*!dustem_plugin).(i))[*,2]
75   - ENDIF
76   -
  72 +
  73 + ENDIF
  74 +
77 75 ENDFOR
78 76  
79   -IF ~isa(Q_spec) && ~isa(U_spec) THEN BEGIN
80   - ;maybe add a condition that takes into account the angles of the stokes parameters.
81   - ;I believe it is best to hard code the angle information in here
82   - ;this also includes its extraction?
83   -
84   - polar_ippsi2iqu,stI,Q_spec,U_spec,frac,replicate(!dustem_psi,Nwaves)
85   -;stop
86   -ENDIF
87   -
  77 +IF ~isa(Q_spec) && ~isa(U_spec) THEN polar_ippsi2iqu,stI,Q_spec,U_spec,frac,replicate(!dustem_psi,Nwaves) ;This line is to generate data by default.
  78 +
88 79  
89 80 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
90 81  
91   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN BEGIN
  82 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN BEGIN
  83 +
92 84 Q_spec+=(*(*!dustem_plugin).(i))[*,1]
93   - ENDIF
94   -
95   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_USED') THEN BEGIN
96 85 U_spec+=(*(*!dustem_plugin).(i))[*,2]
97   - ENDIF
98 86  
  87 + ENDIF
  88 +
99 89 ENDFOR
100 90  
101 91 ;stop
... ... @@ -107,7 +97,7 @@ dustem_qsed = (*!dustem_data.qsed).values * 0.
107 97 dustem_used = (*!dustem_data.used).values * 0.
108 98  
109 99  
110   -if not isarray(stI) THEN stop
  100 +if not isarray(stI) THEN stop ; I don't get this test. It is unnecessary.
111 101  
112 102 ;Performing color corrections on the dustem spectra and generating the SEDs at the given filters
113 103  
... ...
src/idl/dustem_init.pro
... ... @@ -110,30 +110,64 @@ dustem_fit_st={data:ptr_new(),wavelength:ptr_new(), $
110 110 }
111 111 defsysv, '!dustem_fit', ptr_new(dustem_fit_st) ;Data to fit
112 112  
  113 +
  114 +
  115 +
113 116 if keyword_set(pol) then begin
114 117 defsysv, '!dustem_data', { $ ;Data to fit
  118 + sed: ptr_new(), $ ;
  119 + ext: ptr_new(), $ ;
  120 + polext: ptr_new(), $ ; FREE TO USE
  121 + polsed: ptr_new(), $ ; FREE TO USE
  122 + polfrac: ptr_new(), $ ; FREE TO USE
  123 + psi_em: ptr_new(), $ ; FREE TO USE
  124 + psi_ext: ptr_new(), $ ; FREE TO USE
  125 + qsed: ptr_new(), $ ;
  126 + used: ptr_new(), $ ;
  127 + qext: ptr_new(), $ ;
  128 + uext: ptr_new() $ ;
  129 + }
  130 +
  131 + ;rchi2_weight = {sed: 0.,ext: 0.,polext: 0.,polsed: 0.,polfrac:0.,qsed:0.,used:0.,qext:0.,uext:0.} ;polsed and polfrac newly deprecated
  132 + rchi2_weight = {sed: 0.,ext: 0.,polext:0.,polsed:0.,polfrac:0.,psi_em:0.,psi_ext:0.,qsed:0.,used:0.,qext:0.,uext:0.}
  133 +
  134 + defsysv,'!dustem_show', { $ ;Data to fit
115 135 sed: ptr_new(), $
116 136 ext: ptr_new(), $
117   - polext: ptr_new(), $ ;
118   - polsed: ptr_new(), $ ; changes in dustem_set_data/check_data to be made!!!
119   - polfrac: ptr_new(), $ ;
  137 + polext: ptr_new(), $
  138 + polsed: ptr_new(), $
  139 + polfrac: ptr_new(), $
  140 + psi_em: ptr_new(), $
  141 + psi_ext: ptr_new(), $
120 142 qsed: ptr_new(), $
121 143 used: ptr_new(), $
122 144 qext: ptr_new(), $
123 145 uext: ptr_new() $
124   - }
125   -
126   - ;rchi2_weight = {sed: 0.,ext: 0.,polext: 0.,polsed: 0.,polfrac:0.,qsed:0.,used:0.,qext:0.,uext:0.} ;polsed and polfrac newly deprecated
127   - rchi2_weight = {sed: 0.,ext: 0.,qsed:0.,used:0.,qext:0.,uext:0.}
  146 + }
  147 +
128 148 endif else begin
  149 +
129 150 defsysv, '!dustem_data', { $ ;Data to fit
130 151 sed: ptr_new(), $
131 152 ext: ptr_new() $
132 153 }
133 154 rchi2_weight = {sed: 0.,ext: 0.}
  155 +
  156 + defsysv, '!dustem_show', { $ ;Data to fit
  157 + sed: ptr_new(), $
  158 + ext: ptr_new() $
  159 + }
134 160 endelse
135 161  
136   -tagnames = tag_names(!dustem_data)
  162 +
  163 +if !run_pol then begin
  164 + tagnames=tag_names(!dustem_data)
  165 + testpol = tagnames EQ 'POLSED' or tagnames EQ 'POLEXT' or tagnames EQ 'POLFRAC' or tagnames EQ 'POLSED' or tagnames EQ 'PSI_EM' or tagnames EQ 'PSI_EXT'
  166 + ind_data=where(~testpol,ctestpol)
  167 + if ctestpol ne 0 then tagnames =(tag_names(!dustem_data))[ind_data]
  168 +
  169 +endif else tagnames=tag_names(!dustem_data)
  170 +
137 171 instr="defsysv, '!fit_rchi2_weight', {"
138 172 FOR i = 0, n_elements(tagnames)-1 DO BEGIN
139 173 instr+=tagnames(i)+': rchi2_weight.'+tagnames(i)
... ... @@ -142,32 +176,34 @@ ENDFOR
142 176 instr+='}'
143 177 toto=execute(instr)
144 178  
  179 +;#########system variables necessary for cgwindow plotting##########
  180 +defsysv, '!dustemcgwin_id', { $ ;IDs of windows to plot
  181 + sed: la_undef(), $
  182 + ext: la_undef() $
  183 + }
  184 +;I am not sure about the layout of this system variable/structure
  185 +
  186 +defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run.
  187 + sed: {pl:0, nrm:0}, $
  188 + ext: {pl:0, nrm:0}, $
  189 + polext: {pl:0, nrm:0}, $
  190 + polsed: {pl:0, nrm:0}, $
  191 + polfrac: {pl:0, nrm:0}, $
  192 + psi_em: {pl:0, nrm:0}, $
  193 + psi_ext: {pl:0, nrm:0}, $
  194 + qsed: {pl:0, nrm:0}, $
  195 + used: {pl:0, nrm:0}, $
  196 + qext: {pl:0, nrm:0}, $
  197 + uext: {pl:0, nrm:0} $
  198 + }
  199 +
  200 +defsysv, '!dustem_mlog', 0 ;necessary for the plotting of negative values on the axis in dstmwrp_exp.pro
  201 +;###################################################################
  202 +
  203 +
  204 +defsysv, '!dustem_psi', 0.
145 205  
146   -defsysv,'!dustem_show', { $ ;Data to fit
147   - sed: ptr_new(), $
148   - ext: ptr_new(), $
149   - polext: ptr_new(), $
150   - polsed: ptr_new(), $
151   - polfrac: ptr_new(), $
152   - psi_em: ptr_new(), $
153   - psi_ext: ptr_new(), $
154   - qsed: ptr_new(), $
155   - used: ptr_new(), $
156   - qext: ptr_new(), $
157   - uext: ptr_new() $
158   - }
159   -
160   -
161   -defsysv, '!dustemcgwin_id', { $ ;IDs of windows to plot
162   - sed: la_undef(), $
163   - ext: la_undef() $
164   - }
165 206  
166   -defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run.
167   - sed: {ct_z1:0,ct_z2:0,ct_z3:0,ct_z4:0,ct_z5:0,ct_z6:0}, $
168   - ext: {ct_z1:0,ct_z2:0,ct_z3:0,ct_z4:0,ct_z5:0,ct_z6:0} $
169   - }
170   -
171 207  
172 208 ;IDL> help,*!dustem_data,/str
173 209 ;** Structure <2173b20>, 4 tags, length=448, data length=448, refs=1:
... ... @@ -236,7 +272,7 @@ dustem_inputs={GRAIN:&#39;GRAIN.DAT&#39;,ISRF:&#39;ISRF.DAT&#39;,ALIGN:&#39;ALIGN.DAT&#39;}
236 272 !dustem_inputs=ptr_new(dustem_inputs)
237 273  
238 274  
239   -defsysv, '!dustem_HCD', ptr_new(1.00E20) ;This is a dumb thing I added but will shortly remove it
  275 +defsysv, '!dustem_HCD', ptr_new(1.00E20) ;I do not see the reason behind using a pointer in this case.
240 276  
241 277  
242 278 ;===This is the Desert option
... ... @@ -404,6 +440,7 @@ ENDIF
404 440 ;Initialize filters
405 441 dustem_filter_init,dir=dir
406 442  
  443 +
407 444 the_end:
408 445  
409 446 END
... ...
src/idl/dustem_plot_mlog.pro 0 โ†’ 100644
... ... @@ -0,0 +1,117 @@
  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
  2 +
  3 +;+
  4 +; NAME:
  5 +; plot_negative_log
  6 +; CALLING SEQUENCE:
  7 +; plot_negative_log,x,y,_extra=_extra
  8 +; PURPOSE:
  9 +; plots an array in log scale including negative values in two half-plots
  10 +; INPUTS:
  11 +; x = x vector to plot
  12 +; y = y vector to plot
  13 +; OPTIONAL INPUT:
  14 +; ppositions = a 4-element vector for global plot position in the window
  15 +; dy = fractional distance between the two half-plots along y
  16 +; ACCEPTED KEY-WORDS:
  17 +; _extra is filtered and passed to cgplot
  18 +; EXAMPLES
  19 +;x=[0,1,2,3,4,7,12] & y=[1.e-2,2,-1,-2,-5,-10,-50.]
  20 +;dustem_plot_mlog,x,y,xtitle='x',ytitle='y',xrange=[-1,15],/xsty,yrange=[0.001,100],/ysty,ppositions=[0.3,0.2,0.8,0.9],dy=0.001
  21 +;x=lindgen(1000)/500. & y=sin(x*10)*exp(-x*2.)*1.e2
  22 +;dustem_plot_mlog,x,y,xtitle='x',ytitle='y',xrange=[-0.1,2.],/xsty,yrange=[0.001,100],/ysty
  23 +;
  24 +; OUTPUTS:
  25 +; None
  26 +; OPTIONAL OUTPUTS:
  27 +; None
  28 +; PROCEDURE AND SUBROUTINE USED
  29 +;
  30 +; COMMONS:
  31 +;
  32 +; SIDE EFFECTS:
  33 +; The two half plots are forced to have the same (reflected) y axis.
  34 +; MODIFICATION HISTORY:
  35 +; written 28-06-22 by Jean-Philippe Bernard
  36 +;-
  37 +
  38 +IF keyword_set(help) THEN BEGIN
  39 + doc_library,'dustem_plot_mlog'
  40 + goto,sortie
  41 +ENDIF
  42 +
  43 +defsysv,'!previous_yrange',exist=exist
  44 +IF not exist THEN defsysv,'!previous_yrange',ptr_new()
  45 +
  46 +indpos=where(y GT 0,countpos)
  47 +indneg=where(y LT 0,countneg)
  48 +maskpos=y*0
  49 +maskneg=y*0
  50 +maskpos[indpos]=1
  51 +maskneg[indneg]=1
  52 +
  53 +df_pos=find_ind(maskpos,1,count=count_pos_regions)
  54 +df_neg=find_ind(maskneg,1,count=count_neg_regions)
  55 +
  56 +Nx=1 & Ny=2
  57 +IF not keyword_set(ppositions) THEN BEGIN
  58 + x0=0.10 & y0=0.10
  59 + x1=0.90 & y1=0.90
  60 +ENDIF ELSE BEGIN
  61 + x0=ppositions[0] & y0=ppositions[1]
  62 + x1=ppositions[2] & y1=ppositions[3]
  63 +ENDELSE
  64 +dx=0.15 ;not used anywy for this plot
  65 +use_dy=0.01;.05
  66 +IF keyword_set(dy) THEN BEGIN
  67 + use_dy=dy
  68 +ENDIF
  69 +
  70 +pp=make_ppositions(x0,y0,x1,y1,dx,use_dy,Nx,Ny,xtit_plot=xtit_plot,ytit_plot=ytit_plot, $
  71 + noerase=noerase,xcharsize=xcharsize,ycharsize=ycharsize);,/silent)
  72 +
  73 +i=0L
  74 +IF countpos NE 0 THEN BEGIN
  75 + 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
  97 +
  98 +IF countneg NE 0 THEN BEGIN
  99 + 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
  108 + ENDIF
  109 +ENDIF
  110 +
  111 +sortie:
  112 +
  113 +;stop
  114 +
  115 +END
  116 +
  117 +
... ...
src/idl/dustem_plugin_freefree.pro
... ... @@ -112,7 +112,7 @@ CASE use_method OF
112 112 END
113 113 ENDCASE
114 114  
115   -scope='ADD_SED+ADD_QSED+ADD_USED'
  115 +scope='ADD_SED+ADD_POLSED'
116 116  
117 117 ;polarization this actually need to
118 118 polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
... ...
src/idl/dustem_plugin_mbbdy.pro
... ... @@ -52,7 +52,7 @@ w0=100. ; Theoretical wavelength (3THz) where optical depth equals unity
52 52 smallp=0.
53 53 psi=0.
54 54  
55   -scope='ADD_SED+ADD_QSED+ADD_USED'
  55 +scope='ADD_SED+ADD_POLSED'
56 56 paramtag=['Amp','T_MBB (K)','beta (Plaw_index)','p','Psi (deg)']
57 57  
58 58 IF keyword_set(key) THEN BEGIN
... ...
src/idl/dustem_plugin_mbbdy_isrf.pro
... ... @@ -108,7 +108,7 @@ output[*,1]=Q
108 108 output[*,2]=U
109 109  
110 110  
111   -scope='ADD_SED+ADD_QSED+ADD_USED'
  111 +scope='ADD_SED+ADD_POLSED'
112 112  
113 113  
114 114 the_end:
... ...
src/idl/dustem_plugin_mdfy_spinning_pol.pro
... ... @@ -91,7 +91,7 @@ out[*,2]=SpinningU
91 91  
92 92  
93 93  
94   -scope='ADD_QSED+ADD_USED'
  94 +scope='ADD_POLSED' ;replace this scope by ADD_POL (new scopes are : ADD_SED/ADD_POLSED/ADD_EXT/ADD_POLEXT)
95 95  
96 96  
97 97 return, out
... ...
src/idl/dustem_plugin_modify_dust_pol.pro
... ... @@ -56,7 +56,7 @@ IF keyword_set(key) THEN BEGIN
56 56 ind1=where(key EQ 1,count1)
57 57 ind2=where(key EQ 2,count2)
58 58 IF count1 NE 0 THEN smallp=val[ind1[0]] ; setting smallp from pd
59   - IF count2 NE 0 THEN psi=val[ind2[0]] ; setting psi from pd
  59 + IF count2 NE 0 THEN psi=val[ind2[0]] & !dustem_psi = psi ; setting psi from pd. !dustem_psi here helps for the plotting.
60 60 ENDIF
61 61  
62 62  
... ... @@ -80,7 +80,7 @@ out[*,0]=I
80 80 out[*,1]=Q
81 81 out[*,2]=U
82 82  
83   -scope='REPLACE_QSED+REPLACE_USED'
  83 +scope='REPLACE_POLSED'
84 84  
85 85 return, out
86 86  
... ...
src/idl/dustem_plugin_synchrotron.pro
... ... @@ -80,7 +80,7 @@ output[*,1]=Q
80 80 output[*,2]=U
81 81  
82 82  
83   -scope='ADD_SED+ADD_QSED+ADD_USED'
  83 +scope='ADD_SED+ADD_POLSED'
84 84  
85 85 the_end:
86 86 RETURN,output
... ...
src/idl/dustemcgwin_dataset.pro
... ... @@ -30,7 +30,7 @@ PRO dustemcgwin_dataset, st, prediction, dataset=dataset, norm=norm, refresh=ref
30 30  
31 31 ;######LIST OF THINGS NEEDED#################################################################
32 32 ;############################################################################################
33   -pospltxt = [position(0)+0.02,position(3)-0.05] ;hard-coded but we can find a way
  33 +if !run_pol then pospltxt = [position(0)+0.02,position(3)-0.02] else pospltxt = [position(0)+0.02,position(3)-0.05] ;hard-coded but we can find a way
34 34 wavs=dustem_get_wavelengths()
35 35 n_plgns = n_tags(*!dustem_plugin)
36 36 Ngrains=(*!dustem_params).Ngrains
... ... @@ -38,25 +38,44 @@ use_cols=dustem_grains_colors(Ngrains,/cgplot)
38 38 use_cols[1]='Cornflower'
39 39 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 40 spec = st.sed.em_tot * fact
41   -if !run_pol then specpol = st.polsed.em_tot * fact
  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 51 clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
43 52 scopes=tag_names((*!dustem_scope))
  53 +
44 54 IF scopes[0] NE 'NONE' THEN BEGIN
45 55 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
46 56 IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0]
47   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
48   - ENDFOR
49   - FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
50   - if !run_pol then begin
51   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
52   - endif
  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
  69 +
53 70 ENDFOR
  71 +
54 72 ENDIF
55 73 tgnms_extra = tag_names(_extra)
56 74 ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR')
57 75 ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR')
58 76 if ind_xr EQ -1 then xr=[1.00E+00,1.00E+05] else xr=(_extra.(ind_xr))
59 77 if ind_yr EQ -1 then yr=[5.00E-03,1.00E+08] else yr=(_extra.(ind_yr))
  78 +
60 79 ;############################################################################################
61 80 ;############################################################################################
62 81  
... ... @@ -96,16 +115,9 @@ if keyword_set(dataset) then begin
96 115 endif else begin ;when the data is present
97 116  
98 117 if keyword_set(norm) then begin
99   -
  118 +
100 119 if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
101 120  
102   - IF ct_filt NE 0 THEN BEGIN
103   - xx=((*!dustem_data.sed).wav)[idx_filt]
104   - yy=prediction[idx_filt]
105   - rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.
106   - cgoplot,xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
107   - 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'
108   - ENDIF
109 121  
110 122 IF ct_spec NE 0 THEN BEGIN
111 123 xx=((*!dustem_data.sed).wav)[idx_spec]
... ... @@ -113,9 +125,19 @@ if keyword_set(dataset) then begin
113 125 rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
114 126 cgoplot,xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
115 127 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'
116   - ENDIF
  128 + ENDIF
117 129  
118   - endif else begin ;The data points in the plot that remain unchanged
  130 +
  131 + IF ct_filt NE 0 THEN BEGIN
  132 + xx=((*!dustem_data.sed).wav)[idx_filt]
  133 + yy=prediction[idx_filt]
  134 + rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.
  135 + 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'
  137 + ENDIF
  138 +
  139 +
  140 + 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.
119 141  
120 142 xtit=textoidl('\lambda (\mum)')
121 143 if !run_pol then xtit = ''
... ... @@ -126,27 +148,22 @@ if keyword_set(dataset) then begin
126 148  
127 149  
128 150 endif else begin ; normal plot
129   -
130   - if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
131 151  
  152 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
132 153  
133 154 ;Plotting of the spectra of the dust species
134 155 FOR i=0L,Ngrains-1 DO BEGIN
135 156 cgoplot,st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
136 157 ENDFOR
137 158  
  159 +
138 160 ;Plotting of the plugins.
139 161 for i=0L,n_plgns-1 do begin
140   - cgoplot,st.sed.wav,(*(*!dustem_plugin).(i)),clrs_plgns=[i],pos=position,noerase=1,linestyle=2
  162 + cgoplot,st.sed.wav,(*(*!dustem_plugin).(i)),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
141 163 endfor
142   -
  164 +
143 165 ;PLotting of the interpolates corresponding to spectrum and filter points
144   - IF ct_filt NE 0 THEN BEGIN
145   - xx=((*!dustem_data.sed).wav)[idx_filt]
146   - yy=prediction[idx_filt]
147   - cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
148   - ENDIF
149   -
  166 +
150 167 IF ct_spec NE 0 THEN BEGIN
151 168  
152 169 xx=((*!dustem_data.sed).wav)[idx_spec]
... ... @@ -154,17 +171,27 @@ if keyword_set(dataset) then begin
154 171 cgoplot,xx,yy,color='red',pos=position,psym=7,syms=2,noerase=1
155 172 ENDIF
156 173  
157   - ;Plotting of the total dust emission spectrum
158   - cgoplot,st.sed.wav,spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
159 174  
  175 + IF ct_filt NE 0 THEN BEGIN
  176 + xx=((*!dustem_data.sed).wav)[idx_filt]
  177 + yy=prediction[idx_filt]
  178 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  179 + ENDIF
160 180  
  181 +
  182 +
  183 + ;Plotting of the total dust emission spectrum
  184 + cgoplot,st.sed.wav,spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  185 +
  186 +
  187 +
161 188 endif else begin ;The data points in the plot that remain unchanged.
162 189  
163 190 ;Spectrum points are treated before for plotting reasons.
164 191 if ct_spec ne 0 then begin
165 192  
166 193 ;Plotting of spectrum data points (to be fitted)
167   - cgplot,((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).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'
  194 + cgplot,((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).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'
168 195  
169 196 ;Plotting of the spectrum error points
170 197 rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
... ... @@ -173,25 +200,30 @@ if keyword_set(dataset) then begin
173 200 endif
174 201  
175 202 if ct_filt ne 0 then begin
  203 +
176 204 ;Plotting of filter data points (to be fitted) + testing for prior plotting
177 205 if ct_spec ne 0 then cgoplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).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 $
178   - cgplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).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
  206 + cgplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).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
  207 +
179 208  
180 209 ;Plotting of the filter error points
181 210 rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
182 211 cgerrplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt)-rms,((*!dustem_data.sed).values)(idx_filt)+rms,color='Dodger Blue'
183   -
  212 +
184 213 endif
  214 +
  215 +
185 216 ;Plotting of frequency axis
186   - 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)')
  217 + 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)')
  218 +
187 219 xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
188   - ;stop
  220 +
189 221 ;Locating all the hidden data points (spectrum+filter)
190 222 match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
191 223 idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
192   -
193   - if ct_hdnpts ne 0 then begin ;Hidden data points are present
194 224  
  225 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  226 +
195 227 ;Locating the hidden spectrum and filter data points
196 228 idx_filt_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
197 229 idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
... ... @@ -204,7 +236,7 @@ if keyword_set(dataset) then begin
204 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'
205 237  
206 238 ;Plotting of hidden filter data points
207   - cgoplot,((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn),pos=p_sed,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
  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
208 240  
209 241 ;Plotting of hidden filter error point
210 242 rms=3.*((*!dustem_show.sed).sigma)(idx_filt_hdn)/2.
... ... @@ -220,7 +252,7 @@ if keyword_set(dataset) then begin
220 252  
221 253 endelse
222 254  
223   - endelse ;
  255 + endelse
224 256  
225 257 end
226 258  
... ... @@ -248,7 +280,185 @@ if keyword_set(dataset) then begin
248 280  
249 281 end
250 282  
251   - 'QSED': begin
  283 + 'QSED': begin ; THE ONE I WILL BE WORKING ON
  284 +
  285 + ;SIGN-RELATED PARAMETERS/LOOPS HERE?
  286 + ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
  287 + varvar=where(specq LT 0, testsgq)
  288 + idx_filt=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM', ct_filt)
  289 + idx_spec=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM' , ct_spec)
  290 +
  291 +
  292 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  293 +
  294 + if keyword_set(nodata) then begin ;when the data is not present
  295 +
  296 + if keyword_set(norm) then begin ;normalized plot
  297 +
  298 + xtit=textoidl('\lambda (\mum)')
  299 + if !run_pol then xtit = ''
  300 + 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
  301 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  302 +
  303 + endif else begin ;normal plot
  304 +
  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
  307 + xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  308 +
  309 + endelse
  310 +
  311 +
  312 + endif else begin ;when the data is present
  313 + ;NOTA BENE: DIVDE THE POSITIONS BY A FACTOR :'(
  314 + if keyword_set(norm) then begin
  315 +
  316 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  317 +
  318 + ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  319 +
  320 + IF ct_filt NE 0 THEN BEGIN
  321 + xx=((*!dustem_data.qsed).wav)[idx_filt]
  322 + yy=prediction[idx_filt]
  323 + 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
  326 + 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 + ENDIF
  328 +
  329 +
  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 + endif else begin ;The data points in the plot that remain unchanged
  341 +
  342 + xtit=textoidl('\lambda (\mum)')
  343 + if !run_pol then xtit = ''
  344 + 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
  345 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  346 +
  347 + endelse
  348 +
  349 +
  350 + endif else begin ; normal plot - STOPPED HERE FOR QSED
  351 +
  352 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  353 +
  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
  360 +
  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
  366 +
  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
  373 +
  374 + ENDIF
  375 +
  376 + IF ct_spec NE 0 THEN BEGIN
  377 +
  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
  383 +
  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 +
  388 +
  389 +
  390 + endif else begin ;The data points in the plot that remain unchanged.
  391 +
  392 + ;Spectrum points are treated before for plotting reasons.
  393 + if ct_spec ne 0 then begin
  394 +
  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'
  402 +
  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
  408 +
  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 + endif else begin
  412 +
  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 $
  414 +
  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
  417 +
  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'
  421 +
  422 + 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
  426 + ;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 +
  431 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  432 +
  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)
  436 +
  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
  439 +
  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
  446 +
  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
  452 +
  453 +
  454 +
  455 + endelse
  456 +
  457 +
  458 +
  459 + endelse
  460 +
  461 + endelse ;
252 462  
253 463 end
254 464  
... ...
src/idl/dustemwrap_plot.pro
... ... @@ -83,8 +83,6 @@ cmdind_x = 0 ;for extinction
83 83 ;these following indices will be used to change the keep the same information in the _extra structure
84 84 ;this is an initial solution until I finish coding the _extra-filtering procedure.
85 85  
86   -
87   -
88 86 iswinsed = !dustemcgwin_id.sed EQ la_undef()
89 87 iswinext = !dustemcgwin_id.ext EQ la_undef()
90 88  
... ... @@ -96,7 +94,7 @@ if test_m then begin
96 94 ;Generating emission window and saving window ID
97 95  
98 96 if iswinsed then begin
99   - cgwindow, wtitle='DUSTEMWRAP v2.0 (EMISSION)', wback='grey';,wobject=winobj_m
  97 + if !run_pol then cgwindow,wxsize=1260,wysize=670,wtitle='DUSTEMWRAP v2.0 (EMISSION)' else cgwindow, wtitle='DUSTEMWRAP v2.0 (EMISSION)';, wback='grey';,wobject=winobj_m
100 98 winid_m = cgquery(dimensions=dim_m,/current) ;this has to be changed because the dimensions of this array change with the data sets present (extinction/emission).
101 99 !dustemcgwin_id.sed = winid_m
102 100  
... ... @@ -106,7 +104,7 @@ if test_m then begin
106 104 ;cgWindow_GetDefs,xsize=xsize,ysize=ysize
107 105 ;cgcontrol, resize=[xsize,ysize]
108 106 if !run_pol then begin
109   - ;cgwindow,wxsize=1260,wysize=670,wtitle='DUSTEMWRAP v2.0 (EMISSION)',wback='grey'
  107 + ;,wback='grey'
110 108  
111 109 ;position arrays for plot and normalized graph
112 110 ;there might be some problems with the 'math' here
... ... @@ -115,41 +113,17 @@ if test_m then begin
115 113 p_psed = [0.525,0.67,0.95,0.90]
116 114 ;p_spsed = [0.07,0.42,0.5,0.57]
117 115 ;p_psised = [,,,]
118   - p_qsed = [0.07,0.19,0.5,0.39]
  116 + p_qsed = [0.05,0.26,0.475,0.49] ;FIX THESE POSITIONS.
119 117 ;p_used = [,,,]
120 118 np_sed = [0.05,0.60,0.475,0.67]
121 119 ;np_psed = [0.525,0.60,0.95,0.67]
122   - np_qsed = [0.07,0.09,0.5,0.19]
  120 + np_qsed = [0.05,0.19,0.5,0.27]
123 121 ;np_used = [,,,]
124   -
125   - posp_sed = [0.07,0.87]
126   -; posp_psed =
127   -; posp_spsed =
128   -; posp_qsed =
129   -; posp_used =
130   -
131   - posnp_sed = [0.07,0.65]
132   -; posnp_psed =
133   -; posnp_spsed =
134   -; posnp_qsed =
135   -; posnp_used =
136   -;
137   -
  122 +
138 123 endif else begin
139 124 p_sed = [0.07,0.30,0.97,0.85]
140 125 np_sed = [0.07,0.10,0.97,0.30]
141   -
142   - posp_sed = [0.09,0.80]
143   -; posp_psed =
144   -; posp_spsed =
145   -; posp_qsed =
146   -; posp_used =
147   -
148   - posnp_sed = [0.09,0.25]
149   -; posnp_psed =
150   -; posnp_spsed =
151   -; posnp_qsed =
152   -; posnp_used =
  126 +
153 127 endelse
154 128  
155 129 ;Plotting of sed data axes (whether or not data is present)
... ... @@ -157,29 +131,34 @@ if test_m then begin
157 131  
158 132 cgcontrol, execute=0
159 133  
160   - if ~iswinsed then goto, zone1
161 134  
  135 +
  136 + ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
162 137 if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
163 138  
164 139 cgwindow,'dustemcgwin_dataset', st, dataset='SED', /nodata, position=p_sed, /addcmd, winid=winid_m, _extra=_extra
165 140 cgwindow,'dustemcgwin_dataset', st, dataset='SED', /norm, /nodata, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
166 141  
167 142 endif else begin ;SED exists
  143 + if ~iswinsed and test_sed then goto, zone1
168 144  
169 145 cgwindow,'dustemcgwin_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra
  146 +
170 147 cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  148 +
171 149 !dustemcgwin_ncmds.sed.pl = cmdind_m
172   - stop
173 150 zone1:
174 151 if ~iswinsed then begin
175 152 cmdind_m = !dustemcgwin_ncmds.sed.pl
176 153 cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
177 154 goto, zone2
178 155 endif
179   - 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
  156 +
  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
  158 +
180 159 cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
181 160 !dustemcgwin_ncmds.sed.nrm = cmdind_m
182   - stop
  161 +
183 162 zone2:
184 163 if ~iswinsed then begin
185 164 cmdind_m = !dustemcgwin_ncmds.sed.nrm
... ... @@ -188,105 +167,151 @@ if test_m then begin
188 167  
189 168 endelse
190 169  
191   -
192   - ;####################THIS IS THE OLD PART OF THE CODE. #################################
193   - ;#######################################################################################
194   -
195   -
196   -
197   -
198   - if ~!run_pol then goto, end_m
199   -
200   -
201   - if ~test_qsed then begin ; QSED data is not present (For completeness) # This is only valid when !run_pol=1
202   -
203   - xvar=dustem_get_wavelengths() ;supposedly does not modify the x axis range
204   - cgwindow,'cgplot',xvar,xvar,/nodata,/ylog,/xlog,/ys,xs=9,position=p_qsed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1
205   - cgwindow, 'cgaxis', xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10 & cmdind_m+=1
206   -
207   - ;Plotting of the title of the SED plot
208   - cgwindow,'xyouts',0.07,0.87,textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
209   -
210   - ;Plotting of the normalized SED plot
211   - cgwindow,'cgplot',xvar,xvar,/xlog,/ys,xs=1,position=np_qsed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1
212   -
213   - ;Plotting of the title of the normalized plot
214   - cgwindow,'xyouts',0.07,0.65,textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
215   -
216   - ;FORGOT THE PLOTTING OF THE TITLES. THIS SHOULD PROBABLY BE PLACED OUT.
217   -
218   - endif else begin ;QSED exists
219   -
220   - ;Locating filter and spectrum data points
221   - idx_filtq=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM',ct_filtq)
222   - idx_specq=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM',ct_specq)
223   -
224   - if ct_specq ne 0 then begin
225   -
226   - ;Plotting of spectrum data points (to be fitted)
227   - cgwindow,'cgplot',((*!dustem_data.qsed).wav)(idx_specq),((*!dustem_data.qsed).values)(idx_specq),/ylog,/xlog,/ys,xs=9,position=p_qsed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8,ytickformat='dstmwrp_exp' & cmdind_m+=1
228   - ;stop
229   -
230   - ;Plotting of the spectrum error points
231   - rms=3.*((*!dustem_data.qsed).sigma)(idx_specq)/2.
232   - cgwindow,'cgerrplot',((*!dustem_data.qsed).wav)(idx_specq),((*!dustem_data.qsed).values)(idx_specq)-rms,((*!dustem_data.qsed).values)(idx_specq)+rms,/addcmd,color='Powder Blue' & cmdind_m+=1
233   -
234   - endif
235   -
236   - if ct_filtq ne 0 then begin
237   -
238   - if ct_specq ne 0 then txtcmd = 'cgoplot' else txtcmd = 'cgplot'
239   - ;Plotting of filter data points (to be fitted) ;
240   - cgwindow,txtcmd,((*!dustem_data.qsed).wav)(idx_filtq),((*!dustem_data.qsed).values)(idx_filtq),/addcmd,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,position=p_qsed,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog & cmdind_m+=1
241   -
242   - ;Plotting of the filter error points
243   - rms=3.*((*!dustem_data.qsed).sigma)(idx_filtq)/2.;/dustem_sed(idx_filt)
244   - cgwindow,'cgerrplot',((*!dustem_data.qsed).wav)(idx_filtq),((*!dustem_data.qsed).values)(idx_filtq)-rms,((*!dustem_data.qsed).values)(idx_filtq)+rms,/addcmd,color='Dodger Blue' & cmdind_m+=1
245   -
246   - endif
247   - ;Plotting of frequency axis
248   - cgwindow, 'cgaxis', xaxis=1,xlog=1 ,xs=1,xminor=10, xticklen=0.05 ,xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)') & cmdind_m+=1
249   - ;stop
250   -
251   - ;Locating all the hidden data points (spectrum+filter)
252   - match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),fit_sedptsq,show_sedptsq ;only show_sedpts is needed
253   - idx_rmv_sedq=where(show_sedptsq eq -1, ct_hdnptsq) ; indices of the points to hide
254   -
255   - if ct_hdnptsq ne 0 then begin ;Hidden data points are present
256   -
257   - ;Locating the hidden spectrum and filter data points
258   - idx_filt_hdnq = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sedq) NE 'SPECTRUM',ct_filt_hdnq)
259   - idx_spec_hdnq = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sedq) EQ 'SPECTRUM',ct_spec_hdnq)
260   -
261   - ;Plotting of hidden spectrum data points
262   - cgwindow,'cgoplot',((*!dustem_show.qsed).wav)(idx_spec_hdnq),((*!dustem_show.qsed).values)(idx_spec_hdnq),position=p_qsed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1
263   -
264   - ;Plotting of hidden spectrum error points
265   - rms=3.*((*!dustem_show.qsed).sigma)(idx_spec_hdnq)/2.
266   - cgwindow,'cgerrplot',((*!dustem_show.qsed).wav)(idx_spec_hdnq),((*!dustem_show.qsed).values)(idx_spec_hdnq)-rms,((*!dustem_show.qsed).values)(idx_spec_hdnq)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1
267   -
268   - ;Plotting of hidden filter data points
269   - cgwindow,'cgoplot',((*!dustem_show.qsed).wav)(idx_filt_hdnq),((*!dustem_show.qsed).values)(idx_filt_hdnq),pos=p_qsed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1
270   -
271   - ;Plotting of hidden filter error point
272   - rms=3.*((*!dustem_show.qsed).sigma)(idx_filt_hdn)/2.
273   - cgwindow,'cgerrplot',((*!dustem_show.qsed).wav)(idx_filt_hdn),((*!dustem_show.qsed).values)(idx_filt_hdn)-rms,((*!dustem_show.qsed).values)(idx_filt_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1
274   -
275   - endif
276   -
277   - ;Plotting of the title of the SED plot
278   - cgwindow,'xyouts',0.07,0.87,textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
279   -
280   - ;Plotting of the normalized SED plot
281   - xvar=dustem_get_wavelengths()
282   - cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_qsed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1
283   -
284   - ;Plotting of the title of the normalized plot
285   - cgwindow,'xyouts',0.07,0.65,textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
286   -
287   - endelse
288   -
289   -
  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 +;
  229 +; if ~iswinsed and test_polsed then goto, zone7
  230 +;
  231 +; if ~test_polsed then begin ;Polsed is not present
  232 +;
  233 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLSED', /nodata, position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  234 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLSED', /norm, /nodata, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  235 +;
  236 +; endif else begin ;Polsed data is present
  237 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLSED', position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  238 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='POLSED', /refresh ,position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  239 +; !dustemcgwin_ncmds.polsed.pl = cmdind_m
  240 +; zone7:
  241 +; if ~iswinsed then begin
  242 +; cmdind_m = !dustemcgwin_ncmds.polsed.pl
  243 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='POLSED', /refresh ,position=p_psed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  244 +; goto, zone8
  245 +; endif
  246 +; 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 used too
  247 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='POLSED', /refresh, /norm,position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  248 +; !dustemcgwin_ncmds.polsed.nrm = cmdind_m
  249 +; zone8:
  250 +; if ~iswinsed then begin
  251 +; cmdind_m = !dustemcgwin_ncmds.polsed.nrm
  252 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='POLSED', /refresh, /norm,position=np_psed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  253 +; endif
  254 +;
  255 +; endelse
  256 +;
  257 +; if ~iswinsed and test_polfrac then goto, zone9
  258 +;
  259 +; if ~test_polfrac then begin ;Polfrac is not present
  260 +;
  261 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLFRAC', /nodata, position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  262 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLFRAC', /norm, /nodata, position=np_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  263 +;
  264 +; endif else begin ;Polfrac data is present
  265 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLFRAC', position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  266 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='POLFRAC', /refresh ,position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  267 +; !dustemcgwin_ncmds.polfrac.pl = cmdind_m
  268 +; zone9:
  269 +; if ~iswinsed then begin
  270 +; cmdind_m = !dustemcgwin_ncmds.polfrac.pl
  271 +; cgwindow,'dustemcgwin_dataset', st, dustem_polfrac, dataset='POLFRAC', /refresh ,position=p_spsed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  272 +; goto, zone10
  273 +; endif
  274 +; cgwindow,'dustemcgwin_dataset', st, dataset='POLFRAC', /norm, position=np_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
  275 +; cgwindow,'dustemcgwin_dataset', st, dustem_polfrac, dataset='POLFRAC', /refresh, /norm,position=np_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  276 +; !dustemcgwin_ncmds.polfrac.nrm = cmdind_m
  277 +; zone10:
  278 +; if ~iswinsed then begin
  279 +; cmdind_m = !dustemcgwin_ncmds.polfrac.nrm
  280 +; cgwindow,'dustemcgwin_dataset', st, dustem_polfrac, dataset='POLFRAC', /refresh, /norm,position=np_spsed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  281 +; endif
  282 +;
  283 +; endelse
  284 +;
  285 +; if ~iswinsed and test_psi_em then goto, zone11
  286 +;
  287 +; if ~test_psi_em then begin ;Polfrac is not present
  288 +;
  289 +; cgwindow,'dustemcgwin_dataset', st, dataset='PSI_EM', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  290 +; cgwindow,'dustemcgwin_dataset', st, dataset='PSI_EM', /norm, /nodata, position=np_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  291 +;
  292 +; endif else begin ;Polfrac data is present
  293 +; cgwindow,'dustemcgwin_dataset', st, dataset='PSI_EM', position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  294 +; cgwindow,'dustemcgwin_dataset', st, dustem_polsed, dataset='PSI_EM', /refresh ,position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  295 +; !dustemcgwin_ncmds.psi_em.pl = cmdind_m
  296 +; zone11:
  297 +; if ~iswinsed then begin
  298 +; cmdind_m = !dustemcgwin_ncmds.psi_em.pl
  299 +; cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='PSI_EM', /refresh ,position=p_psised, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  300 +; goto, zone12
  301 +; endif
  302 +; 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 used too
  303 +; cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='PSI_EM', /refresh, /norm,position=np_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  304 +; !dustemcgwin_ncmds.psi_em.nrm = cmdind_m
  305 +; zone12:
  306 +; if ~iswinsed then begin
  307 +; cmdind_m = !dustemcgwin_ncmds.psi_em.nrm
  308 +; cgwindow,'dustemcgwin_dataset', st, dustem_psi_em, dataset='PSI_EM', /refresh, /norm,position=np_psised, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  309 +; endif
  310 +;
  311 +; endelse
  312 +;
  313 +;
  314 +; endif
290 315  
291 316 end_m:
292 317  
... ... @@ -307,7 +332,7 @@ if test_m then begin
307 332 ;cgcontrol, update=0
308 333 ;cgcontrol, update=1
309 334 ;varr=cgquery(dimensions=dim_m,objectref=winobj_m)
310   -
  335 + stop
311 336  
312 337 endif
313 338 ;endif
... ...