Commit 916ea5d5170a767a2fae97d809bc87db39a4a23c

Authored by Jean-Philippe Bernard
2 parents be700cfc b5314324
Exists in master

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

Showing 2 changed files with 347 additions and 217 deletions   Show diff stats
src/idl/dustemcgwin_dataset.pro 0 → 100644
... ... @@ -0,0 +1,299 @@
  1 +PRO dustemcgwin_dataset, st, prediction, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position, _extra=_extra
  2 +
  3 +;######DRAFT HELP SECTION######
  4 +
  5 +;dataset = string. IE: 'SED','POLSED','QSED' etc...
  6 +;prediction = array. IE: 'dustem_sed', 'dustem_polsed' ... (discrete dustemwrap model predictions)
  7 +;norm = boolean. To indicate that it is the normalized plot.
  8 +;refresh = boolen. To indicate that the commands are the be replaced.
  9 +
  10 +;#1-loop on the data set and find its index in !dustem_data/!dustem_show
  11 +
  12 +;#prediction will be used whith refresh.
  13 +
  14 +;#you need to know that the data set has been plotted once in order to replace the commands. That is why you need the command index
  15 +
  16 +;first run requires to be known.
  17 +;To do so I will use this system variable '!dustemcgwin_ncmds' that I will only set after the first run
  18 +;.sed.pl and .sed.nrm will tell about the number of commands for each kind of plot.
  19 +;this will also interact with the refresh keyword.
  20 +
  21 +;except for when nodata is used, the 'prediction' array should always be present for errors not to occur.
  22 +
  23 +;YOU NEED THE INFORMATION INSIDE THE _EXTRA STRUCTURE
  24 +
  25 +;NB: this procedures uses both !dustem_data/!dustem_show to locate hidden filter/spectrum data points
  26 +
  27 +
  28 +;positions for xyouts on the plots - not using any widgets for now
  29 +;using same margins for (placement of xyouts plot titles (ie: I_nu, Q_nu, U_nu etc...)) normalized plots and normal ones.
  30 +
  31 +;######LIST OF THINGS NEEDED#################################################################
  32 +;############################################################################################
  33 +pospltxt = [position(0)+0.02,position(3)-0.05] ;hard-coded but we can find a way
  34 +wavs=dustem_get_wavelengths()
  35 +n_plgns = n_tags(*!dustem_plugin)
  36 +Ngrains=(*!dustem_params).Ngrains
  37 +use_cols=dustem_grains_colors(Ngrains,/cgplot)
  38 +use_cols[1]='Cornflower'
  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 +spec = st.sed.em_tot * fact
  41 +if !run_pol then specpol = st.polsed.em_tot * fact
  42 +clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
  43 +scopes=tag_names((*!dustem_scope))
  44 +IF scopes[0] NE 'NONE' THEN BEGIN
  45 + FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
  46 + 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
  53 + ENDFOR
  54 +ENDIF
  55 +tgnms_extra = tag_names(_extra)
  56 +ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR')
  57 +ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR')
  58 +if ind_xr EQ -1 then xr=[1.00E+00,1.00E+05] else xr=(_extra.(ind_xr))
  59 +if ind_yr EQ -1 then yr=[5.00E-03,1.00E+08] else yr=(_extra.(ind_yr))
  60 +;############################################################################################
  61 +;############################################################################################
  62 +
  63 +
  64 +
  65 +;NB: because of small issue you forgot in the main code. Add xtit=xtit when convenient
  66 +
  67 +if keyword_set(dataset) then begin
  68 +;!run_pol is implied for QSED/USED/POLSED etc...
  69 + Case strupcase(dataset) of
  70 +
  71 + 'SED': begin
  72 +
  73 + idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
  74 + idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
  75 +
  76 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  77 +
  78 + if keyword_set(nodata) then begin ;when the data is not present
  79 +
  80 + if keyword_set(norm) then begin ;normalized plot
  81 +
  82 + xtit=textoidl('\lambda (\mum)')
  83 + if !run_pol then xtit = ''
  84 + 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
  85 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  86 +
  87 + endif else begin ;normal plot
  88 +
  89 + 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
  90 + cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  91 + xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  92 +
  93 + endelse
  94 +
  95 +
  96 + endif else begin ;when the data is present
  97 +
  98 + if keyword_set(norm) then begin
  99 +
  100 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  101 +
  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 +
  110 + IF ct_spec NE 0 THEN BEGIN
  111 + xx=((*!dustem_data.sed).wav)[idx_spec]
  112 + yy=prediction[idx_spec]
  113 + rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
  114 + cgoplot,xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  115 + 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
  117 +
  118 + endif else begin ;The data points in the plot that remain unchanged
  119 +
  120 + xtit=textoidl('\lambda (\mum)')
  121 + if !run_pol then xtit = ''
  122 + 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
  123 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  124 +
  125 + endelse
  126 +
  127 +
  128 + endif else begin ; normal plot
  129 +
  130 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  131 +
  132 +
  133 + ;Plotting of the spectra of the dust species
  134 + FOR i=0L,Ngrains-1 DO BEGIN
  135 + cgoplot,st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
  136 + ENDFOR
  137 +
  138 + ;Plotting of the plugins.
  139 + 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
  141 + endfor
  142 +
  143 + ;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 +
  150 + IF ct_spec NE 0 THEN BEGIN
  151 +
  152 + xx=((*!dustem_data.sed).wav)[idx_spec]
  153 + yy=prediction[idx_spec]
  154 + cgoplot,xx,yy,color='red',pos=position,psym=7,syms=2,noerase=1
  155 + ENDIF
  156 +
  157 + ;Plotting of the total dust emission spectrum
  158 + cgoplot,st.sed.wav,spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  159 +
  160 +
  161 + endif else begin ;The data points in the plot that remain unchanged.
  162 +
  163 + ;Spectrum points are treated before for plotting reasons.
  164 + if ct_spec ne 0 then begin
  165 +
  166 + ;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'
  168 +
  169 + ;Plotting of the spectrum error points
  170 + rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
  171 + cgerrplot,((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec)-rms,((*!dustem_data.sed).values)(idx_spec)+rms,color='Powder Blue'
  172 +
  173 + endif
  174 +
  175 + if ct_filt ne 0 then begin
  176 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  177 + 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
  179 +
  180 + ;Plotting of the filter error points
  181 + rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
  182 + 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 +
  184 + endif
  185 + ;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)')
  187 + xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1
  188 + ;stop
  189 + ;Locating all the hidden data points (spectrum+filter)
  190 + match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
  191 + 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 +
  195 + ;Locating the hidden spectrum and filter data points
  196 + idx_filt_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  197 + idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  198 +
  199 + ;Plotting of hidden spectrum data points
  200 + 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
  201 +
  202 + ;Plotting of hidden spectrum error points
  203 + rms=3.*((*!dustem_show.sed).sigma)(idx_spec_hdn)/2.
  204 + 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 +
  206 + ;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
  208 +
  209 + ;Plotting of hidden filter error point
  210 + rms=3.*((*!dustem_show.sed).sigma)(idx_filt_hdn)/2.
  211 + 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'
  212 +
  213 + endif
  214 +
  215 +
  216 +
  217 + endelse
  218 +
  219 +
  220 +
  221 + endelse
  222 +
  223 + endelse ;
  224 +
  225 + end
  226 +
  227 + 'EXT': begin
  228 +
  229 + end
  230 +
  231 + 'POLEXT': begin
  232 +
  233 + end
  234 +
  235 + 'POLSED': begin
  236 +
  237 + end
  238 +
  239 + 'POLFRAC': begin
  240 +
  241 + end
  242 +
  243 + 'PSI_EM': begin
  244 +
  245 + end
  246 +
  247 + 'PSI_EXT': begin
  248 +
  249 + end
  250 +
  251 + 'QSED': begin
  252 +
  253 + end
  254 +
  255 + 'USED': begin
  256 +
  257 + end
  258 +
  259 + 'QEXT': begin
  260 +
  261 + end
  262 +
  263 + 'UEXT': begin
  264 +
  265 + end
  266 +
  267 + endcase
  268 +
  269 +
  270 +endif
  271 +
  272 +
  273 +
  274 +
  275 +
  276 +
  277 +
  278 +
  279 +
  280 +
  281 +
  282 +
  283 +
  284 +
  285 +
  286 +
  287 +
  288 +
  289 +
  290 +
  291 +
  292 +
  293 +
  294 +
  295 +
  296 +
  297 +
  298 +
  299 +END
... ...
src/idl/dustemwrap_plot.pro
... ... @@ -48,29 +48,29 @@ ENDIF
48 48  
49 49 test_sed = isa(!dustem_show.sed)
50 50 test_ext = isa(!dustem_show.ext)
51   -test_polext = isa(!dustem_show.polext)
52   -test_polsed = isa(!dustem_show.polsed)
53   -test_polfrac = isa(!dustem_show.polfrac)
54   -test_psi_em = isa(!dustem_show.psi_em)
55   -test_psi_ext = isa(!dustem_show.psi_ext)
56   -test_qsed = isa(!dustem_show.qsed)
57   -test_used = isa(!dustem_show.used)
58   -test_qext = isa(!dustem_show.qext)
59   -test_uext = isa(!dustem_show.uext)
60   -
61   -
  51 +if !run_pol then begin
  52 + test_polext = isa(!dustem_show.polext)
  53 + test_polsed = isa(!dustem_show.polsed)
  54 + test_polfrac = isa(!dustem_show.polfrac)
  55 + test_psi_em = isa(!dustem_show.psi_em)
  56 + test_psi_ext = isa(!dustem_show.psi_ext)
  57 + test_qsed = isa(!dustem_show.qsed)
  58 + test_used = isa(!dustem_show.used)
  59 + test_qext = isa(!dustem_show.qext)
  60 + test_uext = isa(!dustem_show.uext)
  61 + test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em
  62 + test_x = test_ext or test_polext or test_qext or test_uext or test_psi_ext
  63 +endif else begin
  64 + test_m = test_sed
  65 + test_x = test_ext
  66 +endelse
62 67 ;testing on the fitting of emission vs extinction data
63   -test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em
64   -test_x = test_ext or test_polext or test_qext or test_uext or test_psi_ext
65 68  
66   -;there are three display layouts in one-window mode: emission, extinction and emission+extinction
67   -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
68   -spec = st.sed.em_tot * fact
69   -if !run_pol then specpol = st.polsed.em_tot * fact
  69 +;I could create a procedure for colors for the plugins but I am just going to define an array for now
  70 +
  71 +;clrs_plgns = (colortable(38))(uniq(colortable(38))) ;CT RAINBOW18
70 72  
71   -Ngrains=(*!dustem_params).Ngrains
72   -use_cols=dustem_grains_colors(Ngrains,/cgplot)
73   -use_cols[1]='Cornflower'
  73 +n_plgns = n_tags(*!dustem_plugin)
74 74  
75 75 ;I have decided to keep track of the command index manually as I did not find any command online that does this.
76 76 cmdind_m = 0 ;for emission
... ... @@ -79,30 +79,11 @@ cmdind_x = 0 ;for extinction
79 79 ;#YOU NEED TO REPLACE THE QSED AND USED SCOPES WITH A SINGLE POLSED ONE
80 80  
81 81 ;ADDING PLUGIN(S) TO SPECTRUM----------------
82   -scopes=tag_names((*!dustem_scope))
83   -IF scopes[0] NE 'NONE' THEN BEGIN
84   -
85   - FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
86   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0]
87   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
88   - ENDFOR
89   - FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
90   - if !run_pol then begin
91   - IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
92   - endif
93   - ENDFOR
94   -
95   -
96   -ENDIF
97 82  
98 83 ;these following indices will be used to change the keep the same information in the _extra structure
99 84 ;this is an initial solution until I finish coding the _extra-filtering procedure.
100 85  
101   -tgnms_extra = tag_names(_extra)
102   -ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR')
103   -ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR')
104   -if ind_xr EQ -1 then xr=[1.00E+00,1.00E+05] else xr=(_extra.(ind_xr))
105   -if ind_yr EQ -1 then yr=[5.00E-03,1.00E+08] else yr=(_extra.(ind_yr))
  86 +
106 87  
107 88 iswinsed = !dustemcgwin_id.sed EQ la_undef()
108 89 iswinext = !dustemcgwin_id.ext EQ la_undef()
... ... @@ -173,200 +154,50 @@ if test_m then begin
173 154  
174 155 ;Plotting of sed data axes (whether or not data is present)
175 156 plotsym,0,/fill ;you might need to execute this again. hmm...
176   - ;stop
177 157  
178 158 cgcontrol, execute=0
179 159  
180   - ;cgcontrol, update=0
181   - ;stop
182   - ;cgcontrol, update=0
183 160 if ~iswinsed then goto, zone1
184 161  
185 162 if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
186 163  
187   - xvar=dustem_get_wavelengths() ;supposedly does not modify the x axis range
188   - cgwindow,'cgplot',xvar,xvar,/nodata,/ylog,/xlog,/ys,xs=9,position=p_sed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8
189   - 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
190   -
191   - ;Plotting of the title of the SED plot
192   - cgwindow,'xyouts',posp_sed[0],posp_sed[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
  164 + cgwindow,'dustemcgwin_dataset', st, dataset='SED', /nodata, position=p_sed, /addcmd, winid=winid_m, _extra=_extra
  165 + cgwindow,'dustemcgwin_dataset', st, dataset='SED', /norm, /nodata, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
193 166  
194   - ;Plotting of the normalized SED plot
195   - cgwindow,'cgplot',xvar,xvar,/xlog,/ys,xs=1,position=np_sed,/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
196   -
197   - ;Plotting of the title of the normalized plot
198   - cgwindow,'xyouts',posnp_sed[0],posnp_sed[1],textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
199   -
200   - ;FORGOT THE PLOTTING OF THE TITLES. THIS SHOULD PROBABLY BE PLACED OUT.
201   -
202 167 endif else begin ;SED exists
203 168  
204   - ;Locating filter and spectrum data points
205   - idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
206   - idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
207   -
208   - if ct_spec ne 0 then begin
209   -
210   - ;Plotting of spectrum data points (to be fitted)
211   - cgwindow,'cgplot',((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec),/ylog,/xlog,/ys,xs=9,position=p_sed,/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'
212   - ;stop
213   -
214   - ;Plotting of the spectrum error points
215   - rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
216   - cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec)-rms,((*!dustem_data.sed).values)(idx_spec)+rms,/addcmd,color='Powder Blue' & cmdind_m+=1
217   -
218   - endif
219   -
220   - if ct_filt ne 0 then begin
221   -
222   - if ct_spec ne 0 then txtcmd = 'cgoplot' else txtcmd = 'cgplot' & cmdind_m-=1
223   - ;Plotting of filter data points (to be fitted) ;
224   - cgwindow,txtcmd,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt),/addcmd,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,position=p_sed,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog & cmdind_m+=1;,xtick_get=hh
225   -
226   - ;Plotting of the filter error points
227   - rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
228   - cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt)-rms,((*!dustem_data.sed).values)(idx_filt)+rms,/addcmd,color='Dodger Blue' & cmdind_m+=1
229   -
230   - endif
231   - ;Plotting of frequency axis
232   - 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
233   - ;stop
234   - ;Locating all the hidden data points (spectrum+filter)
235   - match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed
236   - idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
237   -
238   - if ct_hdnpts ne 0 then begin ;Hidden data points are present
239   -
240   - ;Locating the hidden spectrum and filter data points
241   - idx_filt_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
242   - idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
243   -
244   - ;Plotting of hidden spectrum data points
245   - cgwindow,'cgoplot',((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_hdn),position=p_sed,/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
246   -
247   - ;Plotting of hidden spectrum error points
248   - rms=3.*((*!dustem_show.sed).sigma)(idx_spec_hdn)/2.
249   - cgwindow,'cgerrplot',((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_hdn)-rms,((*!dustem_show.sed).values)(idx_spec_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1
250   -
251   - ;Plotting of hidden filter data points
252   - cgwindow,'cgoplot',((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn),pos=p_sed,/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
253   -
254   - ;Plotting of hidden filter error point
255   - rms=3.*((*!dustem_show.sed).sigma)(idx_filt_hdn)/2.
256   - cgwindow,'cgerrplot',((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn)-rms,((*!dustem_show.sed).values)(idx_filt_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1
257   -
258   - endif
259   -
260   - ;Plotting of the title of the SED plot
261   - cgwindow,'xyouts',posp_sed[0],posp_sed[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m
262   - ;Plotting of the title of the normalized plot
263   - cgwindow,'xyouts',posnp_sed[0],posnp_sed[1],textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1
264   - ;stop
265   -
266   -
267   - ;create counter here!!
268   - if iswinsed then !dustemcgwin_ncmds.sed.ct_z1 = cmdind_m
  169 + cgwindow,'dustemcgwin_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra
  170 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  171 + !dustemcgwin_ncmds.sed.pl = cmdind_m
  172 + stop
269 173 zone1:
270 174 if ~iswinsed then begin
271   - cmdind_m = !dustemcgwin_ncmds.sed.ct_z1
272   - idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
273   - idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
  175 + cmdind_m = !dustemcgwin_ncmds.sed.pl
  176 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh ,position=p_sed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  177 + goto, zone2
274 178 endif
275   - ;Plotting of the spectra of the dust species
276   - FOR i=0L,Ngrains-1 DO BEGIN
277   - ;if i EQ 0 then txtcmd='cgplot' else txtcmd = 'cgoplot'
278   - cmdind_m+=1
279   - if iswinsed then cgwindow,'cgoplot',st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],position=p_sed,/addcmd,noerase=1,winid=winid_m else $
280   - cgwindow,'cgoplot',st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],position=p_sed,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m
281   - ENDFOR
282   -
283   - ;Plotting of the total dust emission spectrum
284   - if iswinsed then begin
285   - cgwindow,'cgoplot',st.sed.wav,spec,position=p_sed,/addcmd,noerase=1,winid=winid_m
286   - cmdind_m+=1
287   - endif else begin
288   - cmdind_m+=1
289   - cgwindow,'cgoplot',st.sed.wav,spec,position=p_sed,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m
290   - endelse
291   -
292   - ;PLotting of the interpolates corresponding to spectrum and filter points
293   - IF ct_filt NE 0 THEN BEGIN
294   - ;plotsym,8
295   - xx=((*!dustem_data.sed).wav)[idx_filt]
296   - yy=dustem_sed[idx_filt]
297   - if iswinsed then begin
298   - cgwindow,'cgoplot',xx,yy,color='red',psym=6,syms=2,noerase=1,/addcmd,winid=winid_m
299   - cmdind_m+=1
300   - endif else begin
301   - cmdind_m+=1
302   - cgwindow,'cgoplot',xx,yy,color='red',psym=6,syms=2,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m
303   - endelse
304   - ENDIF
305   - ;stop
306   - IF ct_spec NE 0 THEN BEGIN
307   - ;plotsym,0
308   - xx=((*!dustem_data.sed).wav)[idx_spec]
309   - yy=dustem_sed[idx_spec]
310   - if iswinsed then begin
311   - cgwindow,'cgoplot',xx,yy,color='red',psym=7,syms=2,noerase=1,/addcmd,winid=winid_m
312   - cmdind_m+=1
313   - endif else begin
314   - cmdind_m+=1
315   - cgwindow,'cgoplot',xx,yy,color='red',psym=7,syms=2,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m
316   - endelse
317   - ENDIF
318   - ;stop
319   - if iswinsed then begin
320   - xvar=dustem_get_wavelengths()
321   - ;plotsym,0,/fill
322   - cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_sed,/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
323   - endif else begin
324   - cmdind_m += 1
325   - endelse
326   -
327   -; ;Plotting of the normalized SED plot
328   -; xvar=dustem_get_wavelengths()
329   -; ;plotsym,0,/fill
330   -; cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_sed,/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
331   -; ;stop
332   - IF ct_filt NE 0 THEN BEGIN
333   - xx=((*!dustem_data.sed).wav)[idx_filt]
334   - yy=dustem_sed[idx_filt]
335   - rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.
336   - if iswinsed then begin
337   - cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/addcmd,winid=winid_m,pos=np_sed & cmdind_m+=1
338   - cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_filt),(((*!dustem_data.sed).values)[idx_filt]-rms)/yy,(((*!dustem_data.sed).values)[idx_filt]+rms)/yy,/addcmd,color='Dodger Blue' & cmdind_m+=1
339   - endif else begin
340   - cmdind_m+=1 & cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m,pos=np_sed
341   - cmdind_m+=1 & cgwindow,'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',/replacecmd, cmdindex=cmdind_m
342   - endelse
343   - ENDIF
344   -
345   - IF ct_spec NE 0 THEN BEGIN
346   - ;plotsym,0,/fill
347   - xx=((*!dustem_data.sed).wav)[idx_spec]
348   - yy=dustem_sed[idx_spec]
349   - rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
350   - if iswinsed then begin
351   - cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Dodger Blue',psym=16,syms=0.8,noerase=1,/addcmd,winid=winid_m & cmdind_m+=1
352   - cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),(((*!dustem_data.sed).values)[idx_spec]-rms)/yy,(((*!dustem_data.sed).values)[idx_spec]+rms)/yy,/addcmd,color='Dodger Blue' & cmdind_m+=1
353   - endif else begin
354   - cmdind_m+=1 & cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Dodger Blue',psym=16,syms=0.8,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m
355   - cmdind_m+=1 & cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),(((*!dustem_data.sed).values)[idx_spec]-rms)/yy,(((*!dustem_data.sed).values)[idx_spec]+rms)/yy,color='Dodger Blue',/replacecmd,cmdindex=cmdind_m
356   - endelse
357   -
358   - ENDIF
359   -
360   -
361   - ;cgwindow,'cgoplot',((*!dustem_show.sed).wav),((*!dustem_show.sed).values)/dustem_sed,/xlog,/ys,xs=1,position=np_sed,/addcmd,noerase=1,color='Dodger Blue',psym=8
362   -
363   -
364   - ;,winid=winid_m
  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
  180 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  181 + !dustemcgwin_ncmds.sed.nrm = cmdind_m
  182 + stop
  183 + zone2:
  184 + if ~iswinsed then begin
  185 + cmdind_m = !dustemcgwin_ncmds.sed.nrm
  186 + cgwindow,'dustemcgwin_dataset', st, dustem_sed, dataset='SED', /refresh, /norm,position=np_sed, winid=winid_m, _extra=_extra,/replacecmd,cmdindex=cmdind_m
  187 + endif
365 188  
366 189 endelse
367 190  
  191 +
  192 + ;####################THIS IS THE OLD PART OF THE CODE. #################################
  193 + ;#######################################################################################
  194 +
  195 +
  196 +
  197 +
368 198 if ~!run_pol then goto, end_m
369   -
  199 +
  200 +
370 201 if ~test_qsed then begin ; QSED data is not present (For completeness) # This is only valid when !run_pol=1
371 202  
372 203 xvar=dustem_get_wavelengths() ;supposedly does not modify the x axis range
... ...