Commit c1c1dd83dcefad9e68fd307454c6f427be19deab

Authored by Annie Hughes
2 parents 1140d8da 7d129a82
Exists in master

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

src/idl/dustem_init.pro
... ... @@ -244,25 +244,26 @@ defsysv, '!dustem_version',version ;This is the current dustemwrap version
244 244  
245 245 ;NB: #This is definitely not a robust way to handle the _extra tags but it's a primariy workaround for the plotting tags of the data sets.
246 246  
247   -defsysv, '!dustem_plot_extra', { $
248   -
249   - sed: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
250   - qsed: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
251   - used: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
252   - polsed: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
253   - polfrac: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
254   - psi_em: {pl:{xr:[0,0], yr:[-90,90],xlog:1, ylog:0}} , $ ;
255   - ext: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
256   - qext: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
257   - uext: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
258   - polext: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
259   - fpolext: {pl:{xr:[0,0], yr:[0,0],xlog:1, ylog:1},nrm:{xr:[0,0], yr:[0,0],xlog:1, ylog:0}}, $ ;
260   - psi_ext: {pl:{xr:[0,0], yr:[-90,90],xlog:1, ylog:0}} , $ ;
261   - title : 'DUSTEMWRAP '+'('+!dustem_version.version+') '+'Spectral Energy Distribution' $ ; default title if no title is specified
262   -
  247 +defsysv, '!dustem_plot_range', { $
  248 +
  249 + sed: {xr:[1.,5.0e5], yr:[5e-8,1.00e6]}, $ ;
  250 + qsed: {xr:[1.,5.0e5], yr:[5e-8,1.00e6]}, $ ;
  251 + used: {xr:[1.,5.0e5], yr:[5e-8,1.00e6]}, $ ;
  252 + polsed: {xr:[1.,5.0e5], yr:[5e-8,1.00e6]}, $ ;
  253 + polfrac: {xr:[1.,5.0e5], yr:[1.00E-04,50.00]}, $ ;
  254 + psi_em: {xr:[1.,5.0e5], yr:[-90.,90.]}, $ ;
  255 + ext: {xr:[0.01,30], yr:[5.00E-8,10]}, $ ;
  256 + qext: {xr:[0.01,30], yr:[5.00E-8,10]}, $ ;
  257 + uext: {xr:[0.01,30], yr:[5.00E-8,10]}, $ ;
  258 + polext: {xr:[0.01,30], yr:[5.00E-8,10]}, $ ;
  259 + fpolext: {xr:[0.01,30], yr:[1.00E-04,10.00]}, $ ;
  260 + psi_ext: {xr:[0.01,30], yr:[-90.,90.]}, $ ;
  261 + title_m : 'DUSTEMWRAP '+'('+!dustem_version.version+') '+'Spectral Energy Distribution', $ ; default title if no title is specified
  262 + title_x : 'DUSTEMWRAP '+'('+!dustem_version.version+') '+'Dust Optical Depth' $
263 263 }
264 264  
265 265  
  266 +
266 267 defsysv, '!dustem_mlog', 0 ;necessary for the plotting of negative values on the axis in dstmwrp_exp.pro
267 268  
268 269 ;###################################################################
... ...
src/idl/dustem_mpfit_data.pro
... ... @@ -154,9 +154,9 @@ print, p_dim
154 154  
155 155 ;JPB: What if _extra.xr does not exist then ?
156 156 IF !dustem_noobj THEN BEGIN
157   - dustemwrap_plot_noobj,p_dim,stp,xr=_extra.xrange,/xstyle,yr=_extra.yrange,/ysty,/ylog,/xlog,title=_extra.title
  157 + dustemwrap_plot_noobj,p_dim,stp,/xstyle,/ysty,/ylog,/xlog
158 158 ENDIF ELSE BEGIN
159   - dustemwrap_plot,p_dim,stp,xr=_extra.xrange,/xstyle,yr=_extra.yrange,/ysty,/ylog,/xlog,title=_extra.title
  159 + dustemwrap_plot,p_dim,stp,/xstyle,/ysty,/ylog,/xlog
160 160 ENDELSE
161 161  
162 162 RETURN, p_dim
... ...
src/idl/dustem_mpfit_run.pro
... ... @@ -195,8 +195,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
195 195 IF !run_pol and !run_lin THEN BEGIN
196 196  
197 197 dustem_polsed = dustem_compute_polsed(p_dim,st,P_spec,SP_spec,dustem_polfrac,dustem_sed=dustem_sed)
198   -
199   -
  198 +
200 199 ENDIF
201 200 END
202 201  
... ...
src/idl/dustem_plot_dataset.pro 0 โ†’ 100644
... ... @@ -0,0 +1,3575 @@
  1 +PRO dustem_plot_dataset, st, dustem_interp, dustem_spec, extra_spec, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position,positive_only=positive_only, negative_only=negative_only, _extra=_extra, help=help
  2 +
  3 +
  4 +;+
  5 +; NAME:
  6 +; dustem_plot_dataset
  7 +; PURPOSE:
  8 +; Allows the plotting of a (several) dataset(s)
  9 +; CATEGORY:
  10 +; DustEMWrap
  11 +; CALLING SEQUENCE:
  12 +; dustem_plot_dataset, st, dustem_interp, dustem_spec, extra_spec, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position,positive_only=positive_only, negative_only=negative_only, _extra=_extra
  13 +; INPUTS:
  14 +; p_dim
  15 +; OPTIONAL INPUT PARAMETERS:
  16 +; st
  17 +; dustem_interp
  18 +; dustem_spec
  19 +; extra_spec : used only in the plotting of polfrac and the parameters/plugins
  20 +; dataset=dataset
  21 +; norm=norm
  22 +; refresh=refresh : when used it plots the part of the dataset that changes with each mpfit iteration. Otherwhise it plots the data that does not wary with the mpfit iteration.
  23 +; nodata=nodata
  24 +; position=position
  25 +; positive_only=positive_only
  26 +; negative_only=negative_only
  27 +; OUTPUTS:
  28 +; NONE
  29 +; OPTIONAL OUTPUT PARAMETERS:
  30 +;
  31 +
  32 +; ACCEPTED KEY-WORDS:
  33 +; help
  34 +; COMMON BLOCKS:
  35 +; None
  36 +; SIDE EFFECTS:
  37 +; Does a plot
  38 +; RESTRICTIONS:
  39 +; The DustEM fortran code must be installed
  40 +; The DustEMWrap IDL code must be installed
  41 +; PROCEDURES AND SUBROUTINES USED:
  42 +;
  43 +; EXAMPLES
  44 +;
  45 +; MODIFICATION HISTORY:
  46 +; Written by Ilyes Choubani
  47 +; Evolution details on the DustEMWrap gitlab.
  48 +;-
  49 +
  50 +IF keyword_set(help) THEN BEGIN
  51 + doc_library,'dustem_plot_dataset'
  52 + goto,the_end
  53 +END
  54 +
  55 +
  56 +if !run_pol then begin
  57 + if isa(position) then begin
  58 + if keyword_set(norm) then pospltxt = [position(0)+0.02,position(3)-0.02] else pospltxt = [position(0)+0.02,position(3)-0.03]
  59 + endif
  60 +endif else begin
  61 + if isa(position) then pospltxt = [position(0)+0.02,position(3)-0.05] ;hard-coded but we can find a way
  62 +endelse
  63 +
  64 +wavs=dustem_get_wavelengths()
  65 +n_plgns = n_tags(*!dustem_plugin)
  66 +Ngrains=(*!dustem_params).Ngrains
  67 +use_cols=dustem_grains_colors(Ngrains,/cgplot)
  68 +use_cols[1]='Cornflower'
  69 +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
  70 +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.
  71 +
  72 +clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
  73 +;NB: plugins need to have different colors for extinction because they are not the same plugins. New array required.
  74 +
  75 +scopes=tag_names((*!dustem_plugin))
  76 +tgnms_extra = tag_names(_extra)
  77 +
  78 +
  79 +frmt0='(A46)'
  80 +frmt1='(1E11.4)'
  81 +frmt2='(10F10.2)'
  82 +
  83 +
  84 +
  85 +if keyword_set(dataset) then begin
  86 +;!run_pol is implied for QSED/USED/POLSED etc...
  87 + Case strupcase(dataset) of
  88 +
  89 + 'SED': begin
  90 +
  91 + ;This test will have to change. It will now depend on the content of the new system variable
  92 +
  93 + ;SETTING THE PLOT RANGE
  94 + xr = !dustem_plot_range.sed.xr
  95 + yr = !dustem_plot_range.sed.yr
  96 +
  97 +
  98 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  99 + vectw=10^vectw[1:*]
  100 + vectw=[wavs,vectw]
  101 + vectx=vectw*0+1
  102 +
  103 + idx_filt=where((*(*!dustem_data).sed).filt_names NE 'SPECTRUM',ct_filt)
  104 + idx_spec=where((*(*!dustem_data).sed).filt_names EQ 'SPECTRUM',ct_spec)
  105 +
  106 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  107 +
  108 + if keyword_set(nodata) then begin ;when the data is not present
  109 +
  110 + if keyword_set(norm) then begin ;normalized plot
  111 +
  112 + xtit=textoidl('\lambda (\mum)')
  113 + if !run_pol then xtit = ''
  114 + cgplot,vectw,vectx,/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
  115 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  116 +
  117 + endif ;else begin ;normal plot
  118 +
  119 + if not keyword_set(norm) then begin
  120 + ;/NODATA
  121 + 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
  122 + axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
  123 + xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  124 +
  125 + ;endelse
  126 + endif
  127 +
  128 + endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
  129 + if not keyword_set(nodata) then begin
  130 + if keyword_set(norm) then begin
  131 +
  132 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  133 +
  134 + IF ct_spec NE 0 THEN BEGIN
  135 + xx=((*(*!dustem_data).sed).wav)[idx_spec]
  136 + yy=dustem_interp[idx_spec]
  137 + rms=3.*((*(*!dustem_data).sed).sigma)(idx_spec)/2.
  138 + cgoplot,xx,((*(*!dustem_data).sed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  139 + 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'
  140 + ENDIF
  141 +
  142 + IF ct_filt NE 0 THEN BEGIN
  143 + xx=((*(*!dustem_data).sed).wav)[idx_filt]
  144 + yy=dustem_interp[idx_filt]
  145 + rms=3.*((*(*!dustem_data).sed).sigma)(idx_filt)/2.
  146 + cgoplot,xx,((*(*!dustem_data).sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
  147 + 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
  148 + ENDIF
  149 +
  150 +
  151 + 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.
  152 + ;stop
  153 +
  154 + if not keyword_set(refresh) then begin
  155 + ;stop
  156 +
  157 + xtit=textoidl('\lambda (\mum)')
  158 + if !run_pol then begin
  159 + xtit = ''
  160 + xtickformat='(A1)'
  161 + endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
  162 +
  163 + cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  164 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  165 +
  166 + ;endelse
  167 + endif
  168 +
  169 +
  170 + endif ;else begin ; normal plot
  171 + if not keyword_set(norm) then begin
  172 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  173 +
  174 + ;Plotting of the spectra of the dust species
  175 + FOR i=0L,Ngrains-1 DO BEGIN
  176 + cgoplot,st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
  177 + ENDFOR
  178 +
  179 +
  180 + ;Plotting of the plugins.
  181 + for i=0L,n_plgns-1 do begin
  182 +
  183 + if isa((*!dustem_plugin).(0).spec) then begin
  184 +
  185 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_SED') THEN begin
  186 + cgoplot,st.sed.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  187 + ENDIF
  188 +
  189 + endif
  190 +
  191 + endfor
  192 +
  193 + ;PLotting of the interpolates corresponding to spectrum and filter points
  194 +
  195 + IF ct_spec NE 0 THEN BEGIN
  196 +
  197 + xx=((*(*!dustem_data).sed).wav)[idx_spec]
  198 + yy=dustem_interp[idx_spec]
  199 + cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1
  200 + ENDIF
  201 +
  202 +
  203 + IF ct_filt NE 0 THEN BEGIN
  204 + xx=((*(*!dustem_data).sed).wav)[idx_filt]
  205 + yy=dustem_interp[idx_filt]
  206 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  207 + ENDIF
  208 +
  209 +
  210 + ;Plotting of the total dust emission spectrum
  211 + cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  212 +
  213 +
  214 +
  215 + endif ;else begin ;The data points in the plot that remain unchanged.
  216 + ;stop
  217 + if not keyword_set(refresh) then begin
  218 + ;Spectrum points are treated before for plotting reasons.
  219 + if ct_spec ne 0 then begin
  220 +
  221 + ;Plotting of spectrum data points (to be fitted)
  222 + 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=16,syms=0.8,ytickformat='dstmwrp_exp'
  223 +
  224 + ;Plotting of the spectrum error points
  225 + rms=3.*((*(*!dustem_data).sed).sigma)(idx_spec)/2.
  226 + cgerrplot,((*(*!dustem_data).sed).wav)(idx_spec),((*(*!dustem_data).sed).values)(idx_spec)-rms,((*(*!dustem_data).sed).values)(idx_spec)+rms,color='Powder Blue'
  227 +
  228 + endif
  229 +
  230 + if ct_filt ne 0 then begin
  231 +
  232 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  233 + 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=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
  234 + cgplot,((*(*!dustem_data).sed).wav)(idx_filt),((*(*!dustem_data).sed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
  235 +
  236 +
  237 + ;Plotting of the filter error points
  238 + rms=3.*((*(*!dustem_data).sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
  239 + cgerrplot,((*(*!dustem_data).sed).wav)(idx_filt),((*(*!dustem_data).sed).values)(idx_filt)-rms,((*(*!dustem_data).sed).values)(idx_filt)+rms,color='Dodger Blue'
  240 +
  241 + endif
  242 +
  243 + ;Plotting of frequency axis
  244 + ;save_x=!x & save_y=!y & save_z=!z & save_p=!p & save_d=!d
  245 + ;save_scaling=1
  246 + ;use_xrange=((!const.c*1E6/(xr))*1E-9)
  247 + ;order=sort(use_xrange)
  248 + ;use_xrange=use_xrange[order]
  249 + ;print,use_xrange
  250 + ;stop
  251 + IF !dustemwrap_which_language NE 'fawlty' THEN BEGIN
  252 + axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=use_xrange,charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
  253 + ENDIF
  254 +
  255 + xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  256 +
  257 + ;Locating all the hidden data points (spectrum+filter)
  258 + match2,((*(*!dustem_data).sed).wav),((*(*!dustem_show).sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  259 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  260 + ;Locating the hidden spectrum and filter data points
  261 + idx_filt_hdn = where((((*(*!dustem_show).sed).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  262 + idx_spec_hdn = where(((*(*!dustem_show).sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  263 +
  264 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  265 + ;stop
  266 + if ct_spec_hdn ne 0 then begin
  267 + ;Plotting of hidden spectrum data points
  268 + 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=16,syms=0.8
  269 +
  270 + ;Plotting of hidden spectrum error points
  271 + rms=3.*(((*(*!dustem_show).sed).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
  272 + 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'
  273 + endif
  274 +
  275 + if ct_filt_hdn then begin
  276 + ;Plotting of hidden filter data points
  277 + 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=16,syms=0.8
  278 +
  279 + ;Plotting of hidden filter error point
  280 + rms=3.*(((*(*!dustem_show).sed).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
  281 + 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'
  282 +
  283 + endif
  284 +
  285 + endif
  286 +
  287 +
  288 +
  289 + ;endelse
  290 + endif
  291 +
  292 +
  293 + ;endelse
  294 + endif
  295 + ;endelse
  296 + endif
  297 + ;stop
  298 + end
  299 +
  300 + 'EXT': begin ;BE VERY CAREFUL THE EXTINCTION STRUCTURE AS REDERED BY DUSTEM IS DIFFERENT THAN THE EMISSION ONE
  301 +
  302 + ;SETTING THE PLOT RANGE
  303 + xr = !dustem_plot_range.ext.xr
  304 + yr = !dustem_plot_range.ext.yr
  305 +
  306 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  307 + vectw=10^vectw[1:*]
  308 + vectw=[wavs,vectw]
  309 + vectx=vectw*0+1
  310 +
  311 + idx_filt=where((*(*!dustem_data).ext).filt_names NE 'SPECTRUM',ct_filt)
  312 + idx_spec=where((*(*!dustem_data).ext).filt_names EQ 'SPECTRUM',ct_spec)
  313 +
  314 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  315 +
  316 + if keyword_set(nodata) then begin ;when the data is not present
  317 +
  318 + if keyword_set(norm) then begin ;normalized plot
  319 +
  320 + xtit=textoidl('1/\lambda (\mum^{-1})')
  321 + if !run_pol then xtit = ''
  322 + cgplot,1/vectw,vectx,/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
  323 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  324 +
  325 + endif ;else begin ;normal plot
  326 +
  327 + if not keyword_set(norm) then begin
  328 + ;/NODATA
  329 + 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
  330 + axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
  331 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  332 +
  333 + ;endelse
  334 + endif
  335 +
  336 + endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
  337 + if not keyword_set(nodata) then begin
  338 + if keyword_set(norm) then begin
  339 +
  340 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  341 +
  342 + IF ct_spec NE 0 THEN BEGIN
  343 + xx=((*(*!dustem_data).ext).wav)[idx_spec]
  344 + yy=dustem_interp[idx_spec]
  345 + rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
  346 + indzero = where(yy NE 0, ct_zero)
  347 + IF ct_zero NE 0 THEN BEGIN
  348 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  349 + cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_spec))[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  350 + ENDIF
  351 + ENDIF
  352 +
  353 + IF ct_filt NE 0 THEN BEGIN ; There are no filter points for now...
  354 + xx=((*(*!dustem_data).ext).wav)[idx_filt]
  355 + yy=dustem_interp[idx_filt]
  356 + rms=3.*((*(*!dustem_data).ext).sigma)(idx_filt)/2.
  357 + indzero = where(yy NE 0, ct_zero)
  358 + IF ct_zero NE 0 THEN BEGIN
  359 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
  360 + cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_filt))[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot
  361 + ENDIF
  362 + ENDIF
  363 +
  364 +
  365 + 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.
  366 + ;stop
  367 +
  368 + if not keyword_set(refresh) then begin
  369 + ;stop
  370 + xtit=textoidl('1/\lambda (\mum^{-1})')
  371 + if !run_pol then begin
  372 + xtit = ''
  373 + xtickformat='(A1)'
  374 + endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
  375 + cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  376 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  377 +
  378 + ;endelse
  379 + endif
  380 +
  381 +
  382 + endif ;else begin ; normal plot
  383 + if not keyword_set(norm) then begin
  384 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  385 +
  386 + ;not so sure about the multiplicative factor
  387 +
  388 + ;Plotting of the spectra of the dust species
  389 +
  390 + FOR i=0L,Ngrains-1 DO BEGIN
  391 + cgoplot,1/st.ext.wav,transpose((st.ext.(1))[i,*]+(st.ext.(2))[i,*])*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
  392 + ENDFOR
  393 +
  394 +
  395 + ;Plotting of the plugins.
  396 + for i=0L,n_plgns-1 do begin
  397 +
  398 + if isa((*!dustem_plugin).(0).spec) then begin
  399 +
  400 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_EXT') THEN begin
  401 + cgoplot,1/st.ext.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  402 + ENDIF
  403 +
  404 + endif
  405 +
  406 + endfor
  407 +
  408 +
  409 + ;PLotting of the interpolates corresponding to spectrum and filter points
  410 +
  411 + IF ct_spec NE 0 THEN BEGIN
  412 +
  413 + xx=((*(*!dustem_data).ext).wav)[idx_spec]
  414 + yy=dustem_interp[idx_spec]
  415 + cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1
  416 + ENDIF
  417 +
  418 +
  419 + IF ct_filt NE 0 THEN BEGIN
  420 + xx=((*(*!dustem_data).ext).wav)[idx_filt]
  421 + yy=dustem_interp[idx_filt]
  422 + cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  423 + ENDIF
  424 +
  425 +
  426 + ;Plotting of the total dust emission spectrum
  427 + cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  428 +
  429 +
  430 +
  431 + endif ;else begin ;The data points in the plot that remain unchanged.
  432 + ;stop
  433 + if not keyword_set(refresh) then begin
  434 + ;Spectrum points are treated before for plotting reasons.
  435 + if ct_spec ne 0 then begin
  436 +
  437 + ;Plotting of spectrum data points (to be fitted)
  438 + cgplot,1/((*(*!dustem_data).ext).wav)(idx_spec),((*(*!dustem_data).ext).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=16,syms=0.8,ytickformat='dstmwrp_exp'
  439 +
  440 + ;Plotting of the spectrum error points
  441 + rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
  442 + cgerrplot,1/((*(*!dustem_data).ext).wav)(idx_spec),((*(*!dustem_data).ext).values)(idx_spec)-rms,((*(*!dustem_data).ext).values)(idx_spec)+rms,color='Powder Blue'
  443 +
  444 + endif
  445 +
  446 + if ct_filt ne 0 then begin
  447 +
  448 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  449 + if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
  450 + cgplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
  451 +
  452 +
  453 + ;Plotting of the filter error points
  454 + rms=3.*((*(*!dustem_data).ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
  455 + cgerrplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt)-rms,((*(*!dustem_data).ext).values)(idx_filt)+rms,color='Dodger Blue'
  456 +
  457 + endif
  458 +
  459 +
  460 + ;Plotting of frequency axis
  461 + axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
  462 +
  463 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  464 +
  465 + ;Locating all the hidden data points (spectrum+filter)
  466 + match2,((*(*!dustem_data).ext).wav),((*(*!dustem_show).ext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  467 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  468 + ;Locating the hidden spectrum and filter data points
  469 + idx_filt_hdn = where((((*(*!dustem_show).ext).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  470 + idx_spec_hdn = where(((*(*!dustem_show).ext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  471 +
  472 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  473 + ;stop
  474 + if ct_spec_hdn ne 0 then begin
  475 + ;Plotting of hidden spectrum data points
  476 + cgoplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*(*!dustem_show).ext).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=16,syms=0.8
  477 +
  478 + ;Plotting of hidden spectrum error points
  479 + rms=3.*(((*(*!dustem_show).ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
  480 + cgerrplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
  481 + endif
  482 +
  483 + if ct_filt_hdn then begin
  484 + ;Plotting of hidden filter data points
  485 + cgoplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*(*!dustem_show).ext).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=16,syms=0.8
  486 +
  487 + ;Plotting of hidden filter error point
  488 + rms=3.*(((*(*!dustem_show).ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
  489 + cgerrplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
  490 +
  491 + endif
  492 +
  493 + endif
  494 +
  495 +
  496 +
  497 + ;endelse
  498 + endif
  499 +
  500 +
  501 + ;endelse
  502 + endif
  503 + ;endelse
  504 + endif
  505 +
  506 +
  507 + end
  508 +
  509 + 'POLEXT': begin
  510 +
  511 + ;SETTING THE PLOT RANGE
  512 + xr = !dustem_plot_range.polext.xr
  513 + yr = !dustem_plot_range.polext.yr
  514 +
  515 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  516 + vectw=10^vectw[1:*]
  517 + vectw=[wavs,vectw]
  518 + vectx=vectw*0+1
  519 +
  520 + idx_filt=where((*(*!dustem_data).polext).filt_names NE 'SPECTRUM',ct_filt)
  521 + idx_spec=where((*(*!dustem_data).polext).filt_names EQ 'SPECTRUM',ct_spec)
  522 +
  523 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  524 +
  525 + if keyword_set(nodata) then begin ;when the data is not present
  526 +
  527 + if keyword_set(norm) then begin ;normalized plot
  528 +
  529 + xtit=textoidl('1/\lambda (\mum^{_1})')
  530 + if !run_pol then xtit = ''
  531 + cgplot,1/vectw,vectx,/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
  532 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  533 +
  534 + endif else begin ;normal plot
  535 + ;/NODATA
  536 + 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
  537 + axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
  538 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  539 +
  540 + endelse
  541 +
  542 +
  543 + endif else begin ;when the data is present
  544 +
  545 + if keyword_set(norm) then begin
  546 +
  547 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  548 +
  549 + IF ct_spec NE 0 THEN BEGIN
  550 +
  551 + xx=((*(*!dustem_data).polext).wav)[idx_spec]
  552 + yy=dustem_interp[idx_spec]
  553 + rms=3.*((*(*!dustem_data).polext).sigma)(idx_spec)/2.
  554 + indzero = where(yy NE 0, ct_zero)
  555 +
  556 + IF ct_zero NE 0 THEN BEGIN
  557 +
  558 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).polext).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  559 + cgerrplot,(1/((*(*!dustem_data).polext).wav)(idx_spec))[indzero],((((*(*!dustem_data).polext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  560 +
  561 + ENDIF
  562 + ENDIF
  563 +
  564 + IF ct_filt NE 0 THEN BEGIN
  565 + xx=((*(*!dustem_data).polext).wav)[idx_filt]
  566 + yy=dustem_interp[idx_filt]
  567 + rms=3.*((*(*!dustem_data).polext).sigma)(idx_filt)/2.
  568 + indzero = where(yy NE 0, ct_zero)
  569 + IF ct_zero NE 0 THEN BEGIN
  570 +
  571 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).polext).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
  572 + cgerrplot,(1/((*(*!dustem_data).polext).wav)(idx_filt))[indzero],((((*(*!dustem_data).polext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot
  573 +
  574 + ENDIF
  575 + ENDIF
  576 +
  577 +
  578 + endif else begin ;The data points in the plot that remain unchanged ; UNNECESSARY BLOCK but needed to limit erros when calls are made with missing keywords.
  579 +
  580 + xtit=textoidl('1/\lambda (\mum^{-1})')
  581 + if !run_pol then xtit = ''
  582 + cgplot,1/vectw,vectx,/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
  583 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  584 +
  585 + endelse
  586 +
  587 +
  588 + endif else begin ; normal plot
  589 +
  590 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  591 +
  592 + ;Plotting of the spectra of the dust species
  593 + FOR i=0L,Ngrains-1 DO BEGIN
  594 + vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
  595 + cgoplot,1/st.polext.wav,vecto*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
  596 + ENDFOR
  597 +
  598 + ;stop
  599 +
  600 + ;Plotting of the plugins.
  601 + for i=0L,n_plgns-1 do begin
  602 + If isa((*!dustem_plugin).(0).spec) then begin
  603 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  604 + cgoplot,1/st.polext.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  605 + ENDIF
  606 + endif
  607 + endfor
  608 +
  609 + ;PLotting of the interpolates corresponding to spectrum and filter points
  610 +
  611 + IF ct_spec NE 0 THEN BEGIN
  612 +
  613 + xx=((*(*!dustem_data).polext).wav)[idx_spec]
  614 + yy=dustem_interp[idx_spec]
  615 + cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  616 + ENDIF
  617 +
  618 +
  619 + IF ct_filt NE 0 THEN BEGIN
  620 + xx=((*(*!dustem_data).polext).wav)[idx_filt]
  621 + yy=dustem_interp[idx_filt]
  622 + cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  623 + ENDIF
  624 +
  625 + ;Plotting of the total dust emission spectru
  626 + cgoplot,1/st.polext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  627 + ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  628 +
  629 +
  630 + endif else begin ;The data points in the plot that remain unchanged.
  631 +
  632 + ;Spectrum points are treated before for plotting reasons.
  633 + if ct_spec ne 0 then begin
  634 +
  635 + ;Plotting of spectrum data points (to be fitted)
  636 + cgplot,1/((*(*!dustem_data).polext).wav)(idx_spec),((*(*!dustem_data).polext).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'
  637 +
  638 + ;Plotting of the spectrum error points
  639 + rms=3.*((*(*!dustem_data).polext).sigma)(idx_spec)/2.
  640 + cgerrplot,1/((*(*!dustem_data).polext).wav)(idx_spec),((*(*!dustem_data).polext).values)(idx_spec)-rms,((*(*!dustem_data).polext).values)(idx_spec)+rms,color='Powder Blue'
  641 +
  642 + endif
  643 +
  644 + if ct_filt ne 0 then begin
  645 + plotsym,0,/fill
  646 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  647 + if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).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 $
  648 + cgplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).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
  649 +
  650 +
  651 + ;Plotting of the filter error points
  652 + rms=3.*((*(*!dustem_data).polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
  653 + cgerrplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).values)(idx_filt)-rms,((*(*!dustem_data).polext).values)(idx_filt)+rms,color='Dodger Blue'
  654 +
  655 + endif
  656 +
  657 +
  658 + ;Plotting of frequency axis
  659 + axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
  660 +
  661 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  662 +
  663 + ;Locating all the hidden data points (spectrum+filter)
  664 + match2,((*(*!dustem_data).polext).wav),((*(*!dustem_show).polext).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
  665 + idx_rmv_polsed=where(fit_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide - not renaming this and keeping the polsed notation
  666 + ;Locating the hidden spectrum and filter data points
  667 + idx_filt_hdn = where((((*(*!dustem_show).polext).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
  668 + idx_spec_hdn = where(((*(*!dustem_show).polext).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
  669 +
  670 + ;stop
  671 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  672 + ;stop
  673 +
  674 + if ct_spec_hdn ne 0 then begin
  675 + ;Plotting of hidden spectrum data points
  676 + cgoplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polext).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
  677 +
  678 + ;Plotting of hidden spectrum error points
  679 + rms=3.*(((*(*!dustem_show).polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
  680 + cgerrplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black'
  681 + endif
  682 +
  683 + if ct_filt_hdn ne 0 then begin
  684 + ;Plotting of hidden filter data points
  685 + cgoplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polext).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
  686 +
  687 + ;Plotting of hidden filter error point
  688 + rms=3.*(((*(*!dustem_show).polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
  689 + cgerrplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
  690 +
  691 + endif
  692 +
  693 + endif
  694 +
  695 +
  696 +
  697 + endelse
  698 +
  699 +
  700 +
  701 + endelse
  702 +
  703 + endelse
  704 +
  705 +
  706 + end
  707 +
  708 + 'POLSED': begin
  709 +
  710 +
  711 + ;SETTING THE PLOT RANGE
  712 + xr = !dustem_plot_range.polsed.xr
  713 + yr = !dustem_plot_range.polsed.yr
  714 +
  715 +
  716 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  717 + vectw=10^vectw[1:*]
  718 + vectw=[wavs,vectw]
  719 + vectx=vectw*0+1
  720 +
  721 + idx_filt=where((*(*!dustem_data).polsed).filt_names NE 'SPECTRUM',ct_filt)
  722 + idx_spec=where((*(*!dustem_data).polsed).filt_names EQ 'SPECTRUM',ct_spec)
  723 +
  724 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  725 +
  726 + if keyword_set(nodata) then begin ;when the data is not present
  727 +
  728 + if keyword_set(norm) then begin ;normalized plot
  729 +
  730 + xtit=textoidl('\lambda (\mum)')
  731 + if !run_pol then xtit = ''
  732 + cgplot,vectw,vectx,/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
  733 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  734 +
  735 + endif else begin ;normal plot
  736 +
  737 + 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
  738 + axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
  739 + xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  740 +
  741 + endelse
  742 +
  743 +
  744 + endif else begin ;when the data is present
  745 +
  746 + if keyword_set(norm) then begin
  747 +
  748 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  749 +
  750 + IF ct_spec NE 0 THEN BEGIN
  751 + xx=((*(*!dustem_data).polsed).wav)[idx_spec]
  752 + yy=dustem_interp[idx_spec]
  753 + rms=3.*((*(*!dustem_data).polsed).sigma)(idx_spec)/2.
  754 + indzero = where(yy NE 0, ct_zero)
  755 + IF ct_zero NE 0 THEN BEGIN
  756 + cgoplot,xx[indzero],(((*(*!dustem_data).polsed).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
  757 + cgerrplot,(((*(*!dustem_data).polsed).wav)(idx_spec))[indzero],((((*(*!dustem_data).polsed).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polsed).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  758 + ENDIF
  759 + ENDIF
  760 +
  761 + IF ct_filt NE 0 THEN BEGIN
  762 + xx=((*(*!dustem_data).polsed).wav)[idx_filt]
  763 + yy=dustem_interp[idx_filt]
  764 + rms=3.*((*(*!dustem_data).polsed).sigma)(idx_filt)/2.
  765 + indzero = where(yy NE 0, ct_zero)
  766 + IF ct_zero NE 0 THEN BEGIN
  767 + cgoplot,xx[indzero],(((*(*!dustem_data).polsed).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
  768 + cgerrplot,(((*(*!dustem_data).polsed).wav)(idx_filt))[indzero],((((*(*!dustem_data).polsed).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polsed).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot
  769 + ENDIF
  770 + ENDIF
  771 +
  772 +
  773 + endif else begin ;The data points in the plot that remain unchanged ; UNNECESSARY BLOCK but needed to limit erros when calls are made with missing keywords.
  774 +
  775 + xtit=textoidl('\lambda (\mum)')
  776 + if !run_pol then xtit = ''
  777 + cgplot,vectw,vectx,/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
  778 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  779 +
  780 + endelse
  781 +
  782 +
  783 + endif else begin ; normal plot
  784 +
  785 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  786 +
  787 + ;Plotting of the spectra of the dust species
  788 + FOR i=0L,Ngrains-1 DO BEGIN
  789 + cgoplot,st.polsed.wav,st.polsed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
  790 + ENDFOR
  791 +
  792 + ;stop
  793 +
  794 + ;Plotting of the plugins.
  795 + for i=0L,n_plgns-1 do begin
  796 + If isa((*!dustem_plugin).(0).spec) then begin
  797 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  798 + cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  799 + ENDIF
  800 + endif
  801 + endfor
  802 +
  803 + ;PLotting of the interpolates corresponding to spectrum and filter points
  804 +
  805 + IF ct_spec NE 0 THEN BEGIN
  806 +
  807 + xx=((*(*!dustem_data).polsed).wav)[idx_spec]
  808 + yy=dustem_interp[idx_spec]
  809 + cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  810 + ENDIF
  811 +
  812 +
  813 + IF ct_filt NE 0 THEN BEGIN
  814 + xx=((*(*!dustem_data).polsed).wav)[idx_filt]
  815 + yy=dustem_interp[idx_filt]
  816 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  817 + ENDIF
  818 +
  819 + ;Plotting of the total dust emission spectru
  820 + cgoplot,st.polsed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  821 + ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
  822 +
  823 +
  824 + endif else begin ;The data points in the plot that remain unchanged.
  825 +
  826 + ;Spectrum points are treated before for plotting reasons.
  827 + if ct_spec ne 0 then begin
  828 +
  829 + ;Plotting of spectrum data points (to be fitted)
  830 + 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'
  831 +
  832 + ;Plotting of the spectrum error points
  833 + rms=3.*((*(*!dustem_data).polsed).sigma)(idx_spec)/2.
  834 + cgerrplot,((*(*!dustem_data).polsed).wav)(idx_spec),((*(*!dustem_data).polsed).values)(idx_spec)-rms,((*(*!dustem_data).polsed).values)(idx_spec)+rms,color='Powder Blue'
  835 +
  836 + endif
  837 +
  838 + if ct_filt ne 0 then begin
  839 + plotsym,0,/fill
  840 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  841 + 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 $
  842 + 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
  843 +
  844 +
  845 + ;Plotting of the filter error points
  846 + rms=3.*((*(*!dustem_data).polsed).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
  847 + cgerrplot,((*(*!dustem_data).polsed).wav)(idx_filt),((*(*!dustem_data).polsed).values)(idx_filt)-rms,((*(*!dustem_data).polsed).values)(idx_filt)+rms,color='Dodger Blue'
  848 +
  849 + endif
  850 +
  851 +
  852 + ;Plotting of frequency axis
  853 + axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(xr))*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
  854 +
  855 + xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  856 +
  857 + ;Locating all the hidden data points (spectrum+filter)
  858 + match2,((*(*!dustem_data).polsed).wav),((*(*!dustem_show).polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
  859 + idx_rmv_polsed=where(fit_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
  860 + ;Locating the hidden spectrum and filter data points
  861 + idx_filt_hdn = where((((*(*!dustem_show).polsed).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
  862 + idx_spec_hdn = where(((*(*!dustem_show).polsed).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
  863 +
  864 + ;stop
  865 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  866 + ;stop
  867 +
  868 + if ct_spec_hdn ne 0 then begin
  869 + ;Plotting of hidden spectrum data points
  870 + cgoplot,(((*(*!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
  871 +
  872 + ;Plotting of hidden spectrum error points
  873 + rms=3.*(((*(*!dustem_show).polsed).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
  874 + 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'
  875 + endif
  876 +
  877 + if ct_filt_hdn ne 0 then begin
  878 + ;Plotting of hidden filter data points
  879 + cgoplot,(((*(*!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
  880 +
  881 + ;Plotting of hidden filter error point
  882 + rms=3.*(((*(*!dustem_show).polsed).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
  883 + 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'
  884 +
  885 + endif
  886 +
  887 + endif
  888 +
  889 +
  890 +
  891 + endelse
  892 +
  893 +
  894 +
  895 + endelse
  896 +
  897 + endelse
  898 +
  899 + end
  900 +
  901 + 'POLFRAC': begin
  902 +
  903 + ;SETTING THE PLOT RANGE
  904 + xr = !dustem_plot_range.polfrac.xr
  905 + yr = !dustem_plot_range.polfrac.yr
  906 +
  907 +
  908 + idx_filt=where((*(*!dustem_data).polfrac).filt_names NE 'SPECTRUM',ct_filt)
  909 + idx_spec=where((*(*!dustem_data).polfrac).filt_names EQ 'SPECTRUM',ct_spec)
  910 +
  911 +
  912 + if keyword_set(nodata) then begin ;when the data is not present
  913 +
  914 + xtit = ''
  915 + 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=yr,/ylog,psym=8,syms=0.8
  916 + xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
  917 +
  918 + endif else begin ;when the data is present ; normal plot
  919 +
  920 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  921 +
  922 + FOR i=0L,Ngrains-1 DO BEGIN
  923 +
  924 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  925 +
  926 + if countneq ne 0 then begin
  927 + vecfin = st.polsed.(i+1)*0.0
  928 +
  929 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact[testneq]/extra_spec[testneq];(st.sed.em_tot)[testneq];;(st.sed.em_tot)[testneq];spec[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  930 +
  931 + cgoplot,st.polsed.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  932 + endif
  933 + ENDFOR
  934 +
  935 + ;Plotting of the plugins.
  936 +
  937 + for i=0L,n_plgns-1 do begin
  938 +
  939 + if isa((*!dustem_plugin).(0).spec) then begin
  940 +
  941 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  942 + vecfin = st.polsed.em_tot*0.0
  943 + vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i).spec)[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i).spec)[*,2])^2)[testneq])/((*(*!dustem_plugin).(i).spec)[*,0])[testneq]
  944 + cgoplot,st.polsed.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  945 +
  946 + ENDIF
  947 + endif
  948 +
  949 + endfor
  950 +
  951 + ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW.
  952 +
  953 +
  954 + ;PLotting of the interpolates corresponding to spectrum and filter points
  955 +
  956 + IF ct_spec NE 0 THEN BEGIN
  957 +
  958 + xx=((*(*!dustem_data).polfrac).wav)[idx_spec]
  959 + yy=dustem_interp[idx_spec]
  960 + cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  961 + ENDIF
  962 +
  963 +
  964 + IF ct_filt NE 0 THEN BEGIN
  965 + xx=((*(*!dustem_data).polfrac).wav)[idx_filt]
  966 + yy=dustem_interp[idx_filt]
  967 + cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
  968 + ENDIF
  969 +
  970 +
  971 + ;Plotting of the total dust emission spectrum
  972 + cgoplot,st.polsed.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
  973 +
  974 + endif else begin ;The data points in the plot that remain unchanged.
  975 +
  976 +
  977 + ;Spectrum points are treated before for plotting reasons.
  978 +
  979 + if ct_spec ne 0 then begin
  980 +
  981 + ;Plotting of spectrum data points (to be fitted)
  982 + cgplot,((*(*!dustem_data).polfrac).wav)(idx_spec),((*(*!dustem_data).polfrac).values)(idx_spec)*100,/xlog,/ylog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=16,syms=0.8;,ytickformat='dstmwrp_exp'
  983 +
  984 + ;Plotting of the spectrum error points
  985 + rms=3.*((*(*!dustem_data).polfrac).sigma)(idx_spec)/2.
  986 + cgerrplot,((*(*!dustem_data).polfrac).wav)(idx_spec),(((*(*!dustem_data).polfrac).values)(idx_spec)-rms)*100,(((*(*!dustem_data).polfrac).values)(idx_spec)+rms)*100,color='Powder Blue'
  987 +
  988 + endif
  989 +
  990 + if ct_filt ne 0 then begin
  991 +
  992 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  993 + if ct_spec ne 0 then cgoplot,((*(*!dustem_data).polfrac).wav)(idx_filt),((*(*!dustem_data).polfrac).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
  994 + cgplot,((*(*!dustem_data).polfrac).wav)(idx_filt),((*(*!dustem_data).polfrac).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,/xlog,/ylog;,ytickformat='dstmwrp_exp'
  995 +
  996 +
  997 + ;Plotting of the filter error points
  998 + rms=3.*((*(*!dustem_data).polfrac).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
  999 + cgerrplot,((*(*!dustem_data).polfrac).wav)(idx_filt),(((*(*!dustem_data).polfrac).values)(idx_filt)-rms)*100,(((*(*!dustem_data).polfrac).values)(idx_filt)+rms)*100,color='Dodger Blue'
  1000 +
  1001 + endif
  1002 +
  1003 +
  1004 +
  1005 + xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1006 +
  1007 + ;Locating all the hidden data points (spectrum+filter)
  1008 +
  1009 + ;The filtering has been done prior (in the primary routine)
  1010 + match2,((*(*!dustem_data).polfrac).wav),((*(*!dustem_show).polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
  1011 + idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
  1012 + ;stop
  1013 + ;Locating the hidden spectrum and filter data points
  1014 + idx_filt_hdn = where(((*(*!dustem_show).polfrac).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
  1015 + idx_spec_hdn = where(((*(*!dustem_show).polfrac).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
  1016 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1017 + ;stop
  1018 +
  1019 + if ct_spec_hdn ne 0 then begin
  1020 + ;Plotting of hidden spectrum data points
  1021 + cgplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),(((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
  1022 +
  1023 + ;Plotting of hidden spectrum error points
  1024 + rms=3.*(((*(*!dustem_show).polfrac).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
  1025 + cgerrplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
  1026 + endif
  1027 +
  1028 + if ct_filt_hdn ne 0 then begin
  1029 + ;stop
  1030 + plotsym,0, /fill
  1031 + ;Plotting of hidden filter data points
  1032 + cgplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),(((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
  1033 + ;stop
  1034 + ;Plotting of hidden filter error point
  1035 + rms=3.*(((*(*!dustem_show).polfrac).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
  1036 + cgerrplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
  1037 +
  1038 + endif
  1039 +
  1040 + endif
  1041 +
  1042 +
  1043 + endelse
  1044 +
  1045 + endelse
  1046 +
  1047 + end
  1048 +
  1049 + 'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
  1050 +
  1051 +
  1052 + ;SETTING THE PLOT RANGE
  1053 + xr = !dustem_plot_range.fpolext.xr
  1054 + yr = !dustem_plot_range.fpolext.yr
  1055 +
  1056 +
  1057 + idx_filt=where((*(*!dustem_data).fpolext).filt_names NE 'SPECTRUM',ct_filt)
  1058 + idx_spec=where((*(*!dustem_data).fpolext).filt_names EQ 'SPECTRUM',ct_spec)
  1059 +
  1060 +
  1061 + if keyword_set(nodata) then begin ;when the data is not present
  1062 +
  1063 + xtit = ''
  1064 + 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=yr,/ylog,psym=8,syms=0.8
  1065 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}/\tau_{EXT} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1066 +
  1067 + endif else begin ;when the data is present ; normal plot
  1068 +
  1069 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  1070 +
  1071 +
  1072 + FOR i=0L,Ngrains-1 DO BEGIN
  1073 +
  1074 + vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
  1075 +
  1076 + testneq = where(vecto ne 0,countneq)
  1077 +
  1078 + if countneq ne 0 then begin
  1079 + vecfin = vecto*0.0
  1080 +
  1081 + vecfin[testneq] = (vecto[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  1082 +
  1083 + cgoplot,1/st.polext.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1084 + endif
  1085 + ENDFOR
  1086 +
  1087 + ;Plotting of the plugins.
  1088 +
  1089 + for i=0L,n_plgns-1 do begin
  1090 +
  1091 + if isa((*!dustem_plugin).(0).spec) then begin
  1092 +
  1093 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  1094 + vecfin = st.polext.ext_tot*0.0
  1095 + vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i).spec)[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i).spec)[*,2])^2)[testneq])/((*(*!dustem_plugin).(i).spec)[*,0])[testneq]
  1096 + cgoplot,1/st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2
  1097 +
  1098 + ENDIF
  1099 + endif
  1100 +
  1101 + endfor
  1102 +
  1103 +
  1104 + ;PLotting of the interpolates corresponding to spectrum and filter points
  1105 +
  1106 + IF ct_spec NE 0 THEN BEGIN
  1107 +
  1108 + xx=((*(*!dustem_data).fpolext).wav)[idx_spec]
  1109 + yy=dustem_interp[idx_spec]
  1110 + cgoplot,1/xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  1111 + ENDIF
  1112 +
  1113 +
  1114 + IF ct_filt NE 0 THEN BEGIN
  1115 + xx=((*(*!dustem_data).fpolext).wav)[idx_filt]
  1116 + yy=dustem_interp[idx_filt]
  1117 + cgoplot,1/xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
  1118 + ENDIF
  1119 +
  1120 +
  1121 + ;Plotting of the total dust emission spectrum
  1122 + cgoplot,1/st.polext.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
  1123 +
  1124 +
  1125 + endif else begin ;The data points in the plot that remain unchanged.
  1126 +
  1127 +
  1128 + ;Spectrum points are treated before for plotting reasons.
  1129 +
  1130 + if ct_spec ne 0 then begin
  1131 +
  1132 + ;Plotting of spectrum data points (to be fitted)
  1133 + cgplot,1/((*(*!dustem_data).fpolext).wav)(idx_spec),((*(*!dustem_data).fpolext).values)(idx_spec)*100,/xlog,/ylog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=16,syms=0.8;,ytickformat='dstmwrp_exp'
  1134 +
  1135 + ;Plotting of the spectrum error points
  1136 + rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_spec)/2.
  1137 + cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_spec),(((*(*!dustem_data).fpolext).values)(idx_spec)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_spec)+rms)*100,color='Powder Blue'
  1138 +
  1139 + endif
  1140 +
  1141 + if ct_filt ne 0 then begin
  1142 +
  1143 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  1144 + if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),((*(*!dustem_data).fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
  1145 + cgplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),((*(*!dustem_data).fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,/xlog,/ylog;,ytickformat='dstmwrp_exp'
  1146 +
  1147 +
  1148 + ;Plotting of the filter error points
  1149 + rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
  1150 + cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),(((*(*!dustem_data).fpolext).values)(idx_filt)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_filt)+rms)*100,color='Dodger Blue'
  1151 +
  1152 + endif
  1153 +
  1154 +
  1155 +
  1156 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}/\tau_{EXT} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1157 +
  1158 + ;Locating all the hidden data points (spectrum+filter)
  1159 +
  1160 + ;The filtering has been done prior (in the primary routine)
  1161 + match2,((*(*!dustem_data).fpolext).wav),((*(*!dustem_show).fpolext).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
  1162 + idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide;
  1163 +
  1164 + ;Locating the hidden spectrum and filter data points
  1165 + idx_filt_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
  1166 + idx_spec_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
  1167 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1168 + ;stop
  1169 +
  1170 + if ct_spec_hdn ne 0 then begin
  1171 + ;Plotting of hidden spectrum data points
  1172 + cgplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_spec_hdn),(((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
  1173 +
  1174 + ;Plotting of hidden spectrum error points
  1175 + rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
  1176 + cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
  1177 + endif
  1178 +
  1179 + if ct_filt_hdn ne 0 then begin
  1180 + ;stop
  1181 + plotsym,0, /fill
  1182 + ;Plotting of hidden filter data points
  1183 + cgplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_filt_hdn),(((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
  1184 + ;stop
  1185 + ;Plotting of hidden filter error point
  1186 + rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
  1187 + cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
  1188 +
  1189 + endif
  1190 +
  1191 + endif
  1192 +
  1193 +
  1194 + endelse
  1195 +
  1196 + endelse
  1197 +
  1198 +
  1199 + END
  1200 +
  1201 +
  1202 +
  1203 + '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
  1204 +
  1205 +
  1206 + ;SETTING THE PLOT RANGE
  1207 + xr = !dustem_plot_range.psi_em.xr
  1208 + yr = !dustem_plot_range.psi_em.yr
  1209 +
  1210 +
  1211 +
  1212 + idx_filt=where((*(*!dustem_data).psi_em).filt_names NE 'SPECTRUM',ct_filt)
  1213 + idx_spec=where((*(*!dustem_data).psi_em).filt_names EQ 'SPECTRUM',ct_spec)
  1214 +
  1215 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  1216 +
  1217 + if keyword_set(nodata) then begin ;when the data is not present
  1218 +
  1219 + xtit = ''
  1220 + 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=yr,psym=8,syms=0.8
  1221 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1222 +
  1223 + endif else begin ;when the data is present ; normal plot
  1224 +
  1225 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  1226 +
  1227 +
  1228 + ;Plotting of the spectra of the dust species
  1229 + FOR i=0L,Ngrains-1 DO BEGIN
  1230 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  1231 + if countneq ne 0 then begin
  1232 + vecfin = st.polsed.(i+1)*0.0
  1233 +
  1234 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])/(st.sed.(i+1))[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'.
  1235 +
  1236 + ;*****NB: These two lines will have to be modified if the polarization angle varies with the dust species and/or with wavelength
  1237 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
  1238 +
  1239 + ;You can replace the -0 values by 0 in order to avoid atan giving wrong values
  1240 + testnzero = where(specqgrain EQ -0., ct_nzero)
  1241 + if ct_nzero ne 0 then specqgrain[testnzero] = 0
  1242 +
  1243 + cgoplot,st.polsed.wav,0.5*atan(specugrain, specqgrain)/!dtor,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=yr
  1244 + ;cgoplot,st.polsed.wav,replicate(!dustem_psi,n_elements(vecfin)),pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
  1245 +
  1246 + endif
  1247 + ENDFOR
  1248 +
  1249 + ;Plotting of the plugins.
  1250 + for i=0L,n_plgns-1 do begin
  1251 +
  1252 + if isa((*!dustem_plugin).(0).spec) then begin
  1253 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  1254 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1255 + cgoplot,st.polsed.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=yr
  1256 + ENDIF
  1257 + ENDIF
  1258 + endfor
  1259 +
  1260 + ;PLotting of the interpolates corresponding to spectrum and filter points
  1261 +
  1262 + IF ct_spec NE 0 THEN BEGIN
  1263 +
  1264 + xx=((*(*!dustem_data).psi_em).wav)[idx_spec]
  1265 + yy=dustem_interp[idx_spec]
  1266 + cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  1267 + ENDIF
  1268 +
  1269 +
  1270 + IF ct_filt NE 0 THEN BEGIN
  1271 + xx=((*(*!dustem_data).psi_em).wav)[idx_filt]
  1272 + yy=dustem_interp[idx_filt]
  1273 + cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  1274 + ENDIF
  1275 +
  1276 +
  1277 + ;Plotting of the total dust emission spectrum
  1278 + ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
  1279 + cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs
  1280 +
  1281 + endif else begin ;The data points in the plot that remain unchanged.
  1282 +
  1283 +
  1284 + ;Spectrum points are treated before for plotting reasons.
  1285 + if ct_spec ne 0 then begin
  1286 +
  1287 + ;Plotting of spectrum data points (to be fitted)
  1288 + 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=yr,psym=16,syms=0.8;,ytickformat='dstmwrp_exp'
  1289 +
  1290 + ;Plotting of the spectrum error points
  1291 + rms=3.*((*(*!dustem_data).psi_em).sigma)(idx_spec)/2.
  1292 + 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'
  1293 +
  1294 + endif
  1295 +
  1296 + if ct_filt ne 0 then begin
  1297 +
  1298 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  1299 + 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=yr,/xlog else $;,ytickformat='dstmwrp_exp'
  1300 + 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=yr,/xlog;,ytickformat='dstmwrp_exp'
  1301 +
  1302 +
  1303 + ;Plotting of the filter error points
  1304 + rms=3.*((*(*!dustem_data).psi_em).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
  1305 + 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'
  1306 +
  1307 + endif
  1308 +
  1309 +
  1310 +
  1311 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1312 +
  1313 + ;Locating all the hidden data points (spectrum+filter)
  1314 +
  1315 + ;The filtering has been done prior (in the primary routine)
  1316 + match2,((*(*!dustem_data).psi_em).wav),((*(*!dustem_show).psi_em).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
  1317 + idx_rmv_psi_em=where(fit_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
  1318 + ;stop
  1319 + ;Locating the hidden spectrum and filter data points
  1320 + idx_filt_hdn = where(((*(*!dustem_show).psi_em).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn)
  1321 + idx_spec_hdn = where(((*(*!dustem_show).psi_em).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
  1322 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1323 + ;stop
  1324 +
  1325 + if ct_spec_hdn ne 0 then begin
  1326 + ;Plotting of hidden spectrum data points
  1327 + 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=yr,psym=8,syms=0.8
  1328 +
  1329 + ;Plotting of hidden spectrum error points
  1330 + rms=3.*(((*(*!dustem_show).psi_em).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
  1331 + 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'
  1332 + endif
  1333 +
  1334 + if ct_filt_hdn ne 0 then begin
  1335 + ;stop
  1336 + plotsym,0, /fill
  1337 + ;Plotting of hidden filter data points
  1338 + 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=yr,psym=8,syms=0.8
  1339 + ;stop
  1340 + ;Plotting of hidden filter error point
  1341 + rms=3.*(((*(*!dustem_show).psi_em).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
  1342 + 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'
  1343 +
  1344 + endif
  1345 +
  1346 + endif
  1347 +
  1348 + endelse
  1349 +
  1350 + endelse
  1351 +
  1352 +
  1353 + end
  1354 +
  1355 + 'PSI_EXT': begin ;MODIFYING THIS NOW - You should write a plugin for the modification of polarized extinction so that !dustem_psi_ext is different than !dustem_psi.
  1356 +
  1357 + ;SETTING THE PLOT RANGE
  1358 + xr = !dustem_plot_range.psi_ext.xr
  1359 + yr = !dustem_plot_range.psi_ext.yr
  1360 +
  1361 +
  1362 + idx_filt=where((*(*!dustem_data).psi_ext).filt_names NE 'SPECTRUM',ct_filt)
  1363 + idx_spec=where((*(*!dustem_data).psi_ext).filt_names EQ 'SPECTRUM',ct_spec)
  1364 +
  1365 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  1366 +
  1367 + if keyword_set(nodata) then begin ;when the data is not present
  1368 +
  1369 + xtit = ''
  1370 + 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=yr,psym=8,syms=0.8
  1371 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1372 +
  1373 + endif else begin ;when the data is present ; normal plot
  1374 +
  1375 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  1376 +
  1377 + ;##################TAKEN FROM SED
  1378 +
  1379 + ;Plotting of the spectra of the dust species
  1380 +
  1381 + FOR i=0L,Ngrains-1 DO BEGIN
  1382 +
  1383 + vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
  1384 + vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
  1385 + testneq = where(vecto ne 0,countneq)
  1386 +
  1387 + ;testing whether the polext values contain negative ones
  1388 + testpos = where(vecto LT 0, countpos)
  1389 + IF countpos NE 0 THEN vecto[testpos] = 0
  1390 +
  1391 + if countneq ne 0 then begin
  1392 +
  1393 + vecfin = vecto*0.0
  1394 +
  1395 + vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'.
  1396 +
  1397 + polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
  1398 +
  1399 + cgoplot,1/st.polext.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=yr
  1400 + endif
  1401 + ENDFOR
  1402 +
  1403 + ;Plotting of the plugins.
  1404 + for i=0L,n_plgns-1 do begin
  1405 +
  1406 + if isa((*!dustem_plugin).(0).spec) then begin
  1407 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  1408 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1409 + cgoplot_mlog,1/st.polext.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=yr
  1410 + ENDIF
  1411 + ENDIF
  1412 + endfor
  1413 +
  1414 + ;PLotting of the interpolates corresponding to spectrum and filter points
  1415 +
  1416 + IF ct_spec NE 0 THEN BEGIN
  1417 +
  1418 + xx=((*(*!dustem_data).psi_ext).wav)[idx_spec]
  1419 + yy=dustem_interp[idx_spec]
  1420 + cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1
  1421 + ENDIF
  1422 +
  1423 +
  1424 + IF ct_filt NE 0 THEN BEGIN
  1425 + xx=((*(*!dustem_data).psi_ext).wav)[idx_filt]
  1426 + yy=dustem_interp[idx_filt]
  1427 + cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
  1428 + ENDIF
  1429 +
  1430 + ;Plotting of the total dust emission spectrum
  1431 + ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
  1432 + cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs
  1433 +
  1434 + endif else begin ;The data points in the plot that remain unchanged.
  1435 +
  1436 + ;Spectrum points are treated before for plotting reasons.
  1437 + if ct_spec ne 0 then begin
  1438 +
  1439 + ;Plotting of spectrum data points (to be fitted)
  1440 + cgplot,1/((*(*!dustem_data).psi_ext).wav)(idx_spec),((*(*!dustem_data).psi_ext).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=16,syms=0.8;,ytickformat='dstmwrp_exp'
  1441 +
  1442 + ;Plotting of the spectrum error points
  1443 + rms=3.*((*(*!dustem_data).psi_ext).sigma)(idx_spec)/2.
  1444 + cgerrplot,1/((*(*!dustem_data).psi_ext).wav)(idx_spec),((*(*!dustem_data).psi_ext).values)(idx_spec)-rms,((*(*!dustem_data).psi_ext).values)(idx_spec)+rms,color='Powder Blue'
  1445 +
  1446 + endif
  1447 +
  1448 + if ct_filt ne 0 then begin
  1449 +
  1450 + ;Plotting of filter data points (to be fitted) + testing for prior plotting
  1451 + if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).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=yr,/xlog else $;,ytickformat='dstmwrp_exp'
  1452 + cgplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).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=yr,/xlog;,ytickformat='dstmwrp_exp'
  1453 +
  1454 +
  1455 + ;Plotting of the filter error points
  1456 + rms=3.*((*(*!dustem_data).psi_ext).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
  1457 + cgerrplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).values)(idx_filt)-rms,((*(*!dustem_data).psi_ext).values)(idx_filt)+rms,color='Dodger Blue'
  1458 +
  1459 + endif
  1460 +
  1461 +
  1462 +
  1463 + xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1464 +
  1465 + ;Locating all the hidden data points (spectrum+filter)
  1466 +
  1467 + ;The filtering has been done prior (in the primary routine)
  1468 + match2,((*(*!dustem_data).psi_ext).wav),((*(*!dustem_show).psi_ext).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
  1469 + idx_rmv_psi_em=where(fit_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
  1470 + ;stop
  1471 + ;Locating the hidden spectrum and filter data points
  1472 + idx_filt_hdn = where(((*(*!dustem_show).psi_ext).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn) ;keeping psi_em notation for counters...
  1473 + idx_spec_hdn = where(((*(*!dustem_show).psi_ext).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
  1474 + if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1475 + ;stop
  1476 +
  1477 + if ct_spec_hdn ne 0 then begin
  1478 + ;Plotting of hidden spectrum data points
  1479 + cgplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*(*!dustem_show).psi_ext).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=yr,psym=8,syms=0.8
  1480 +
  1481 + ;Plotting of hidden spectrum error points
  1482 + rms=3.*(((*(*!dustem_show).psi_ext).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
  1483 + cgerrplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_spec_hdn)-rms,(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_spec_hdn)+rms,color='Black'
  1484 + endif
  1485 +
  1486 + if ct_filt_hdn ne 0 then begin
  1487 + ;stop
  1488 + plotsym,0, /fill
  1489 + ;Plotting of hidden filter data points
  1490 + cgplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*(*!dustem_show).psi_ext).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=yr,psym=8,syms=0.8
  1491 + ;stop
  1492 + ;Plotting of hidden filter error point
  1493 + rms=3.*(((*(*!dustem_show).psi_ext).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
  1494 + cgerrplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_filt_hdn)-rms,(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_filt_hdn)+rms,color='Black'
  1495 +
  1496 + endif
  1497 +
  1498 + endif
  1499 +
  1500 + endelse
  1501 +
  1502 + endelse
  1503 +
  1504 + end
  1505 +
  1506 + 'QSED': begin ; THE ONE I WILL BE WORKING ON
  1507 +
  1508 + ;SETTING THE PLOT RANGE
  1509 + xr = !dustem_plot_range.qsed.xr
  1510 + yr = !dustem_plot_range.qsed.yr
  1511 +
  1512 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  1513 + vectw=10^vectw[1:*]
  1514 + vectw=[wavs,vectw]
  1515 + vectx=vectw*0+1
  1516 +
  1517 + varvar=where((*(*!dustem_data).qsed).values GT 0, testpstv)
  1518 + varvar=where((*(*!dustem_data).qsed).values LT 0, testngtv)
  1519 +
  1520 +
  1521 + idx_filt=where((*(*!dustem_data).qsed).filt_names NE 'SPECTRUM', ct_filt)
  1522 + idx_spec=where((*(*!dustem_data).qsed).filt_names EQ 'SPECTRUM' , ct_spec)
  1523 +
  1524 + ;Locating all the hidden data points (spectrum+filter)
  1525 + match2,((*(*!dustem_data).qsed).wav),((*(*!dustem_show).qsed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  1526 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  1527 +
  1528 +
  1529 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  1530 +
  1531 + if keyword_set(nodata) then begin ;when the data is not present
  1532 +
  1533 + if keyword_set(norm) then begin ;normalized plot
  1534 +
  1535 + xtit=textoidl('\lambda (\mum)')
  1536 + if !run_pol then xtit = ''
  1537 + cgplot,vectw,vectx,/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
  1538 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  1539 +
  1540 + endif else begin ;normal plot
  1541 +
  1542 + 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
  1543 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  1544 + xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1545 +
  1546 + endelse
  1547 +
  1548 +
  1549 + endif else begin ;when the data is present
  1550 +
  1551 + if keyword_set(norm) then begin
  1552 +
  1553 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  1554 +
  1555 + ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  1556 +
  1557 + IF ct_spec NE 0 THEN BEGIN
  1558 + xx=((*(*!dustem_data).qsed).wav)[idx_spec]
  1559 + yy=dustem_interp[idx_spec]
  1560 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_spec)/2.
  1561 + indzero = where(yy NE 0, ct_zero)
  1562 + IF ct_zero NE 0 THEN BEGIN
  1563 + cgoplot,xx[indzero],(((*(*!dustem_data).qsed).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  1564 + cgerrplot,(((*(*!dustem_data).qsed).wav)(idx_spec))[indzero],((((*(*!dustem_data).qsed).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qsed).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  1565 + ENDIF
  1566 + ENDIF
  1567 +
  1568 + IF ct_filt NE 0 THEN BEGIN
  1569 + ;stop
  1570 + xx=((*(*!dustem_data).qsed).wav)[idx_filt]
  1571 + yy=dustem_interp[idx_filt]
  1572 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
  1573 + indzero = where(yy NE 0, ct_zero)
  1574 + IF ct_zero NE 0 THEN BEGIN
  1575 + cgoplot,xx[indzero],(((*(*!dustem_data).qsed).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
  1576 + cgerrplot,(((*(*!dustem_data).qsed).wav)(idx_filt))[indzero],((((*(*!dustem_data).qsed).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qsed).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue'
  1577 + ENDIF
  1578 + ENDIF
  1579 +
  1580 +
  1581 + endif else begin ;The data points in the plot that remain unchanged
  1582 + ;stop
  1583 + ;stitching an array of 1000 more points (up to 1E7) after the end of the dustem wavelength array (dim=800 elements)
  1584 +
  1585 + xtit=textoidl('\lambda (\mum)')
  1586 + ;if !run_pol then xtit = ''
  1587 + cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  1588 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  1589 +
  1590 + endelse
  1591 +
  1592 +
  1593 + endif else begin ; normal plot - STOPPED HERE FOR QSED
  1594 +
  1595 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  1596 + ;stop
  1597 + if keyword_set(positive_only) then begin
  1598 +
  1599 + if testpstv ne 0 then begin
  1600 + ;stop
  1601 + FOR i=0L,Ngrains-1 DO BEGIN
  1602 +
  1603 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  1604 + ;stop
  1605 + if countneq ne 0 then begin
  1606 + vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right?
  1607 + ;stop
  1608 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  1609 +
  1610 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
  1611 +
  1612 + 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
  1613 +
  1614 + endif
  1615 +
  1616 + ENDFOR
  1617 +
  1618 + for i=0L,n_plgns-1 do begin
  1619 +
  1620 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  1621 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  1622 +
  1623 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1624 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1625 + ENDIF
  1626 + ENDIF
  1627 + endfor
  1628 +
  1629 + IF ct_spec NE 0 THEN BEGIN
  1630 + xx=((*(*!dustem_data).qsed).wav)[idx_spec]
  1631 + yy=dustem_interp[idx_spec]
  1632 +
  1633 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1634 + ENDIF
  1635 +
  1636 + IF ct_filt NE 0 THEN BEGIN
  1637 + xx=((*(*!dustem_data).qsed).wav)[idx_filt]
  1638 + yy=dustem_interp[idx_filt]
  1639 +
  1640 + 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
  1641 + ENDIF
  1642 +
  1643 + dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1644 +
  1645 + endif
  1646 +
  1647 +
  1648 + endif
  1649 +
  1650 + ;stop
  1651 + if keyword_set(negative_only) then begin
  1652 + ;stop
  1653 + if testngtv ne 0 then begin
  1654 +
  1655 + ;stop
  1656 + ;Plotting of the spectra of the dust species
  1657 + FOR i=0L,Ngrains-1 DO BEGIN
  1658 +
  1659 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  1660 + ;stop
  1661 + if countneq ne 0 then begin
  1662 + vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right?
  1663 + ;stop
  1664 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  1665 + ;stop
  1666 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
  1667 + ;stop
  1668 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  1669 + 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
  1670 +
  1671 + endif
  1672 + ENDFOR
  1673 + ;Plotting of the plugins
  1674 + for i=0L,n_plgns-1 do begin
  1675 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  1676 +
  1677 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  1678 +
  1679 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  1680 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1681 + ENDIF
  1682 +
  1683 + ENDIF
  1684 + endfor
  1685 + ;PLotting of the interpolates corresponding to spectrum and filter points
  1686 + IF ct_spec NE 0 THEN BEGIN
  1687 + xx=((*(*!dustem_data).qsed).wav)[idx_spec]
  1688 + yy=dustem_interp[idx_spec]
  1689 +
  1690 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1691 + ENDIF
  1692 +
  1693 + IF ct_filt NE 0 THEN BEGIN
  1694 + xx=((*(*!dustem_data).qsed).wav)[idx_filt]
  1695 + yy=dustem_interp[idx_filt]
  1696 + 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
  1697 + ENDIF
  1698 + ;Plotting of the total dust emission spectrum
  1699 + dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  1700 +
  1701 + endif
  1702 +
  1703 +
  1704 + endif
  1705 +
  1706 + ;stop
  1707 + endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE.
  1708 + ;stop
  1709 +
  1710 + xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1711 + ;if ct_hdnpts ne 0 then begin ;Hidden data points are present
  1712 +
  1713 + ;Locating the hidden spectrum and filter data points
  1714 +
  1715 + if ct_hdnpts NE 0 then begin
  1716 + 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)
  1717 + 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)
  1718 + 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)
  1719 + 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)
  1720 + endif
  1721 +
  1722 +
  1723 + if keyword_set(positive_only) then begin
  1724 + ;stop
  1725 + if testpstv ne 0 then begin
  1726 + ;stop
  1727 + plotsym, 0
  1728 +
  1729 +
  1730 + if ct_spec ne 0 then begin
  1731 +
  1732 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_spec)/2.
  1733 + ;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)'
  1734 + 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)'
  1735 + 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)'
  1736 +
  1737 + endif
  1738 +
  1739 + if ct_filt ne 0 then begin
  1740 +
  1741 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
  1742 + ; 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)'
  1743 + if ct_spec 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=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)';,ytickformat='(A1)'
  1744 + if ct_spec eq 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=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  1745 + 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)'
  1746 +
  1747 + endif
  1748 +
  1749 +
  1750 + if ct_hdnpts NE 0 then begin
  1751 +
  1752 + if ct_spec_hdn_pstv ne 0 then begin
  1753 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1754 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1755 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  1756 +
  1757 + 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,ytickformat='(A1)'
  1758 + 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,ytickformat='(A1)' ;,psym=8,syms=0.8
  1759 +
  1760 + endif
  1761 +
  1762 + if ct_filt_hdn_pstv ne 0 then begin
  1763 +
  1764 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1765 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1766 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  1767 +
  1768 + 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,ytickformat='(A1)'
  1769 + 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,ytickformat='(A1)' ;,psym=8,syms=0.8
  1770 +
  1771 + endif
  1772 +
  1773 + endif
  1774 +
  1775 +
  1776 + endif else begin
  1777 +
  1778 +
  1779 +
  1780 + 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)'
  1781 +
  1782 +
  1783 + if ct_filt ne 0 and ct_spec eq 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)'
  1784 +
  1785 +
  1786 + if ct_hdnpts NE 0 then begin
  1787 +
  1788 + if ct_spec_hdn_pstv ne 0 then begin
  1789 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1790 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  1791 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  1792 +
  1793 + 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,ytickformat='(A1)'
  1794 + 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,ytickformat='(A1)' ;,psym=8,syms=0.8
  1795 +
  1796 + endif
  1797 +
  1798 + if ct_filt_hdn_pstv ne 0 then begin
  1799 +
  1800 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1801 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  1802 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  1803 +
  1804 + 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,ytickformat='(A1)'
  1805 + 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,ytickformat='(A1)' ;,psym=8,syms=0.8
  1806 +
  1807 + endif
  1808 +
  1809 + endif
  1810 +
  1811 + endelse
  1812 +
  1813 + endif
  1814 +
  1815 +
  1816 + if keyword_set(negative_only) then begin
  1817 +
  1818 + if testngtv ne 0 then begin
  1819 +
  1820 + ;plotsym, 0
  1821 +
  1822 + if ct_spec ne 0 then begin
  1823 +
  1824 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_spec)/2.
  1825 + ;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)'
  1826 + ; 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
  1827 + 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)'
  1828 + ;endelse;,ytickformat='(A1)'
  1829 + 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,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8
  1830 +
  1831 + endif
  1832 +
  1833 + if ct_filt ne 0 then begin
  1834 +
  1835 + rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
  1836 + ; 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)'
  1837 + ;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
  1838 + if ct_spec 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=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1839 + if ct_spec eq 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=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
  1840 + ;endelse ;,ytickformat='(A1)'
  1841 +
  1842 + 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,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1843 +
  1844 + endif
  1845 +
  1846 + if ct_hdnpts NE 0 then begin
  1847 +
  1848 + if ct_spec_hdn_ngtv ne 0 then begin
  1849 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1850 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1851 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  1852 +
  1853 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1854 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  1855 +
  1856 + endif
  1857 +
  1858 + if ct_filt_hdn_ngtv ne 0 then begin
  1859 +
  1860 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1861 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1862 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  1863 +
  1864 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr ,ytickformat='(A1)'
  1865 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  1866 +
  1867 + endif
  1868 +
  1869 + endif
  1870 +
  1871 +
  1872 + endif else begin
  1873 +
  1874 +
  1875 + 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)'
  1876 +
  1877 +
  1878 + if ct_filt ne 0 and ct_spec eq 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)'
  1879 +
  1880 + if ct_hdnpts NE 0 then begin
  1881 +
  1882 + if ct_spec_hdn_ngtv ne 0 then begin
  1883 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1884 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  1885 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  1886 +
  1887 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  1888 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  1889 +
  1890 + endif
  1891 +
  1892 + if ct_filt_hdn_ngtv ne 0 then begin
  1893 +
  1894 + xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1895 + yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  1896 + rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  1897 +
  1898 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr ,ytickformat='(A1)'
  1899 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  1900 +
  1901 + endif
  1902 +
  1903 + endif
  1904 +
  1905 + endelse
  1906 + ;stop
  1907 + endif
  1908 +
  1909 +
  1910 + endelse
  1911 +
  1912 +
  1913 +
  1914 + endelse
  1915 +
  1916 + endelse ;
  1917 +
  1918 +
  1919 + END
  1920 +
  1921 + 'USED': begin
  1922 +
  1923 + ;SETTING THE PLOT RANGE
  1924 + xr = !dustem_plot_range.used.xr
  1925 + yr = !dustem_plot_range.used.yr
  1926 +
  1927 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  1928 + vectw=10^vectw[1:*]
  1929 + vectw=[wavs,vectw]
  1930 + vectx=vectw*0+1
  1931 +
  1932 + ;SIGN-RELATED PARAMETERS/LOOPS HERE?
  1933 + ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
  1934 + varvar=where((*(*!dustem_data).used).values LT 0, testngtv)
  1935 + varvar=where((*(*!dustem_data).used).values GT 0, testpstv)
  1936 + ;stop
  1937 + idx_filt=where((*(*!dustem_data).used).filt_names NE 'SPECTRUM', ct_filt)
  1938 + idx_spec=where((*(*!dustem_data).used).filt_names EQ 'SPECTRUM' , ct_spec)
  1939 +
  1940 + ;Locating all the hidden data points (spectrum+filter)
  1941 + match2,((*(*!dustem_data).used).wav),((*(*!dustem_show).used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  1942 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  1943 +
  1944 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  1945 +
  1946 + if keyword_set(nodata) then begin ;when the data is not present
  1947 +
  1948 + if keyword_set(norm) then begin ;normalized plot
  1949 +
  1950 + xtit=textoidl('\lambda (\mum)')
  1951 + if !run_pol then xtit = ''
  1952 + cgplot,vectw,vectx,/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
  1953 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  1954 +
  1955 + endif else begin ;normal plot
  1956 +
  1957 + 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
  1958 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  1959 + xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  1960 +
  1961 + endelse
  1962 +
  1963 +
  1964 + endif else begin ;when the data is present
  1965 +
  1966 + if keyword_set(norm) then begin
  1967 +
  1968 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  1969 +
  1970 + ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  1971 +
  1972 + IF ct_spec NE 0 THEN BEGIN
  1973 + xx=((*(*!dustem_data).used).wav)[idx_spec]
  1974 + yy=dustem_interp[idx_spec]
  1975 + rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
  1976 + indzero = where(yy NE 0, ct_zero)
  1977 + IF ct_zero NE 0 THEN BEGIN
  1978 + cgoplot,xx[indzero],(((*(*!dustem_data).used).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  1979 + cgerrplot,(((*(*!dustem_data).used).wav)(idx_spec))[indzero],((((*(*!dustem_data).used).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).used).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  1980 + ENDIF
  1981 + ENDIF
  1982 +
  1983 + IF ct_filt NE 0 THEN BEGIN
  1984 +
  1985 + xx=((*(*!dustem_data).used).wav)[idx_filt]
  1986 + yy=dustem_interp[idx_filt]
  1987 + rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2.
  1988 + indzero = where(yy NE 0, ct_zero)
  1989 + IF ct_zero NE 0 THEN BEGIN
  1990 + cgoplot,xx[indzero],(((*(*!dustem_data).used).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
  1991 + cgerrplot,(((*(*!dustem_data).used).wav)(idx_filt))[indzero],((((*(*!dustem_data).used).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).used).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue'
  1992 + ENDIF
  1993 + ENDIF
  1994 +
  1995 +
  1996 + endif else begin ;The data points in the plot that remain unchanged
  1997 +
  1998 + xtit=textoidl('\lambda (\mum)')
  1999 + ;if !run_pol then xtit = ''
  2000 + cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  2001 + xyouts,pospltxt-[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  2002 +
  2003 + endelse
  2004 +
  2005 +
  2006 + endif else begin ; normal plot - STOPPED HERE FOR used
  2007 +
  2008 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  2009 +
  2010 + if keyword_set(positive_only) then begin
  2011 +
  2012 + if testpstv ne 0 then begin
  2013 + ;stop
  2014 + FOR i=0L,Ngrains-1 DO BEGIN
  2015 +
  2016 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  2017 +
  2018 + if countneq ne 0 then begin
  2019 + vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right?
  2020 +
  2021 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2022 +
  2023 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
  2024 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  2025 + 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
  2026 + endif
  2027 + ;stop
  2028 + ENDFOR
  2029 + ;stop
  2030 + for i=0L,n_plgns-1 do begin
  2031 +
  2032 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2033 +
  2034 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  2035 +
  2036 +
  2037 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2038 + ENDIF
  2039 +
  2040 + ENDIF
  2041 +
  2042 + endfor
  2043 +
  2044 + IF ct_spec NE 0 THEN BEGIN
  2045 + xx=((*(*!dustem_data).used).wav)[idx_spec]
  2046 + yy=dustem_interp[idx_spec]
  2047 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2048 + dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2049 + ENDIF
  2050 +
  2051 + IF ct_filt NE 0 THEN BEGIN
  2052 + xx=((*(*!dustem_data).used).wav)[idx_filt]
  2053 + yy=dustem_interp[idx_filt]
  2054 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2055 + 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
  2056 + ENDIF
  2057 +
  2058 + dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2059 +
  2060 + endif
  2061 +
  2062 +
  2063 + endif
  2064 +
  2065 +
  2066 + if keyword_set(negative_only) then begin
  2067 +
  2068 + if testngtv ne 0 then begin
  2069 +
  2070 + ;Plotting of the spectra of the dust species
  2071 + FOR i=0L,Ngrains-1 DO BEGIN
  2072 + testneq = where(st.polsed.(i+1) ne 0,countneq)
  2073 + if countneq ne 0 then begin
  2074 + vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right?
  2075 +
  2076 + vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2077 +
  2078 + polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
  2079 +
  2080 + 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
  2081 + endif
  2082 + ENDFOR
  2083 + ;Plotting of the plugins
  2084 + FOR i=0L,n_plgns-1 do begin
  2085 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2086 +
  2087 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
  2088 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  2089 + dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2090 + ENDIF
  2091 + ENDIF
  2092 + ENDFOR
  2093 + ;PLotting of the interpolates corresponding to spectrum and filter points
  2094 + IF ct_spec NE 0 THEN BEGIN
  2095 + xx=((*(*!dustem_data).used).wav)[idx_spec]
  2096 + yy=dustem_interp[idx_spec]
  2097 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2098 + dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2099 + ENDIF
  2100 +
  2101 + IF ct_filt NE 0 THEN BEGIN
  2102 + xx=((*(*!dustem_data).used).wav)[idx_filt]
  2103 + yy=dustem_interp[idx_filt]
  2104 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2105 + 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
  2106 + ENDIF
  2107 +
  2108 + ;Plotting of the total dust emission spectrum
  2109 + dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2110 +
  2111 + endif
  2112 +
  2113 +
  2114 + endif
  2115 +
  2116 + ;stop
  2117 + endif else begin ;The data points in the plot that remain unchanged.
  2118 + ;stop
  2119 + ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
  2120 + xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
  2121 + ;if ct_hdnpts ne 0 then begin ;Hidden data points are present
  2122 +
  2123 + ;Locating the hidden spectrum and filter data points
  2124 + ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.
  2125 +
  2126 +
  2127 + if ct_hdnpts NE 0 then begin
  2128 + 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)
  2129 + 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)
  2130 + 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)
  2131 + 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)
  2132 + endif
  2133 + ;stop
  2134 +
  2135 + if keyword_set(positive_only) then begin
  2136 + ;stop
  2137 + if testpstv ne 0 then begin
  2138 + ;stop
  2139 + plotsym, 0
  2140 +
  2141 +
  2142 + if ct_spec ne 0 then begin
  2143 +
  2144 + rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
  2145 + ;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)'
  2146 + ;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
  2147 + 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
  2148 + ;endelse;,ytickformat='(A1)'
  2149 + 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
  2150 +
  2151 + endif
  2152 +
  2153 + if ct_filt ne 0 then begin
  2154 +
  2155 + rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2.
  2156 + ; 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)'
  2157 + ;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
  2158 + if ct_spec 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',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
  2159 + if ct_spec eq 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',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
  2160 + ;endelse;,ytickformat='(A1)'
  2161 + 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
  2162 +
  2163 + endif
  2164 +
  2165 + if ct_hdnpts NE 0 then begin
  2166 +
  2167 + if ct_spec_hdn_pstv ne 0 then begin
  2168 + ;stop
  2169 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2170 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2171 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  2172 +
  2173 + 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,ytickformat='(A1)'
  2174 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2175 +
  2176 + endif
  2177 +
  2178 + if ct_filt_hdn_pstv ne 0 then begin
  2179 + ;stop
  2180 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2181 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2182 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  2183 +
  2184 + 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,ytickformat='(A1)'
  2185 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2186 +
  2187 + endif
  2188 + endif
  2189 + endif else begin
  2190 +
  2191 + 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)'
  2192 +
  2193 +
  2194 + if ct_filt ne 0 and ct_spec eq 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)'
  2195 +
  2196 + if ct_hdnpts NE 0 then begin
  2197 +
  2198 + if ct_spec_hdn_pstv ne 0 then begin
  2199 + ;stop
  2200 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2201 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2202 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  2203 +
  2204 + 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,ytickformat='(A1)'
  2205 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2206 +
  2207 + endif
  2208 +
  2209 + if ct_filt_hdn_pstv ne 0 then begin
  2210 + ;stop
  2211 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2212 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2213 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  2214 +
  2215 + 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,ytickformat='(A1)'
  2216 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2217 +
  2218 + endif
  2219 + endif
  2220 + endelse
  2221 +
  2222 + endif
  2223 +
  2224 + if keyword_set(negative_only) then begin
  2225 + ;stop
  2226 + if testngtv ne 0 then begin
  2227 +
  2228 + plotsym, 0
  2229 +
  2230 +
  2231 + if ct_spec ne 0 then begin
  2232 +
  2233 + rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
  2234 + ;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)'
  2235 + ;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
  2236 + 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)'
  2237 + ;endelse;,ytickformat='(A1)'
  2238 + 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)'
  2239 +
  2240 + endif
  2241 +
  2242 + if ct_filt ne 0 then begin
  2243 +
  2244 + rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2.
  2245 + ; 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)'
  2246 + ;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
  2247 +
  2248 + if ct_spec 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',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
  2249 + if ct_spec eq 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',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  2250 + ;endelse ;,ytickformat='(A1)'
  2251 +
  2252 + 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)'
  2253 +
  2254 + endif
  2255 +
  2256 + if ct_hdnpts NE 0 then begin
  2257 +
  2258 + if ct_spec_hdn_ngtv ne 0 then begin
  2259 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2260 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2261 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  2262 +
  2263 + 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,ytickformat='(A1)'
  2264 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2265 +
  2266 + endif
  2267 +
  2268 + if ct_filt_hdn_ngtv ne 0 then begin
  2269 +
  2270 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2271 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2272 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  2273 +
  2274 + 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,ytickformat='(A1)'
  2275 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2276 +
  2277 + endif
  2278 +
  2279 + endif
  2280 +
  2281 + endif else begin
  2282 +
  2283 + 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)'
  2284 +
  2285 +
  2286 + if ct_filt ne 0 and ct_spec eq 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)'
  2287 +
  2288 +
  2289 + if ct_hdnpts NE 0 then begin
  2290 +
  2291 + if ct_spec_hdn_ngtv ne 0 then begin
  2292 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2293 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2294 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  2295 +
  2296 + 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,ytickformat='(A1)'
  2297 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2298 +
  2299 + endif
  2300 +
  2301 + if ct_filt_hdn_ngtv ne 0 then begin
  2302 +
  2303 + xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2304 + yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2305 + rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  2306 +
  2307 + 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,ytickformat='(A1)'
  2308 + 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,ytickformat='(A1)';,psym=8,syms=0.8
  2309 +
  2310 + endif
  2311 +
  2312 + endif
  2313 +
  2314 +
  2315 +
  2316 +
  2317 +
  2318 + endelse
  2319 + ;stop
  2320 + endif
  2321 +
  2322 +
  2323 + endelse
  2324 +
  2325 +
  2326 +
  2327 + endelse
  2328 +
  2329 + endelse ;
  2330 +
  2331 +
  2332 + end
  2333 +
  2334 + 'QEXT': begin ;Correct this like you corrected extinction...
  2335 +
  2336 + ;SETTING THE PLOT RANGE
  2337 + xr = !dustem_plot_range.qext.xr
  2338 + yr = !dustem_plot_range.qext.yr
  2339 +
  2340 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  2341 + vectw=10^vectw[1:*]
  2342 + vectw=[wavs,vectw]
  2343 + vectx=vectw*0+1
  2344 +
  2345 +
  2346 + varvar=where((*(*!dustem_data).qext).values GT 0, testpstv)
  2347 + varvar=where((*(*!dustem_data).qext).values LT 0, testngtv)
  2348 +
  2349 + ;stop
  2350 + idx_filt=where((*(*!dustem_data).qext).filt_names NE 'SPECTRUM', ct_filt)
  2351 + idx_spec=where((*(*!dustem_data).qext).filt_names EQ 'SPECTRUM' , ct_spec)
  2352 +
  2353 +
  2354 + ;Locating all the hidden data points (spectrum+filter)
  2355 + match2,((*(*!dustem_data).qext).wav),((*(*!dustem_show).qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  2356 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  2357 +
  2358 + ;stop
  2359 +
  2360 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  2361 +
  2362 + if keyword_set(nodata) then begin ;when the data is not present
  2363 +
  2364 + if keyword_set(norm) then begin ;normalized plot
  2365 +
  2366 + xtit=textoidl('1/\lambda (\mum^{-1})')
  2367 + if !run_pol then xtit = ''
  2368 + cgplot,1/vectw,vectx,/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
  2369 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  2370 +
  2371 + endif else begin ;normal plot
  2372 +
  2373 + 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
  2374 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  2375 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  2376 +
  2377 + endelse
  2378 +
  2379 +
  2380 + endif else begin ;when the data is present
  2381 +
  2382 + if keyword_set(norm) then begin
  2383 +
  2384 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  2385 +
  2386 + ;MAJOR LOOP OVER THE SIGN??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  2387 +
  2388 + IF ct_spec NE 0 THEN BEGIN
  2389 +
  2390 + xx=((*(*!dustem_data).qext).wav)[idx_spec]
  2391 + yy=dustem_interp[idx_spec]
  2392 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
  2393 +
  2394 + ;testing so that data/yy is finite:
  2395 + ;avoiding zero points in yy since we divide by it
  2396 + ;testing also if the data is full of zeros (ie: PSI=0 for U and PSI=90 for Q)
  2397 +
  2398 + indzero = where(yy NE 0, ct_zero)
  2399 + if ct_zero ne 0 then begin
  2400 +
  2401 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  2402 + cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_spec))[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  2403 + endif
  2404 + ENDIF
  2405 +
  2406 + IF ct_filt NE 0 THEN BEGIN
  2407 + ;stop
  2408 + xx=((*(*!dustem_data).qext).wav)[idx_filt]
  2409 + yy=dustem_interp[idx_filt]
  2410 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
  2411 + indzero = where(yy NE 0, ct_zero)
  2412 + IF ct_zero NE 0 THEN BEGIN
  2413 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
  2414 + cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_filt))[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue'
  2415 + ENDIF
  2416 + ENDIF
  2417 +
  2418 +
  2419 + endif else begin ;The data points in the plot that remain unchanged
  2420 + ;stop
  2421 +
  2422 + xtit=textoidl('1/\lambda (\mum^{-1})')
  2423 + ;if !run_pol then xtit = ''
  2424 + cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  2425 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  2426 +
  2427 + endelse
  2428 +
  2429 +
  2430 + endif else begin ; normal plot
  2431 +
  2432 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  2433 +
  2434 + if keyword_set(positive_only) then begin
  2435 +
  2436 + if testpstv ne 0 then begin
  2437 +
  2438 + FOR i=0L,Ngrains-1 DO BEGIN
  2439 +
  2440 + vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
  2441 + vecte = transpose((st.ext.(1))[i,*]+(st.ext.(2))[i,*])
  2442 + testneq = where( vecto ne 0,countneq)
  2443 +
  2444 +
  2445 + if countneq ne 0 then begin
  2446 + vecfin = vecto*0.0 ;em_tot can be used here right?
  2447 + ;stop
  2448 + vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2449 + ;stop
  2450 + ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  2451 + polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
  2452 +
  2453 + ;if countneg ne 0 and cos(!dustem_psi_ext) gt 0 then specqgrain[testneg] = 0
  2454 +
  2455 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  2456 + dustem_plot_mlog,1/st.polext.wav,specqgrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2457 +
  2458 + endif
  2459 +
  2460 +
  2461 + ENDFOR
  2462 +
  2463 + for i=0L,n_plgns-1 do begin
  2464 +
  2465 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2466 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  2467 +
  2468 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  2469 + dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2470 + ENDIF
  2471 + ENDIF
  2472 + endfor
  2473 +
  2474 + IF ct_spec NE 0 THEN BEGIN
  2475 + xx=((*(*!dustem_data).qext).wav)[idx_spec]
  2476 + yy=dustem_interp[idx_spec]
  2477 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2478 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2479 + ENDIF
  2480 +
  2481 + IF ct_filt NE 0 THEN BEGIN
  2482 + xx=((*(*!dustem_data).qext).wav)[idx_filt]
  2483 + yy=dustem_interp[idx_filt]
  2484 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2485 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2486 + ENDIF
  2487 +
  2488 + dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2489 +
  2490 + endif
  2491 +
  2492 +
  2493 + endif
  2494 +
  2495 + ;stop
  2496 + if keyword_set(negative_only) then begin
  2497 + ;stop
  2498 + if testngtv ne 0 then begin
  2499 +
  2500 + ;stop
  2501 + ;Plotting of the spectra of the dust species
  2502 + FOR i=0L,Ngrains-1 DO BEGIN
  2503 + vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
  2504 + vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
  2505 + testneq = where(vecto ne 0,countneq)
  2506 + ;stop
  2507 + if countneq ne 0 then begin
  2508 + vecfin = vecto*0.0 ;em_tot can be used here right?
  2509 + ;stop
  2510 + vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2511 + ;stop
  2512 + polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
  2513 +
  2514 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  2515 + dustem_plot_mlog,1/st.polext.wav,specqgrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2516 + endif
  2517 + ENDFOR
  2518 + ;Plotting of the plugins
  2519 + for i=0L,n_plgns-1 do begin
  2520 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2521 +
  2522 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  2523 +
  2524 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  2525 + dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2526 + ENDIF
  2527 +
  2528 + ENDIF
  2529 + endfor
  2530 + ;PLotting of the interpolates corresponding to spectrum and filter points
  2531 + IF ct_spec NE 0 THEN BEGIN
  2532 + xx=((*(*!dustem_data).qext).wav)[idx_spec]
  2533 + yy=dustem_interp[idx_spec]
  2534 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2535 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2536 + ENDIF
  2537 +
  2538 + IF ct_filt NE 0 THEN BEGIN
  2539 + xx=((*(*!dustem_data).qext).wav)[idx_filt]
  2540 + yy=dustem_interp[idx_filt]
  2541 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2542 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2543 + ENDIF
  2544 + ;Plotting of the total dust emission spectrum
  2545 + dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2546 +
  2547 + endif
  2548 +
  2549 +
  2550 + endif
  2551 +
  2552 + ;stop
  2553 + endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE.
  2554 + ;stop
  2555 + ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
  2556 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  2557 + ;if ct_hdnpts ne 0 then begin ;Hidden data points are present
  2558 +
  2559 + ;Locating the hidden spectrum and filter data points
  2560 + ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.
  2561 + ;idx_filt_hdn = where(((*(*!dustem_show).qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  2562 + ;idx_spec_hdn = where(((*(*!dustem_show).qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  2563 + if ct_hdnpts then begin
  2564 + idx_filt_hdn_pstv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
  2565 + idx_spec_hdn_pstv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
  2566 + idx_filt_hdn_ngtv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
  2567 + idx_spec_hdn_ngtv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
  2568 + endif
  2569 +
  2570 +
  2571 + if keyword_set(positive_only) then begin
  2572 +
  2573 + if testpstv ne 0 then begin
  2574 +
  2575 + plotsym, 0
  2576 +
  2577 +
  2578 + if ct_spec ne 0 then begin
  2579 +
  2580 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
  2581 + ;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)'
  2582 +
  2583 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  2584 +
  2585 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,color='Powder 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)'
  2586 +
  2587 + endif
  2588 +
  2589 + if ct_filt ne 0 then begin
  2590 +
  2591 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
  2592 + ; 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)'
  2593 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).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)'
  2594 + if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).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)'
  2595 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).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)'
  2596 +
  2597 + endif
  2598 +
  2599 +
  2600 + if ct_hdnpts NE 0 then begin
  2601 +
  2602 + if ct_spec_hdn_pstv ne 0 then begin
  2603 + xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2604 + yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2605 + rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  2606 +
  2607 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  2608 + dustem_plot_mlog,1/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
  2609 +
  2610 + endif
  2611 +
  2612 + if ct_filt_hdn_pstv ne 0 then begin
  2613 +
  2614 + xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2615 + yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2616 + rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  2617 +
  2618 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  2619 + dustem_plot_mlog,1/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
  2620 +
  2621 + endif
  2622 +
  2623 + endif
  2624 +
  2625 +
  2626 + endif else begin
  2627 +
  2628 +
  2629 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),-((*(*!dustem_data).qext).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)'
  2630 +
  2631 +
  2632 + if ct_filt ne 0 and ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),-((*(*!dustem_data).qext).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)'
  2633 +
  2634 +
  2635 + endelse
  2636 +
  2637 + endif
  2638 +
  2639 +
  2640 + if keyword_set(negative_only) then begin
  2641 +
  2642 + if testngtv ne 0 then begin
  2643 +
  2644 + plotsym, 0
  2645 +
  2646 +
  2647 + if ct_spec ne 0 then begin
  2648 +
  2649 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
  2650 + ;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)'
  2651 + ; 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
  2652 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  2653 +
  2654 + ;endelse;,ytickformat='(A1)'
  2655 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,color='Powder Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8
  2656 +
  2657 + endif
  2658 +
  2659 + if ct_filt ne 0 then begin
  2660 +
  2661 + rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
  2662 + ; 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)'
  2663 + ;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
  2664 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).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)'
  2665 + if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).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
  2666 + ;endelse ;,ytickformat='(A1)'
  2667 +
  2668 + dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  2669 +
  2670 + endif
  2671 +
  2672 + if ct_hdnpts then begin
  2673 +
  2674 + if ct_spec_hdn_ngtv ne 0 then begin
  2675 + xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2676 + yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  2677 + rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  2678 +
  2679 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  2680 + dustem_plot_mlog,1/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
  2681 +
  2682 + endif
  2683 +
  2684 + if ct_filt_hdn_ngtv ne 0 then begin
  2685 +
  2686 + xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2687 + yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  2688 + rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  2689 +
  2690 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  2691 + dustem_plot_mlog,1/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
  2692 +
  2693 + endif
  2694 +
  2695 + endif
  2696 +
  2697 + endif else begin
  2698 +
  2699 + if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).qext).wav)(idx_spec),-((*(*!dustem_data).qext).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)'
  2700 +
  2701 +
  2702 + if ct_filt ne 0 and ct_spec eq 0 then dustem_plot_mlog,((*(*!dustem_data).qext).wav)(idx_filt),-((*(*!dustem_data).qext).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)'
  2703 +
  2704 + endelse
  2705 + ;stop
  2706 + endif
  2707 +
  2708 +
  2709 + endelse
  2710 +
  2711 +
  2712 +
  2713 + endelse
  2714 +
  2715 + endelse ;
  2716 +
  2717 + end
  2718 +
  2719 + 'UEXT': begin
  2720 +
  2721 + ;SETTING THE PLOT RANGE
  2722 + xr = !dustem_plot_range.uext.xr
  2723 + yr = !dustem_plot_range.uext.yr
  2724 +
  2725 + vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
  2726 + vectw=10^vectw[1:*]
  2727 + vectw=[wavs,vectw]
  2728 + vectx=vectw*0+1
  2729 +
  2730 + varvar=where((*(*!dustem_data).uext).values GT 0, testpstv)
  2731 + varvar=where((*(*!dustem_data).uext).values LT 0, testngtv)
  2732 +
  2733 + ;stop
  2734 + idx_filt=where((*(*!dustem_data).uext).filt_names NE 'SPECTRUM', ct_filt)
  2735 + idx_spec=where((*(*!dustem_data).uext).filt_names EQ 'SPECTRUM' , ct_spec)
  2736 +
  2737 + ;Plotting of frequency axis
  2738 + ;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)')
  2739 +
  2740 + ;stop
  2741 + ;Locating all the hidden data points (spectrum+filter)
  2742 + match2,((*(*!dustem_data).uext).wav),((*(*!dustem_show).uext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
  2743 + idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
  2744 +
  2745 +
  2746 + ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
  2747 +
  2748 + if keyword_set(nodata) then begin ;when the data is not present
  2749 +
  2750 + if keyword_set(norm) then begin ;normalized plot
  2751 +
  2752 + xtit=textoidl('1/\lambda (\mum^{-1})')
  2753 + if !run_pol then xtit = ''
  2754 + cgplot,1/vectw,vectx,/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
  2755 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  2756 +
  2757 + endif else begin ;normal plot
  2758 +
  2759 + 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
  2760 + ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
  2761 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  2762 +
  2763 + endelse
  2764 +
  2765 +
  2766 + endif else begin ;when the data is present
  2767 +
  2768 + if keyword_set(norm) then begin
  2769 +
  2770 + if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed
  2771 +
  2772 + ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE
  2773 +
  2774 + IF ct_spec NE 0 THEN BEGIN
  2775 +
  2776 + xx=((*(*!dustem_data).uext).wav)[idx_spec]
  2777 + yy=dustem_interp[idx_spec]
  2778 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
  2779 +
  2780 + indzero = where(yy NE 0, ct_zero)
  2781 + If ct_zero NE 0 THEN BEGIN
  2782 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).uext).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1
  2783 + cgerrplot,(1/((*(*!dustem_data).uext).wav)(idx_spec))[indzero],((((*(*!dustem_data).uext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).uext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
  2784 + ENDIF
  2785 + ENDIF
  2786 +
  2787 + IF ct_filt NE 0 THEN BEGIN
  2788 + ;stop
  2789 + xx=((*(*!dustem_data).uext).wav)[idx_filt]
  2790 + yy=dustem_interp[idx_filt]
  2791 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2.
  2792 + indzero = where(yy NE 0, ct_zero)
  2793 + IF ct_zero NE 0 THEN BEGIN
  2794 + cgoplot,(1/xx)[indzero],(((*(*!dustem_data).uext).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1
  2795 + cgerrplot,(1/((*(*!dustem_data).uext).wav)(idx_filt))[indzero],((((*(*!dustem_data).uext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).uext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue'
  2796 + ENDIF
  2797 + ENDIF
  2798 +
  2799 +
  2800 + endif else begin ;The data points in the plot that remain unchanged
  2801 + ;stop
  2802 +
  2803 + xtit=textoidl('1/\lambda (\mum^{-1})')
  2804 + ;if !run_pol then xtit = ''
  2805 + cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
  2806 + xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
  2807 +
  2808 + endelse
  2809 +
  2810 +
  2811 + endif else begin ; normal plot - STOPPED HERE FOR QSED
  2812 +
  2813 + if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
  2814 +
  2815 + if keyword_set(positive_only) then begin
  2816 +
  2817 + if testpstv ne 0 then begin
  2818 +
  2819 + FOR i=0L,Ngrains-1 DO BEGIN
  2820 +
  2821 + vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
  2822 + vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
  2823 +
  2824 + testneq = where( vecto ne 0,countneq)
  2825 + ;stop
  2826 + if countneq ne 0 then begin
  2827 + vecfin = vecto*0.0 ;em_tot can be used here right?
  2828 + ;stop
  2829 + vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2830 + ;stop
  2831 + ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
  2832 + polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
  2833 +
  2834 + ;stop
  2835 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  2836 + dustem_plot_mlog,1/st.polext.wav,specugrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2837 + ;stop
  2838 + endif
  2839 + ;stop
  2840 + ENDFOR
  2841 +
  2842 + for i=0L,n_plgns-1 do begin
  2843 +
  2844 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2845 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  2846 +
  2847 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  2848 + dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2849 + ENDIF
  2850 + ENDIF
  2851 + endfor
  2852 +
  2853 + IF ct_spec NE 0 THEN BEGIN
  2854 + xx=((*(*!dustem_data).uext).wav)[idx_spec]
  2855 + yy=dustem_interp[idx_spec]
  2856 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2857 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2858 + ENDIF
  2859 +
  2860 + IF ct_filt NE 0 THEN BEGIN
  2861 + xx=((*(*!dustem_data).uext).wav)[idx_filt]
  2862 + yy=dustem_interp[idx_filt]
  2863 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2864 + dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2865 + ENDIF
  2866 +
  2867 + dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2868 +
  2869 + endif
  2870 +
  2871 +
  2872 + endif
  2873 +
  2874 + ;stop
  2875 + if keyword_set(negative_only) then begin
  2876 + ;stop
  2877 + if testngtv ne 0 then begin
  2878 +
  2879 +
  2880 + ;Plotting of the spectra of the dust species
  2881 + FOR i=0L,Ngrains-1 DO BEGIN
  2882 + vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
  2883 + vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
  2884 + testneq = where( vecto ne 0,countneq)
  2885 + ;stop
  2886 + if countneq ne 0 then begin
  2887 + vecfin = vecto*0.0 ;em_tot can be used here right?
  2888 + ;stop
  2889 + vecfin[testneq] = vecto[testneq]/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
  2890 + ;stop
  2891 + polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
  2892 + ;stop
  2893 + ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog
  2894 + dustem_plot_mlog,1/st.polext.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2895 + endif
  2896 + ENDFOR
  2897 + ;Plotting of the plugins
  2898 + for i=0L,n_plgns-1 do begin
  2899 + IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
  2900 +
  2901 + IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
  2902 +
  2903 + ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
  2904 + dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2905 + ENDIF
  2906 +
  2907 + ENDIF
  2908 + endfor
  2909 + ;PLotting of the interpolates corresponding to spectrum and filter points
  2910 + IF ct_spec NE 0 THEN BEGIN
  2911 + xx=((*(*!dustem_data).uext).wav)[idx_spec]
  2912 + yy=dustem_interp[idx_spec]
  2913 + ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
  2914 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2915 + ENDIF
  2916 +
  2917 + IF ct_filt NE 0 THEN BEGIN
  2918 + xx=((*(*!dustem_data).uext).wav)[idx_filt]
  2919 + yy=dustem_interp[idx_filt]
  2920 + ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
  2921 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2922 + ENDIF
  2923 + ;Plotting of the total dust emission spectrum
  2924 + dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
  2925 +
  2926 + endif
  2927 +
  2928 +
  2929 + endif
  2930 +
  2931 + ;stop
  2932 + endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE.
  2933 + ;stop
  2934 + ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
  2935 + xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
  2936 + ;if ct_hdnpts ne 0 then begin ;Hidden data points are present
  2937 +
  2938 + ;Locating the hidden spectrum and filter data points
  2939 + ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.
  2940 + ;idx_filt_hdn = where(((*(*!dustem_show).qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
  2941 + ;idx_spec_hdn = where(((*(*!dustem_show).qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
  2942 + if ct_hdnpts then begin
  2943 + idx_filt_hdn_pstv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
  2944 + idx_spec_hdn_pstv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
  2945 + idx_filt_hdn_ngtv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
  2946 + idx_spec_hdn_ngtv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
  2947 + endif
  2948 +
  2949 +
  2950 + if keyword_set(positive_only) then begin
  2951 +
  2952 +
  2953 +
  2954 + if ct_spec ne 0 then begin
  2955 +
  2956 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
  2957 + ;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)'
  2958 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  2959 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,color='Powder 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)'
  2960 +
  2961 + endif
  2962 +
  2963 + if ct_filt ne 0 then begin
  2964 +
  2965 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2.
  2966 + ; 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)'
  2967 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).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)'
  2968 + if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).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)'
  2969 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).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)'
  2970 +
  2971 + endif
  2972 +
  2973 +
  2974 + if testpstv ne 0 then begin
  2975 +
  2976 + plotsym, 0
  2977 +
  2978 + if ct_hdnpts NE 0 then begin
  2979 +
  2980 + if ct_spec_hdn_pstv ne 0 then begin
  2981 + xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2982 + yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
  2983 + rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
  2984 +
  2985 + dustem_plot_mlog,1/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
  2986 + dustem_plot_mlog,1/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
  2987 +
  2988 + endif
  2989 +
  2990 + if ct_filt_hdn_pstv ne 0 then begin
  2991 +
  2992 + xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2993 + yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
  2994 + rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
  2995 +
  2996 + dustem_plot_mlog,1/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
  2997 + dustem_plot_mlog,1/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
  2998 +
  2999 + endif
  3000 +
  3001 + endif
  3002 + endif else begin
  3003 +
  3004 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  3005 +
  3006 +
  3007 + if ct_filt ne 0 and ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),-((*(*!dustem_data).uext).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)'
  3008 +
  3009 +
  3010 + endelse
  3011 +
  3012 +
  3013 + endif
  3014 +
  3015 +
  3016 + if keyword_set(negative_only) then begin
  3017 +
  3018 + if testngtv ne 0 then begin
  3019 +
  3020 + plotsym, 0
  3021 +
  3022 +
  3023 + if ct_spec ne 0 then begin
  3024 +
  3025 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
  3026 + ;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)'
  3027 + ; 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
  3028 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  3029 + ;endelse;,ytickformat='(A1)'
  3030 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,color='Powder Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8
  3031 +
  3032 + endif
  3033 +
  3034 + if ct_filt ne 0 then begin
  3035 +
  3036 + rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2.
  3037 + ; 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)'
  3038 + ;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
  3039 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).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)'
  3040 + if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).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)'
  3041 + ;endelse ;,ytickformat='(A1)'
  3042 +
  3043 + dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
  3044 +
  3045 + endif
  3046 +
  3047 + if ct_hdnpts NE 0 then begin
  3048 +
  3049 + if ct_spec_hdn_ngtv ne 0 then begin
  3050 + xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  3051 + yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
  3052 + rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
  3053 +
  3054 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  3055 + dustem_plot_mlog,1/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
  3056 +
  3057 + endif
  3058 +
  3059 + if ct_filt_hdn_ngtv ne 0 then begin
  3060 +
  3061 + xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  3062 + yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
  3063 + rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
  3064 +
  3065 + dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
  3066 + dustem_plot_mlog,1/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
  3067 +
  3068 + endif
  3069 +
  3070 + endif
  3071 +
  3072 + endif else begin
  3073 +
  3074 + if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),-((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
  3075 +
  3076 +
  3077 + if ct_filt ne 0 and ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),-((*(*!dustem_data).uext).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)'
  3078 +
  3079 +
  3080 + endelse
  3081 + ;stop
  3082 + endif
  3083 +
  3084 +
  3085 + endelse
  3086 +
  3087 + endelse
  3088 +
  3089 + endelse
  3090 +
  3091 + end
  3092 +
  3093 + 'PARAMETERS':begin ;needs the followingd data (errors+res+formats)
  3094 +
  3095 + p_dim = extra_spec
  3096 + ;stop
  3097 + Npar=n_elements(p_dim)
  3098 +
  3099 + if keyword_set(refresh) then begin ;data in the parameter window that is being refreshed
  3100 +
  3101 + k=0
  3102 +
  3103 +
  3104 + IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
  3105 +
  3106 + Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
  3107 + res = (*(*!dustem_fit).fixed_param_init_values)
  3108 +
  3109 + FOR i=0L,Nfpar-1 DO BEGIN
  3110 +
  3111 + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]
  3112 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3113 + ;Not sure about the wrapper data type that is mentioned in this procedure
  3114 + IF parameter_type NE 'PLUGIN' THEN BEGIN
  3115 + yypos = 0.8 - k*0.09
  3116 + k+=1
  3117 + ENDIF
  3118 +
  3119 + ENDFOR
  3120 +
  3121 +
  3122 + ENDIF
  3123 +
  3124 +
  3125 + prms_dscs = (*(*!dustem_fit).param_descs)
  3126 + prms_tps = strarr(n_elements(prms_dscs))
  3127 +
  3128 + for i=0L,n_elements(prms_dscs)-1 do begin
  3129 + prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
  3130 + endfor
  3131 +
  3132 + testprms = where(prms_tps ne 'PLUGIN', ct_data)
  3133 + if ct_data ne 0 then begin
  3134 +
  3135 + if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
  3136 +
  3137 +
  3138 + res = dustem_interp
  3139 + errors = dustem_spec
  3140 + yypostmp = yypos
  3141 + k=0
  3142 + FOR i=0L,Npar-1 DO BEGIN
  3143 +
  3144 + parameter_description = (*(*!dustem_fit).param_descs)[i]
  3145 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3146 + testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
  3147 +
  3148 + IF parameter_type EQ 'FORTRAN' and testpop then begin
  3149 +
  3150 + indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
  3151 + string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
  3152 +
  3153 + ;choosing a step of 0.03 in norm coordinates
  3154 + yypos = yypostmp - k*0.09
  3155 + xxpos = 0.0
  3156 +
  3157 + ;original line
  3158 + ;str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1)
  3159 +
  3160 + str = strtrim(string(string_name+' = ',format=frmt0),2)+ string(res[i],format=frmt1) + textoidl(' \pm ') +string(errors(i),format=frmt1)
  3161 + ;will this work?
  3162 + cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
  3163 + xxpos = (1-thiswidth)/2
  3164 + str = strtrim(string(string_name+' = ',format=frmt0),2)
  3165 + cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
  3166 + xxpos+= thiswidth
  3167 +
  3168 + str= string(res[i],format=frmt1) + textoidl(' \pm ') + string(errors(i),format=frmt1)
  3169 + ;stop
  3170 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3171 + k+=1
  3172 +
  3173 + ENDIF
  3174 +
  3175 +
  3176 + IF parameter_type EQ 'FORTRAN' and ~testpop then begin
  3177 +
  3178 + ;indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
  3179 + ;string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
  3180 +
  3181 +
  3182 + yypos = yypostmp - k*0.09
  3183 + xxpos = 0.0
  3184 +
  3185 + ;original line
  3186 + ;str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1)
  3187 +
  3188 + str = strtrim(string(string_name+' = ',format=frmt0),2)+ string(res[i],format=frmt1) + textoidl(' \pm ') +string(errors(i),format=frmt1)
  3189 + ;will this work?
  3190 + cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
  3191 + xxpos = (1-thiswidth)/2
  3192 + str = strtrim(string(string_name+' = ',format=frmt0),2)
  3193 + cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
  3194 + xxpos+= thiswidth
  3195 +
  3196 + str= string(res[i],format=frmt1) + textoidl(' \pm ') + string(errors(i),format=frmt1)
  3197 + ;stop
  3198 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3199 + k+=1
  3200 +
  3201 + ENDIF
  3202 +
  3203 +
  3204 + ENDFOR
  3205 +
  3206 + ENDIF
  3207 +
  3208 + endif else begin ;data in the parameter window that is unchanged
  3209 +
  3210 + ;Trying to gather information on the fixed parameters
  3211 + ;Two pointers assuming one is sufficient for the following condition (unless dustem_init_fixed_parameters)
  3212 + ;WILL THIS WORK?
  3213 +
  3214 + IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
  3215 +
  3216 + Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
  3217 + res = (*(*!dustem_fit).fixed_param_init_values)
  3218 + k = 0
  3219 + xxpos = 0.0
  3220 + yypos = 0.9
  3221 + ;xxpos = 0.0 ;might need to be modified
  3222 + cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal
  3223 + xxpos=(1-thiswidth)/2
  3224 + xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
  3225 +
  3226 + FOR i=0L,Nfpar-1 DO BEGIN
  3227 +
  3228 + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]
  3229 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3230 + testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
  3231 + IF parameter_type NE 'PLUGIN' THEN BEGIN
  3232 +
  3233 + IF parameter_type EQ 'FORTRAN' and testpop then begin
  3234 +
  3235 + indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
  3236 + string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
  3237 +
  3238 + ENDIF
  3239 +
  3240 + yypos = 0.8 - k*0.09
  3241 + xxpos = 0.0
  3242 +
  3243 + str=strtrim(string(string_name+' = ',format=frmt0),2)
  3244 + str1=str+string(res[i],format=frmt1)
  3245 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3246 + xxpos=(1-thiswidth)/2
  3247 + ;stop
  3248 + xyouts,xxpos,yypos,str1,color=0,/normal,charsize=1.
  3249 + k+=1
  3250 +
  3251 + ENDIF
  3252 +
  3253 + ENDFOR
  3254 +
  3255 + ENDIF
  3256 +
  3257 +
  3258 +
  3259 + ;stop
  3260 + xxpos = 0.0;might need to be modified
  3261 +
  3262 + ;test so that this string isn't displayed when there are no free parameters:
  3263 +
  3264 + prms_dscs = (*(*!dustem_fit).param_descs)
  3265 + prms_tps = strarr(n_elements(prms_dscs))
  3266 +
  3267 + for i=0L,n_elements(prms_dscs)-1 do begin
  3268 + prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
  3269 + endfor
  3270 +
  3271 + testprms = where(prms_tps ne 'PLUGIN', ct_data)
  3272 +
  3273 + IF ct_data ne 0 then begin
  3274 +
  3275 + if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
  3276 +
  3277 + cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal
  3278 +
  3279 + xxpos=(1-thiswidth)/2
  3280 + xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
  3281 +
  3282 + ;stop
  3283 + k=0
  3284 + res = dustem_interp
  3285 + errors = dustem_spec
  3286 + ;stop
  3287 +
  3288 + yypos-=0.1
  3289 + yypostmp = yypos
  3290 + FOR i=0L,Npar-1 DO BEGIN
  3291 +
  3292 + parameter_description = (*(*!dustem_fit).param_descs)[i]
  3293 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3294 + testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
  3295 + ;stop
  3296 + ;STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).'
  3297 +
  3298 + IF parameter_type EQ 'FORTRAN' and testpop then begin
  3299 +
  3300 + indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
  3301 + string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
  3302 +
  3303 +
  3304 + yypos = yypostmp - k*0.09
  3305 + xxpos = 0.0
  3306 +
  3307 + str=strtrim(string(string_name+' = ',format=frmt0),2)
  3308 + ;stop
  3309 + str1=str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
  3310 + ;stop
  3311 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3312 + xxpos=(1-thiswidth)/2
  3313 + ;stop
  3314 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3315 +
  3316 + k+=1
  3317 + ;stop
  3318 + ENDIF
  3319 +
  3320 + ;STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).'
  3321 + IF parameter_type EQ 'FORTRAN' and ~testpop then begin
  3322 +
  3323 + ;indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
  3324 + ;string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
  3325 + ;stop
  3326 + ;choosing a step of 0.03 in norm coordinates
  3327 +
  3328 + yypos = yypostmp - k*0.09
  3329 + xxpos = 0.0
  3330 +
  3331 + str=strtrim(string(string_name+' = ',format=frmt0),2)
  3332 + ;stop
  3333 + str1=str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
  3334 + ;stop
  3335 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3336 + xxpos=(1-thiswidth)/2
  3337 + ;stop
  3338 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3339 +
  3340 + k+=1
  3341 + ;stop
  3342 + ENDIF
  3343 +
  3344 + ENDFOR
  3345 +
  3346 + ENDIF
  3347 +
  3348 +
  3349 + endelse
  3350 +
  3351 + end
  3352 +
  3353 + 'PLUGINS':begin ;NOT SO SURE ABOUT THIS BLOCK . TEST IT WHEN YOU GET HOME
  3354 +
  3355 + p_dim = extra_spec
  3356 +
  3357 + Npar=n_elements(p_dim)
  3358 +
  3359 + if keyword_set(refresh) then begin ;(REFRESHED RUN)
  3360 +
  3361 + IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
  3362 +
  3363 + Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
  3364 + res = (*(*!dustem_fit).fixed_param_init_values)
  3365 + k=0
  3366 + FOR i=0L,Nfpar-1 DO BEGIN
  3367 +
  3368 + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]
  3369 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3370 + ;Not sure about the wrapper data type that is mentioned in this procedure
  3371 + IF parameter_type EQ 'PLUGIN' THEN BEGIN
  3372 + yypos = 0.8 - k*0.09
  3373 + k+=1
  3374 + ENDIF
  3375 +
  3376 + ENDFOR
  3377 +
  3378 +
  3379 + ENDIF
  3380 +
  3381 +
  3382 + prms_dscs = (*(*!dustem_fit).param_descs)
  3383 + prms_tps = strarr(n_elements(prms_dscs))
  3384 +
  3385 + for i=0L,n_elements(prms_dscs)-1 do begin
  3386 + prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
  3387 + endfor
  3388 +
  3389 + testprms = where(prms_tps EQ 'PLUGIN', ct_data)
  3390 +
  3391 + if ct_data ne 0 then begin
  3392 +
  3393 + if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
  3394 +
  3395 +
  3396 + k=0
  3397 + res = dustem_interp
  3398 + errors = dustem_spec
  3399 + yypostmp = yypos
  3400 +
  3401 + FOR i=0L,Npar-1 DO BEGIN
  3402 + ;stop
  3403 + parameter_description = (*(*!dustem_fit).param_descs)[i]
  3404 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3405 +
  3406 + IF parameter_type EQ 'PLUGIN' THEN BEGIN
  3407 +
  3408 + ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
  3409 + mm = where(tag_names(*!dustem_plugin) eq strupcase(strmid(string_name,7,ii-7))) ;,coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector
  3410 + prmtg = (*(*!dustem_plugin).(mm).paramtag)
  3411 + indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)
  3412 + indtg = fix(indtg)
  3413 + prmtg = prmtg[indtg-1]
  3414 + yypos = yypostmp - k*0.09
  3415 + xxpos = 0.0
  3416 +
  3417 + str = strtrim(string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0),2)
  3418 + str1 = str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
  3419 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3420 + xxpos=(1-thiswidth)/2
  3421 + cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
  3422 + xxpos+=thiswidth;(1-thiswidth)/2
  3423 + str = string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
  3424 +
  3425 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3426 + k+=1
  3427 +
  3428 + ENDIF
  3429 +
  3430 +
  3431 + ENDFOR
  3432 +
  3433 + ENDIF
  3434 +
  3435 + endif else begin ;(FROZEN RUN = title strings + fixed plugins (TBDONE))
  3436 +
  3437 +
  3438 +
  3439 + IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
  3440 +
  3441 + Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
  3442 + res = (*(*!dustem_fit).fixed_param_init_values)
  3443 +
  3444 + iii=0
  3445 + FOR i=0L,Nfpar-1 DO BEGIN
  3446 +
  3447 + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]
  3448 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3449 + if parameter_type EQ 'PLUGIN' then iii+=1
  3450 +
  3451 + ENDFOR
  3452 + k = 0
  3453 + if iii ne 0 then begin
  3454 + xxpos = 0.0
  3455 + yypos = 0.9
  3456 + ;xxpos = 0.0 ;might need to be modified
  3457 + cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal
  3458 + xxpos=(1-thiswidth)/2
  3459 + xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
  3460 + endif
  3461 + FOR i=0L,Nfpar-1 DO BEGIN
  3462 +
  3463 + parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]
  3464 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3465 + testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
  3466 +
  3467 + IF parameter_type EQ 'PLUGIN' THEN BEGIN
  3468 +
  3469 +
  3470 + ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
  3471 + mm = where(tag_names(*!dustem_plugin) eq strupcase(strmid(string_name,7,ii-7))) ;,coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector
  3472 + prmtg = (*(*!dustem_plugin).(mm).paramtag)
  3473 + indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)
  3474 + indtg = fix(indtg)
  3475 + prmtg = prmtg[indtg-1]
  3476 +
  3477 + yypos = 0.8 - k*0.09
  3478 + xxpos = 0.0
  3479 +
  3480 + str = string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0)
  3481 + str=strtrim(str,2)
  3482 + str1=str+string(res[i],format=frmt1)
  3483 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3484 + xxpos=(1-thiswidth)/2
  3485 + ;stop
  3486 + xyouts,xxpos,yypos,str1,color=0,/normal,charsize=1.
  3487 + k+=1
  3488 +
  3489 + ENDIF
  3490 +
  3491 + ENDFOR
  3492 +
  3493 + ENDIF
  3494 +
  3495 + xxpos = 0
  3496 +
  3497 + prms_dscs = (*(*!dustem_fit).param_descs)
  3498 + prms_tps = strarr(n_elements(prms_dscs))
  3499 +
  3500 + for i=0L,n_elements(prms_dscs)-1 do begin
  3501 + prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
  3502 + endfor
  3503 +
  3504 + testprms = where(prms_tps EQ 'PLUGIN', ct_data)
  3505 +
  3506 + IF ct_data ne 0 then begin
  3507 +
  3508 +
  3509 + if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
  3510 + ;stop
  3511 + ;xxpos = 0.0;might need to be modified
  3512 + cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal
  3513 +
  3514 + xxpos=(1-thiswidth)/2
  3515 + xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
  3516 +
  3517 +
  3518 + k=0
  3519 + res = dustem_interp
  3520 + errors = dustem_spec
  3521 + yypos-=0.1
  3522 + yypostmp = yypos
  3523 +
  3524 + FOR i=0L,Npar-1 DO BEGIN
  3525 + ;stop
  3526 + parameter_description = (*(*!dustem_fit).param_descs)[i]
  3527 + parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
  3528 +
  3529 +
  3530 + IF parameter_type EQ 'PLUGIN' THEN BEGIN
  3531 +
  3532 + ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
  3533 + mm = where(tag_names(*!dustem_plugin) eq strupcase(strmid(string_name,7,ii-7))) ;,coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector
  3534 + prmtg = (*(*!dustem_plugin).(mm).paramtag)
  3535 + indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)
  3536 + indtg = fix(indtg)
  3537 + prmtg = prmtg[indtg-1]
  3538 +
  3539 + yypos = yypostmp - k*0.09
  3540 + xxpos = 0.0;15
  3541 +
  3542 + str = string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0)
  3543 + str=strtrim(str,2)
  3544 + str1 = str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
  3545 + ;getting the width of the total string: string title +values +errors so we can place it the right way and not have to worry about its position
  3546 +
  3547 + cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
  3548 + xxpos=(1-thiswidth)/2
  3549 +
  3550 + xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
  3551 + k+=1
  3552 +
  3553 + ENDIF
  3554 +
  3555 +
  3556 +
  3557 + ENDFOR
  3558 + ENDIF
  3559 + endelse
  3560 +
  3561 +
  3562 +
  3563 + end
  3564 +
  3565 +
  3566 + endcase
  3567 +
  3568 +
  3569 +endif
  3570 +
  3571 +
  3572 +the_end:
  3573 +
  3574 +
  3575 +END
... ...
src/idl/dustem_plugin_stellar_population.pro
... ... @@ -4,11 +4,11 @@ Function dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramt
4 4 ; NAME:
5 5 ; dustem_plugin_stellar_population
6 6 ; PURPOSE:
7   -; Produces a system variable called '!dustem_composite_stellar_population' in which a structure containing parameters pertaining to (a) stellar population(s) is placed
  7 +; replaces the default DUSTEM ISRF with a composite stellar spectrum
8 8 ; CATEGORY:
9 9 ; DUSTEM Wrapper
10 10 ; CALLING SEQUENCE:
11   -; dustem_create_plugin_population(key=key,val=val)
  11 +; dustem_plugin_stellar_population(key=key,val=val)
12 12 ; INPUTS:
13 13 ; None
14 14 ; OPTIONAL INPUT PARAMETERS:
... ... @@ -50,14 +50,13 @@ IF keyword_set(paramtag) THEN BEGIN
50 50 ENDIF
51 51 ;DATA IS NOW RETRIEVED FROM THIS TEXT FILE: "A Modern Mean Dwarf Stellar Color and Effective Temperature Sequence"
52 52 ;NB: intermediate spectral classes '.5' are not taken into account - this will probably have to change
53   -;NB: Also contact the one who wrote the text file because he said so in it.
  53 +;NB: Also contact we need to contact the one who wrote the text file because he said so in it.
54 54  
55 55 ;Other parameters of other luminosity classed are being looked into.
56 56 ;BB approximation is a first degree 'bad' approximation because of the lack of radiative transfer especially at the
57 57 ;photosphere of stars.
58 58  
59 59  
60   -
61 60 ;REMARKS: BECAUSE I STILL HAVEN'T SET THE DEFAULT VALUE FOR THE MAJORIY OF THE STELLAR POULATIONS, I WILL COMMENT THE CORRESPONDING LINES INSTEAD OF CHOOSING ARBITRARY VALUES.
62 61  
63 62  
... ... @@ -3666,7 +3665,7 @@ FOR i=0L,n_elements(comp_pop.popid)-1 DO BEGIN ; Looping over all the stellar po
3666 3665 ;we need an index
3667 3666  
3668 3667 id_fftmp = where(strupcase(strmid((*(*!dustem_fit).param_descs),14)) EQ 'FREEFREE_1',ct_fftmp)
3669   - if ct_fftmp ne 0 then Te = ((*!dustem_current_params)[id_fftmp])[0]*(((*(*!dustem_fit).param_init_values))[id_fftmp])[0]
  3668 + if ct_fftmp ne 0 then Te = ((*(*!dustem_fit).current_param_values)[id_fftmp])[0]*(((*(*!dustem_fit).param_init_values))[id_fftmp])[0]
3670 3669 ; test if Te is correct
3671 3670  
3672 3671 Beta2 = 2.e-10*(Te)^(-3/4) ;cm^3/s-1
... ...
src/idl/dustem_set_plot_range.pro 0 โ†’ 100644
... ... @@ -0,0 +1,695 @@
  1 +PRO dustem_set_plot_range ,test_m,test_x, _extra=_extra ,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_set_plot_range
  6 +; PURPOSE:
  7 +; Sets the X and Y plotting ranges for the different datasets in emission and extinction when in polarization mode and not (using the _extra structure).
  8 +; CATEGORY:
  9 +; DustEMWrap
  10 +; CALLING SEQUENCE:
  11 +; dustem_set_plot_range,test_m,test_x,_extra=_extra
  12 +; INPUTS:
  13 +; test_m : (Boolean) signaling emission mode
  14 +; test_x : (Boolean) signaling extinction mode
  15 +; OPTIONAL INPUT PARAMETERS:
  16 +; _extra structure containing the plotting keywords
  17 +; OUTPUTS:
  18 +; NONE
  19 +; OPTIONAL OUTPUT PARAMETERS:
  20 +;
  21 +; ACCEPTED KEY-WORDS:
  22 +; help
  23 +; COMMON BLOCKS:
  24 +; None
  25 +; SIDE EFFECTS:
  26 +; Changes the default plotting parameters in the !dustem_plot_range pointer.
  27 +; The procedure only works with the presence of the _extra structure
  28 +; RESTRICTIONS:
  29 +; The DustEM fortran code must be installed
  30 +; The DustEMWrap IDL code must be installed
  31 +; PROCEDURES AND SUBROUTINES USED:
  32 +;
  33 +; EXAMPLES
  34 +; dustem_set_plot_range ,test_m,test_x, _extra=_extra
  35 +; MODIFICATION HISTORY:
  36 +; Written by Ilyes Choubani
  37 +; Evolution details on the DustEMWrap gitlab.
  38 +;-
  39 +
  40 +IF keyword_set(help) THEN BEGIN
  41 + doc_library,'dustemw_set_plot_range'
  42 + goto,the_end
  43 +END
  44 +
  45 +IF keyword_set(_extra) THEN BEGIN
  46 +
  47 + tgnms_extra = tag_names(_extra)
  48 +
  49 + ; ;Now testing on what is in the _extra structure.
  50 + IF test_m and ~test_x THEN BEGIN ;EMISSION ALONE
  51 +
  52 + IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE DASHBOARD
  53 +
  54 + ;Setting of tHE X-RANGE
  55 + ;taking into account as many entries as possible
  56 + tsxr = strmid(strupcase(tgnms_extra),0,2) EQ 'XR' or $
  57 + strupcase(tgnms_extra) EQ 'XRANGE' or $
  58 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  59 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  60 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  61 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION')
  62 +
  63 + idxr = where(tsxr,ctestxr)
  64 +
  65 + ;There is no error testing on X ranges because there is only one X range
  66 +
  67 + ;THIS WILL ONLY CONCERN THE Y RANGES
  68 +
  69 + tst = STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'SED' and $
  70 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE '_EM' and $
  71 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'RAC'
  72 +
  73 + idyr = where((strmid(strupcase(tgnms_extra),0,2) EQ 'YR'and tst) or $
  74 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  75 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  76 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  77 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  78 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION'),ctestyr) ;(strsplit(tgnms_extra,'_')) NE [0],ctestyr)
  79 +
  80 +
  81 + if ctestyr ne 0 then message, 'You have provided one Y-range when multiple ones have to be provided.', /continue
  82 +
  83 + idyr_polsed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  84 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'POLSED',ctyr_polsed)
  85 +
  86 + idyr_psi_em = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  87 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'PSI_EM',ctyr_psi_em)
  88 +
  89 + idyr_used = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  90 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'USED',ctyr_used)
  91 +
  92 + idyr_sed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  93 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) NE 'POLSED' and $
  94 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'QSED' and $
  95 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'USED' and $
  96 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) EQ 'SED',ctyr_sed)
  97 +
  98 + idyr_polfrac = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  99 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'OLFRAC',ctyr_polfrac)
  100 +
  101 + idyr_qsed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  102 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'QSED',ctyr_qsed)
  103 +
  104 +
  105 + ;SETTING THE TITLE
  106 +
  107 + idtit = where(strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' or $
  108 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  109 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  110 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  111 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION') , ctestit)
  112 +
  113 +
  114 +
  115 +
  116 + ;FILLING UP X ranges (same xrange)
  117 +
  118 + IF ctestxr ne 0 THEN BEGIN
  119 +
  120 + FOR i=0L,(n_tags(!dustem_plot_range)-3)/2 DO BEGIN ; THIS IS EMISSION , extinction will have to from (n_tags(!dustem_plot_range)-2)/2+1 to (n_tags(!dustem_plot_range)-2)
  121 +
  122 + !dustem_plot_range.(i).xr=_extra.(idxr)
  123 +
  124 + ENDFOR
  125 +
  126 +
  127 + ENDIF ;else the default xr is kept
  128 +
  129 + ;FILLING UP Y RANGES
  130 +
  131 +
  132 + if ctyr_polsed ne 0 then !dustem_plot_range.(3).yr = _extra.(idyr_polsed)
  133 +
  134 +
  135 + if ctyr_psi_em ne 0 then !dustem_plot_range.(5).yr = _extra.(idyr_psi_em)
  136 +
  137 +
  138 + if ctyr_used ne 0 then !dustem_plot_range.(2).yr = _extra.(idyr_used)
  139 +
  140 +
  141 + if ctyr_sed ne 0 then !dustem_plot_range.(0).yr = _extra.(idyr_sed)
  142 +
  143 +
  144 + if ctyr_polfrac ne 0 then !dustem_plot_range.(4).yr = _extra.(idyr_polfrac)
  145 +
  146 +
  147 + if ctyr_qsed ne 0 then !dustem_plot_range.(1).yr = _extra.(idyr_qsed)
  148 +
  149 +
  150 + if ctestit ne 0 then !dustem_plot_range.(12) = _extra.(idtit)
  151 + stop
  152 +
  153 + ENDIF ELSE BEGIN ;ONE DATA SET : SED - - - -
  154 +
  155 + tsxr = strmid(strupcase(tgnms_extra),0,2) EQ 'XR' or $
  156 + strupcase(tgnms_extra) EQ 'XRANGE' or $
  157 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  158 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  159 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  160 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION')
  161 +
  162 + idxr = where(tsxr,ctestxr)
  163 + ;FILLING UP X ranges (same xrange)
  164 +
  165 + IF ctestxr ne 0 THEN !dustem_plot_range.(0).xr=_extra.(idxr)
  166 +
  167 + idyr = where(strmid(strupcase(tgnms_extra),0,2) EQ 'YR' or $
  168 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  169 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  170 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  171 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  172 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION'),ctestyr)
  173 +
  174 + ;Filling up the Y range
  175 + if ctestyr ne 0 then !dustem_plot_range.(0).yr = _extra.(idyr)
  176 +
  177 + ;SETTING THE TITLE
  178 +
  179 + idtit = where(strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' or $
  180 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  181 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  182 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  183 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION') , ctestit)
  184 +
  185 + if ctestit ne 0 then !dustem_plot_range.(12) = _extra.(idtit)
  186 +
  187 + ENDELSE
  188 +
  189 +
  190 + ENDIF
  191 +
  192 +
  193 + IF test_x and ~test_m THEN BEGIN ;EXTINCTION ALONE
  194 +
  195 +
  196 +
  197 + IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE DASHBOARD
  198 +
  199 +
  200 + ;Setting of tHE X-RANGE
  201 + ;taking into account as many entries as possible
  202 + tsxr = strmid(strupcase(tgnms_extra),0,2) EQ 'XR' or $
  203 + strupcase(tgnms_extra) EQ 'XRANGE' or $
  204 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  205 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  206 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  207 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION')
  208 +
  209 + idxr = where(tsxr,ctestxr)
  210 +
  211 +
  212 + tst = STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'EXT'
  213 +
  214 + idyr = where((strmid(strupcase(tgnms_extra),0,2) EQ 'YR'and tst) or $
  215 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  216 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  217 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  218 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  219 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION'),ctestyr) ;
  220 +
  221 +
  222 + if ctestyr ne 0 then message, 'You have provided one Y-range when multiple Y-ranges have to be provided.',/continue
  223 +
  224 +
  225 + idyr_polext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  226 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ '_POLEXT',ctyr_polext)
  227 +
  228 + idyr_psi_ext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  229 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ 'PSI_EXT',ctyr_psi_ext)
  230 +
  231 + idyr_uext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  232 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'UEXT',ctyr_uext)
  233 +
  234 + idyr_fpolext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  235 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ 'FPLOEXT',ctyr_fpolext)
  236 +
  237 + idyr_qext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  238 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'QEXT',ctyr_qext)
  239 +
  240 + testext = strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  241 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) EQ 'EXT' and $
  242 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE '_POLEXT' and $
  243 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE 'FPOLEXT' and $
  244 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE 'PSI_EXT' and $
  245 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'UEXT' and $
  246 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'QEXT'
  247 +
  248 + idyr_ext = where(testex,ctyr_ext)
  249 +
  250 +
  251 + ;SETTING THE TITLE
  252 +
  253 + idtit = where(strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' or $
  254 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  255 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  256 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  257 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION') , ctestit)
  258 +
  259 +
  260 + ;FILLING UP Xranges (same xrange)
  261 +
  262 + IF ctestxr ne 0 THEN BEGIN
  263 +
  264 + FOR i=(n_tags(!dustem_plot_range)-2)/2+1,(n_tags(!dustem_plot_range)-2) DO BEGIN ; THIS IS EMISSION , extinction will have to from (n_tags(!dustem_plot_range)-2)/2+1 to (n_tags(!dustem_plot_range)-2)
  265 +
  266 + !dustem_plot_range.(i).xr=_extra.(idxr)
  267 +
  268 + ENDFOR
  269 +
  270 +
  271 + ENDIF ;else the default xr is kept
  272 +
  273 +
  274 + ;FILLING UP Y RANGES
  275 +
  276 +
  277 + if ctyr_polext ne 0 then !dustem_plot_range.(9).yr = _extra.(idyr_polext)
  278 +
  279 +
  280 + if ctyr_psi_ext ne 0 then !dustem_plot_range.(11).yr = _extra.(idyr_psi_ext)
  281 +
  282 +
  283 + if ctyr_uext ne 0 then !dustem_plot_range.(8).yr = _extra.(idyr_uext)
  284 +
  285 +
  286 + if ctyr_ext ne 0 then !dustem_plot_range.(6).yr = _extra.(idyr_ext)
  287 +
  288 +
  289 + if ctyr_fpolext ne 0 then !dustem_plot_range.(10).yr = _extra.(idyr_fpolext)
  290 +
  291 +
  292 + if ctyr_qext ne 0 then !dustem_plot_range.(7).yr = _extra.(idyr_qext)
  293 +
  294 +
  295 + if ctestit ne 0 then !dustem_plot_range.(13) = _extra.(idtit)
  296 +
  297 +
  298 + ENDIF ELSE BEGIN ;ONE DATA SET : EXT
  299 +
  300 +
  301 + tsxr = strmid(strupcase(tgnms_extra),0,2) EQ 'XR' or $
  302 + strupcase(tgnms_extra) EQ 'XRANGE' or $
  303 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  304 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  305 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  306 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION')
  307 +
  308 + idxr = where(tsxr,ctestxr)
  309 +
  310 + ;FILLING UP X ranges (same xrange)
  311 +
  312 + IF ctestxr ne 0 THEN !dustem_plot_range.(6).xr=_extra.(idxr)
  313 +
  314 +
  315 +
  316 + ;NB: Counters in this loop and in the loop above do not necessarily serve the same function
  317 + idyr = where(strmid(strupcase(tgnms_extra),0,2) EQ 'YR' or $
  318 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  319 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  320 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  321 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  322 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION'),ctestyr) ;
  323 +
  324 + if ctestyr ne 0 then !dustem_plot_range.(6).yr = _extra.(idyr)
  325 +
  326 + ;SETTING THE TITLE
  327 +
  328 + idtit = where(strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' or $
  329 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  330 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  331 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  332 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION') , ctestit)
  333 +
  334 +
  335 + if ctestit ne 0 then !dustem_plot_range.(13) = _extra.(idtit)
  336 +
  337 +
  338 + ENDELSE
  339 +
  340 + ENDIF
  341 +
  342 +
  343 +
  344 + IF test_m and test_x THEN BEGIN ;EMISSION and EXTINCTION
  345 +
  346 +
  347 + IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE SED DASHBOARD & EXT DASHBOARD
  348 +
  349 +
  350 + tstxr = strupcase(tgnms_extra) EQ 'XRANGE' or $
  351 + strupcase(tgnms_extra) EQ 'XR' or $
  352 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  353 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  354 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  355 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  356 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  357 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  358 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  359 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION')
  360 +
  361 + idxr = where(tstxr,ctestxr)
  362 +
  363 + if ctestxr ne 0 then message, 'You have provided one X-range when multiple ones are needed',/continue
  364 +
  365 + t_m = (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  366 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  367 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  368 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION')
  369 +
  370 + indxr_m = where(t_m,ctestxr_m)
  371 +
  372 +
  373 +
  374 + t_x = (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  375 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  376 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  377 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION')
  378 +
  379 +
  380 + idxr_x = where(t_x,ctestxr_x)
  381 +
  382 +
  383 + ;SETTING Y RANGE
  384 +
  385 + tst = STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'SED' and $
  386 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE '_EM' and $
  387 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'RAC'and $
  388 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) NE 'EXT'
  389 +
  390 + idyr = where((strmid(strupcase(tgnms_extra),0,2) EQ 'YR'and tst) or $
  391 + strupcase(tgnms_extra) EQ 'YR' or $
  392 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  393 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  394 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  395 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  396 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  397 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  398 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  399 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and tst and $
  400 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION'),ctestyr) ;
  401 +
  402 + if ctestyr ne 0 then message, 'You have provided one Y-range when multiple ones are needed.',/continue
  403 +
  404 + ;EMISSION
  405 + idyr_polsed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  406 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'POLSED',ctyr_polsed)
  407 +
  408 + idyr_psi_em = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  409 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'PSI_EM',ctyr_psi_em)
  410 +
  411 + idyr_used = where(strmid(strupcase(tgnms_extra),0,1) EQ 'YR' and $
  412 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'USED',ctyr_used)
  413 +
  414 + idyr_sed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  415 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) NE 'POLSED' and $
  416 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'QSED' and $
  417 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'USED' and $
  418 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) EQ 'SED',ctyr_sed)
  419 +
  420 + idyr_polfrac = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  421 + STRUPCASE(strmid(tgnms_extra,5,/reverse_offset)) EQ 'OLFRAC',ctyr_polfrac)
  422 +
  423 + idyr_qsed = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  424 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'QSED',ctyr_qsed)
  425 +
  426 + ;EXTINCTION
  427 + idyr_polext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  428 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ '_POLEXT',ctyr_polext)
  429 +
  430 + idyr_psi_ext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  431 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ 'PSI_EXT',ctyr_psi_ext)
  432 +
  433 + idyr_uext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  434 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'UEXT',ctyr_uext)
  435 +
  436 + idyr_fpolext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  437 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) EQ 'FPLOEXT',ctyr_fpolext)
  438 +
  439 + idyr_qext = where(strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  440 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) EQ 'QEXT',ctyr_qext)
  441 +
  442 + testext = strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  443 + STRUPCASE(strmid(tgnms_extra,2,/reverse_offset)) EQ 'EXT' and $
  444 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE '_POLEXT' and $
  445 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE 'FPOLEXT' and $
  446 + STRUPCASE(strmid(tgnms_extra,6,/reverse_offset)) NE 'PSI_EXT' and $
  447 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'UEXT' and $
  448 + STRUPCASE(strmid(tgnms_extra,3,/reverse_offset)) NE 'QEXT'
  449 +
  450 + idyr_ext = where(testex,ctyr_ext)
  451 +
  452 + testit = strupcase(tgnms_extra) EQ 'TIT' or $
  453 + strupcase(tgnms_extra) EQ 'TITLE' or $
  454 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  455 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  456 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  457 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  458 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  459 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  460 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  461 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION')
  462 +
  463 + idtit = where(testit, ctit)
  464 +
  465 + if ctit ne 0 then message, 'You have provivded one title when two (emission + extinctino are needed).', /continue
  466 +
  467 + idtit_m = where((strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  468 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  469 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  470 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION'),ctit_m)
  471 +
  472 +
  473 + idtit_x = where((strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  474 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  475 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  476 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION'),ctit_x)
  477 +
  478 +
  479 + ;FILLING UP X ranges (same xrange): EMISSION
  480 +
  481 + IF ctestxr_m ne 0 THEN BEGIN
  482 +
  483 + FOR i=0L,(n_tags(!dustem_plot_range)-2)/2 DO BEGIN ; THIS IS EMISSION , extinction will have to from (n_tags(!dustem_plot_range)-2)/2+1 to (n_tags(!dustem_plot_range)-2)
  484 +
  485 + !dustem_plot_range.(i).xr=_extra.(idxr_m)
  486 +
  487 +
  488 + ENDFOR
  489 +
  490 +
  491 + ENDIF ;else the default xr is kept
  492 +
  493 +
  494 + ;FILLING UP X ranges (same xrange) - EXTINCTION
  495 +
  496 + IF ctestxr_x ne 0 THEN BEGIN
  497 +
  498 + FOR i=(n_tags(!dustem_plot_range)-2)/2+1,(n_tags(!dustem_plot_range)-2) DO BEGIN ; THIS IS EMISSION , extinction will have to from (n_tags(!dustem_plot_range)-2)/2+1 to (n_tags(!dustem_plot_range)-2)
  499 +
  500 + !dustem_plot_range.(i).xr=_extra.(idxr_x)
  501 +
  502 + ENDFOR
  503 +
  504 +
  505 + ENDIF ;else the default xr is kept
  506 +
  507 +
  508 + ;FILLING UP Y RANGES - EMISSION
  509 +
  510 +
  511 + if ctyr_polsed ne 0 then !dustem_plot_range.(3).yr = _extra.(idyr_polsed)
  512 +
  513 +
  514 + if ctyr_psi_em ne 0 then !dustem_plot_range.(5).yr = _extra.(idyr_psi_em)
  515 +
  516 +
  517 + if ctyr_used ne 0 then !dustem_plot_range.(2).yr = _extra.(idyr_used)
  518 +
  519 +
  520 + if ctyr_sed ne 0 then !dustem_plot_range.(0).yr = _extra.(idyr_sed)
  521 +
  522 +
  523 + if ctyr_polfrac ne 0 then !dustem_plot_range.(4).yr = _extra.(idyr_polfrac)
  524 +
  525 +
  526 + if ctyr_qsed ne 0 then !dustem_plot_range.(1).yr = _extra.(idyr_qsed)
  527 +
  528 + ;FILLING UP Y RANGES - EXTINCTION
  529 +
  530 +
  531 + if ctyr_polext ne 0 then !dustem_plot_range.(9).yr = _extra.(idyr_polext)
  532 +
  533 +
  534 + if ctyr_psi_ext ne 0 then !dustem_plot_range.(11).yr = _extra.(idyr_psi_ext)
  535 +
  536 +
  537 + if ctyr_uext ne 0 then !dustem_plot_range.(8).yr = _extra.(idyr_uext)
  538 +
  539 +
  540 + if ctyr_ext ne 0 then !dustem_plot_range.(6).yr = _extra.(idyr_ext)
  541 +
  542 +
  543 + if ctyr_fpolext ne 0 then !dustem_plot_range.(10).yr = _extra.(idyr_fpolext)
  544 +
  545 +
  546 + if ctyr_qext ne 0 then !dustem_plot_range.(7).yr = _extra.(idyr_qext)
  547 +
  548 + ;SETTING THE TITLE
  549 +
  550 + ;EXTINCTION
  551 + if ctit_x ne 0 then !dustem_plot_range.(13)=_extra.(idtit_x)
  552 +
  553 +
  554 + ;EMISSION
  555 + if ctit_m ne 0 then !dustem_plot_range.(12)=_extra.(idtit_m)
  556 +
  557 +
  558 + ENDIF ELSE BEGIN ;TWO DATA SETS : EXT AND SED
  559 +
  560 + tstxr = strupcase(tgnms_extra) EQ 'XRANGE' or $
  561 + strupcase(tgnms_extra) EQ 'XR' or $
  562 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  563 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  564 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  565 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  566 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  567 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  568 + (strmid(strupcase(tgnms_extra),0,2) EQ 'XR' and $
  569 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION')
  570 +
  571 + idxr = where(tstxr,ctestxr)
  572 +
  573 + if ctestxr ne 0 then message, 'You have provided one X-range when multiple ones are needed',/continue
  574 +
  575 + t_m = (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  576 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  577 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  578 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION')
  579 +
  580 + indxr_m = where(t_m,ctestxr_m)
  581 +
  582 +
  583 +
  584 + t_x = (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  585 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  586 + (strmid(strupcase(tgnms_extra),0,1) EQ 'X' and $
  587 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION')
  588 +
  589 +
  590 + idxr_x = where(t_x,ctestxr_x)
  591 +
  592 +
  593 + idyr = where(strupcase(tgnms_extra) EQ 'YR' or $
  594 + strupcase(tgnms_extra) EQ 'YRANGE' or $
  595 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and $
  596 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  597 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and $
  598 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  599 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and $
  600 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  601 + (strmid(strupcase(tgnms_extra),0,2) EQ 'YR' and $
  602 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION'),ctestyr) ;
  603 +
  604 + if ctestyr ne 0 then message, 'You have provided one Y-range when multiple ones are needed.',/continue
  605 +
  606 +
  607 +
  608 + t_m = (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  609 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  610 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  611 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION')
  612 +
  613 + indyr_m = where(t_m,ctestxr_m)
  614 +
  615 + t_x = (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  616 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  617 + (strmid(strupcase(tgnms_extra),0,1) EQ 'Y' and $
  618 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION')
  619 +
  620 +
  621 + idyr_x = where(t_x,ctestyr_x)
  622 +
  623 +
  624 + testit = strupcase(tgnms_extra) EQ 'TIT' or $
  625 + strupcase(tgnms_extra) EQ 'TITLE' or $
  626 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  627 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_M') or $
  628 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  629 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) NE '_EMISSION') or $
  630 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  631 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) NE '_X') or $
  632 + (strmid(strupcase(tgnms_extra),0,3) EQ 'TIT' and $
  633 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) NE '_EXTINCTION')
  634 +
  635 + idtit = where(testit, ctit)
  636 +
  637 + if ctit ne 0 then message, 'You have provivded one title when two (emission + extinctino are needed).', /continue
  638 +
  639 + idtit_m = where((strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  640 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_M') or $
  641 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  642 + STRUPCASE(strmid(tgnms_extra,8,/reverse_offset)) EQ '_EMISSION') ,ctit_m)
  643 +
  644 +
  645 + idtit_x = where((strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  646 + STRUPCASE(strmid(tgnms_extra,1,/reverse_offset)) EQ '_X') or $
  647 + (strmid(strupcase(tgnms_extra),0,1) EQ 'T' and $
  648 + STRUPCASE(strmid(tgnms_extra,10,/reverse_offset)) EQ '_EXTINCTION'),ctit_x)
  649 +
  650 +
  651 +
  652 + ;FILLING UP X ranges (same xrange): EMISSION
  653 +
  654 + IF ctestxr_m ne 0 THEN !dustem_plot_range.(0).xr=_extra.(idxr_m)
  655 +
  656 +
  657 + ;FILLING UP X ranges (same xrange) - EXTINCTION
  658 +
  659 + IF ctestxr_x ne 0 THEN !dustem_plot_range.(6).xr=_extra.(idxr_x)
  660 +
  661 + ;FILLING UP X ranges (same xrange): EMISSION
  662 +
  663 + IF ctestyr_m ne 0 THEN !dustem_plot_range.(0).yr=_extra.(idyr_m)
  664 +
  665 +
  666 + ;FILLING UP X ranges (same xrange) - EXTINCTION
  667 +
  668 + IF ctestxr_x ne 0 THEN !dustem_plot_range.(6).xr=_extra.(idxr_x)
  669 +
  670 +
  671 + ;SETTING THE TITLE
  672 +
  673 + ;EXTINCTION
  674 + if ctit_x ne 0 then !dustem_plot_range.(13)=_extra.(idtit_x)
  675 +
  676 +
  677 + ;EMISSION
  678 + if ctit_m ne 0 then !dustem_plot_range.(12)=_extra.(idtit_m)
  679 +
  680 +
  681 +
  682 + ENDELSE
  683 +
  684 +
  685 +ENDIF
  686 +
  687 +ENDIF
  688 +
  689 +
  690 +the_end:
  691 +
  692 +
  693 +END
  694 +
  695 +
... ...
src/idl/dustemwrap_plot.pro
... ... @@ -65,7 +65,6 @@ PRO dustemwrap_plot,p_dim,st, $
65 65 ; PSIEXT_spec
66 66 ; OPTIONAL OUTPUT PARAMETERS:
67 67 ;
68   -
69 68 ; ACCEPTED KEY-WORDS:
70 69 ; help
71 70 ; COMMON BLOCKS:
... ... @@ -89,8 +88,6 @@ IF keyword_set(help) THEN BEGIN
89 88 goto,the_end
90 89 END
91 90  
92   -stop
93   -
94 91 ;This is also necessary for the plotting of the results of the fit (Last iteration)
95 92 IF not keyword_set(st) THEN BEGIN
96 93 ;Activation of the plugins is needed because of the plotting of the total emission model that includes them.
... ... @@ -157,9 +154,8 @@ ENDIF ELSE BEGIN ;st is provided
157 154  
158 155 ENDELSE
159 156  
160   -;help,p_dim,st,dustem_sed
161 157  
162   -;print,'!dustem_inter chi^2:',!dustem_iter.act,(*!dustem_fit).rchi2,(*!dustem_fit).chi2
  158 +;IC: Will come back for this to include all datasets and their associated data.
163 159  
164 160 dd=(*(*!dustem_data).sed).values
165 161 ss=(*(*!dustem_data).sed).sigma
... ... @@ -176,8 +172,14 @@ new_mouchard.rchi2=(*!dustem_fit).rchi2
176 172 ;new_mouchard.recomputed_chi2=recomputed_chi2_sed
177 173 ;new_mouchard.recomputed_rchi2=recomputed_rchi2_sed
178 174  
  175 +
  176 +;IC: I've commented this test below but it was uncommented. I don't understand its function.
  177 +;Current parameter values including plugins have been available at each iteration prior to commenting this.
  178 +;Leaving as is.
  179 +
179 180 ;JPB: need here to store values of current parameter values (including plugins) into !iteration_mouchard
180 181 help,(*!dustem_fit).CURRENT_PARAM_VALUES ;This is not currently filled up ...
  182 +
181 183 ;Below will work only for non plugin parameters
182 184 goto,skip1
183 185 param_descs=*(*!dustem_fit).param_descs
... ... @@ -192,14 +194,10 @@ print,params_current
192 194  
193 195 stop
194 196 skip1:
195   -
  197 +
196 198 mouchard=[mouchard,new_mouchard]
197 199 !iteration_mouchard=ptr_new(mouchard)
198 200  
199   -;print,new_mouchard
200   -
201   -;stop
202   -
203 201  
204 202 ;LIST OF TESTS THAT NEED TO BE RAN SO THAT THE PLOTTING OF THE MODEL SPECTRA OCCURS
205 203  
... ... @@ -231,6 +229,8 @@ frmt0='(A36)'
231 229 frmt1='(1E10.2)'
232 230 frmt2='(10F10.2)'
233 231  
  232 +dustem_set_plot_range,test_sed, test_ext,_extra= _extra
  233 +
234 234 ;I have decided to keep track of the command index manually as I did not find any command online that does this.
235 235 cmdind_m = 0 ;for emission
236 236 cmdind_x = 0 ;for extinction
... ... @@ -369,7 +369,7 @@ if test_m then begin
369 369 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
370 370 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
371 371 ;Displaying refreshed part (first run . This is the command that will be replaced)
372   - cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
  372 + cgtext, xxpos + widthtext*1.35 + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
373 373 ;saving the command id to replace it
374 374 !dustemcgwin_ncmds.runs.pl = cmdind_m
375 375  
... ... @@ -482,9 +482,9 @@ if test_m then begin
482 482  
483 483 ;update of the title here ?
484 484  
485   - if isa((*!dustem_fit).current_param_values) then begin
  485 + if !dustem_end EQ 1 then begin
486 486 ;replacing my count - 3
487   - tit=string(_extra.title)
  487 + tit=!dustem_plot_range.title_m
488 488 cmdin_m = !dustemcgwin_ncmds.pltit.pl
489 489  
490 490 xxpos = !dustemcgwin_ncmds.pltit.txtwdth
... ... @@ -544,30 +544,30 @@ if test_m then begin
544 544 ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
545 545 if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
546 546  
547   - cgwindow,'dustemcgwin_dataset', st, dataset='SED', /nodata, position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
548   - cgwindow,'dustemcgwin_dataset', st, dataset='SED', /nodata, /norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  547 + cgwindow,'dustem_plot_dataset', st, dataset='SED', /nodata, position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  548 + cgwindow,'dustem_plot_dataset', st, dataset='SED', /nodata, /norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
549 549  
550 550 endif else begin ;SED exists
551 551  
552 552 if ~iswinsed then begin
553 553  
554 554 cmdind_m = !dustemcgwin_ncmds.sed.pl
555   - cgwindow,'dustemcgwin_dataset', st, dustem_sed,SED_spec,dataset='SED', /refresh ,position=p_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra
  555 + cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec,dataset='SED', /refresh ,position=p_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra
556 556  
557 557 cmdind_m = !dustemcgwin_ncmds.sed.nrm
558   - cgwindow,'dustemcgwin_dataset', st, dustem_sed,SED_spec,dataset='SED', /norm, /refresh,position=np_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra
  558 + cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec,dataset='SED', /norm, /refresh,position=np_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra
559 559  
560 560  
561 561 endif else begin
562 562  
563   - cgwindow,'dustemcgwin_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  563 + cgwindow,'dustem_plot_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
564 564  
565   - cgwindow,'dustemcgwin_dataset', st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  565 + cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
566 566 !dustemcgwin_ncmds.sed.pl = cmdind_m
567 567  
568   - 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
  568 + cgwindow,'dustem_plot_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
569 569  
570   - cgwindow,'dustemcgwin_dataset', st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, /addcmd ,winid=winid_m, _extra=_extra & cmdind_m+=1
  570 + cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, /addcmd ,winid=winid_m, _extra=_extra & cmdind_m+=1
571 571 !dustemcgwin_ncmds.sed.nrm = cmdind_m
572 572  
573 573 endelse
... ... @@ -578,8 +578,8 @@ if test_m then begin
578 578  
579 579 if ~test_qsed then begin ;Qsed is not present
580 580  
581   - cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /nodata, position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
582   - cgwindow,'dustemcgwin_dataset', st, dataset='QSED', /nodata, /norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  581 + cgwindow,'dustem_plot_dataset', st, dataset='QSED', /nodata, position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  582 + cgwindow,'dustem_plot_dataset', st, dataset='QSED', /nodata, /norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
583 583  
584 584 endif else begin ;Qsed data is present
585 585  
... ... @@ -587,29 +587,29 @@ if test_m then begin
587 587  
588 588 cmdind_m = !dustemcgwin_ncmds.qsed.pl
589 589 ;refreshing the positive_only and negative_only plots if data is present in them
590   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/positive_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  590 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/positive_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
591 591  
592   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/negative_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
  592 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/negative_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
593 593  
594 594 cmdind_m = !dustemcgwin_ncmds.qsed.nrm
595   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec, dataset='QSED', /refresh, nodata=0, /norm,position=np_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  595 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED', /refresh, nodata=0, /norm,position=np_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
596 596  
597 597 endif else begin
598 598  
599 599 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
600   - cgwindow,'dustemcgwin_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
  600 + cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
601 601 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
602   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  602 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
603 603  
604 604 !dustemcgwin_ncmds.qsed.pl = cmdind_m
605 605  
606   - cgwindow,'dustemcgwin_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
  606 + cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
607 607 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
608   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  608 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
609 609  
610 610  
611   - 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
612   - cgwindow,'dustemcgwin_dataset', st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  611 + cgwindow,'dustem_plot_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
  612 + cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
613 613 !dustemcgwin_ncmds.qsed.nrm = cmdind_m
614 614  
615 615 endelse
... ... @@ -617,38 +617,38 @@ if test_m then begin
617 617 ;stop
618 618 if ~test_used then begin ;used is not present
619 619  
620   - cgwindow,'dustemcgwin_dataset', st, dataset='USED', /nodata, position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
621   - cgwindow,'dustemcgwin_dataset', st, dataset='USED', /nodata, /norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  620 + cgwindow,'dustem_plot_dataset', st, dataset='USED', /nodata, position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  621 + cgwindow,'dustem_plot_dataset', st, dataset='USED', /nodata, /norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
622 622  
623 623 endif else begin ;used data is present
624 624  
625 625 if ~iswinsed then begin
626 626 cmdind_m = !dustemcgwin_ncmds.used.pl
627 627 ;refreshing the positive_only and negative_only plots if data is present in them
628   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  628 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
629 629  
630   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
  630 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
631 631  
632 632 cmdind_m = !dustemcgwin_ncmds.used.nrm
633   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED', /refresh, nodata=0, /norm,position=np_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  633 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED', /refresh, nodata=0, /norm,position=np_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
634 634  
635 635 endif else begin
636 636 ;stop
637 637 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
638   - cgwindow,'dustemcgwin_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
  638 + cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
639 639 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
640   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  640 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
641 641  
642 642 !dustemcgwin_ncmds.used.pl = cmdind_m
643 643  
644   - cgwindow,'dustemcgwin_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
  644 + cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
645 645 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
646   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  646 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
647 647  
648 648  
649 649  
650   - 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
651   - cgwindow,'dustemcgwin_dataset', st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  650 + cgwindow,'dustem_plot_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
  651 + cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
652 652 !dustemcgwin_ncmds.used.nrm = cmdind_m
653 653  
654 654 endelse
... ... @@ -656,18 +656,18 @@ if test_m then begin
656 656  
657 657 if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1
658 658  
659   - cgwindow,'dustemcgwin_dataset', st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  659 + cgwindow,'dustem_plot_dataset', st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
660 660  
661 661 endif else begin ;psi_em exists
662 662 ;stop
663 663 if ~iswinsed then begin
664 664 cmdind_m = !dustemcgwin_ncmds.psi_em.pl
665   - cgwindow,'dustemcgwin_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  665 + cgwindow,'dustem_plot_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
666 666  
667 667 endif else begin
668 668 ;stop
669   - cgwindow,'dustemcgwin_dataset', st, dataset='psi_em', position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
670   - cgwindow,'dustemcgwin_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  669 + cgwindow,'dustem_plot_dataset', st, dataset='psi_em', position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  670 + cgwindow,'dustem_plot_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
671 671 !dustemcgwin_ncmds.psi_em.pl = cmdind_m
672 672  
673 673 endelse
... ... @@ -676,23 +676,23 @@ if test_m then begin
676 676  
677 677 if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1
678 678  
679   - cgwindow,'dustemcgwin_dataset', st, dataset='polsed', /nodata, position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
680   - cgwindow,'dustemcgwin_dataset', st, dataset='polsed', /nodata, /norm, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  679 + cgwindow,'dustem_plot_dataset', st, dataset='polsed', /nodata, position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  680 + cgwindow,'dustem_plot_dataset', st, dataset='polsed', /nodata, /norm, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
681 681  
682 682 endif else begin ;polsed exists
683 683  
684 684 if ~iswinsed then begin
685 685 cmdind_m = !dustemcgwin_ncmds.polsed.pl
686   - cgwindow,'dustemcgwin_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  686 + cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
687 687 cmdind_m = !dustemcgwin_ncmds.polsed.nrm
688   - cgwindow,'dustemcgwin_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  688 + cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
689 689 endif else begin
690 690 ;stop
691   - cgwindow,'dustemcgwin_dataset', st, dataset='polsed', position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
692   - cgwindow,'dustemcgwin_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  691 + cgwindow,'dustem_plot_dataset', st, dataset='polsed', position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  692 + cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
693 693 !dustemcgwin_ncmds.polsed.pl = cmdind_m
694   - 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
695   - cgwindow,'dustemcgwin_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  694 + cgwindow,'dustem_plot_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
  695 + cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
696 696 !dustemcgwin_ncmds.polsed.nrm = cmdind_m
697 697 endelse
698 698 endelse
... ... @@ -700,18 +700,18 @@ if test_m then begin
700 700  
701 701 if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1
702 702  
703   - cgwindow,'dustemcgwin_dataset', st, dataset='polfrac', /nodata, position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  703 + cgwindow,'dustem_plot_dataset', st, dataset='polfrac', /nodata, position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
704 704  
705 705 endif else begin ;polfrac exists
706 706  
707 707 if ~iswinsed then begin
708 708 cmdind_m = !dustemcgwin_ncmds.polfrac.pl
709   - cgwindow,'dustemcgwin_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
  709 + cgwindow,'dustem_plot_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
710 710  
711 711 endif else begin
712 712 ;stop
713   - cgwindow,'dustemcgwin_dataset', st, dataset='polfrac', position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
714   - cgwindow,'dustemcgwin_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  713 + cgwindow,'dustem_plot_dataset', st, dataset='polfrac', position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
  714 + cgwindow,'dustem_plot_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
715 715 !dustemcgwin_ncmds.polfrac.pl = cmdind_m
716 716  
717 717 endelse
... ... @@ -885,9 +885,9 @@ if test_x then begin
885 885 ;NB: JP is right, the user should be able to set the entirety of the title.
886 886 ;Make this block aware of the saving of the data (from the fits table)
887 887  
888   - if isa((*!dustem_fit).current_param_values) then begin
  888 + if !dustem_end EQ 1 then begin
889 889 ;replacing my count - 3
890   - tit=string(_extra.title)
  890 + tit=!dustem_plot_range.title_x
891 891 cmdind_x = !dustemcgwin_ncmds.pltit.pl
892 892  
893 893 xxpos = !dustemcgwin_ncmds.pltit.txtwdth
... ... @@ -947,29 +947,29 @@ if test_x then begin
947 947 ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
948 948 if ~test_ext then begin ; EXT data is not present (For completeness) # This is only valid when !run_pol=1
949 949  
950   - cgwindow,'dustemcgwin_dataset', st, dataset='EXT', /nodata, position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
951   - cgwindow,'dustemcgwin_dataset', st, dataset='EXT', /nodata, /norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  950 + cgwindow,'dustem_plot_dataset', st, dataset='EXT', /nodata, position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  951 + cgwindow,'dustem_plot_dataset', st, dataset='EXT', /nodata, /norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
952 952  
953 953 endif else begin ;EXT exists
954 954  
955 955 if ~iswinext then begin
956 956  
957 957 cmdind_x = !dustemcgwin_ncmds.ext.pl
958   - cgwindow,'dustemcgwin_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /refresh ,position=p_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra
  958 + cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /refresh ,position=p_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra
959 959  
960 960 cmdind_x = !dustemcgwin_ncmds.ext.nrm
961   - cgwindow,'dustemcgwin_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /norm, /refresh,position=np_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra
  961 + cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /norm, /refresh,position=np_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra
962 962  
963 963  
964 964 endif else begin
965 965  
966   - cgwindow,'dustemcgwin_dataset', st, dataset='EXT', position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
967   - cgwindow,'dustemcgwin_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  966 + cgwindow,'dustem_plot_dataset', st, dataset='EXT', position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  967 + cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
968 968 !dustemcgwin_ncmds.ext.pl = cmdind_x
969 969  
970   - cgwindow,'dustemcgwin_dataset', st, dataset='EXT',/norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be used too
  970 + cgwindow,'dustem_plot_dataset', st, dataset='EXT',/norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be used too
971 971  
972   - cgwindow,'dustemcgwin_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, /addcmd ,winid=winid_x, _extra=_extra & cmdind_x+=1
  972 + cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, /addcmd ,winid=winid_x, _extra=_extra & cmdind_x+=1
973 973 !dustemcgwin_ncmds.ext.nrm = cmdind_x
974 974  
975 975 endelse
... ... @@ -980,37 +980,37 @@ if test_x then begin
980 980  
981 981 if ~test_qext then begin ;Qext is not present
982 982  
983   - cgwindow,'dustemcgwin_dataset', st, dataset='QEXT', /nodata, position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
984   - cgwindow,'dustemcgwin_dataset', st, dataset='QEXT', /nodata, /norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  983 + cgwindow,'dustem_plot_dataset', st, dataset='QEXT', /nodata, position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  984 + cgwindow,'dustem_plot_dataset', st, dataset='QEXT', /nodata, /norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
985 985  
986 986 endif else begin ;Qext data is present
987 987  
988 988 if ~iswinext then begin
989 989 cmdind_x = !dustemcgwin_ncmds.qext.pl
990 990 ;refreshing the positive_only and negative_only plots if data is present in them
991   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/positive_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  991 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/positive_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
992 992  
993   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/negative_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
  993 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/negative_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
994 994  
995 995 cmdind_x = !dustemcgwin_ncmds.qext.nrm
996   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT', /refresh, nodata=0, /norm,position=np_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  996 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT', /refresh, nodata=0, /norm,position=np_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
997 997  
998 998 endif else begin
999 999  
1000 1000 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
1001   - cgwindow,'dustemcgwin_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
  1001 + cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
1002 1002 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
1003 1003  
1004   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1004 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1005 1005  
1006 1006 !dustemcgwin_ncmds.qext.pl = cmdind_x
1007 1007  
1008   - cgwindow,'dustemcgwin_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
  1008 + cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
1009 1009 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
1010   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1010 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1011 1011  
1012   - cgwindow,'dustemcgwin_dataset', st, dataset='QEXT',/norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uqsed too
1013   - cgwindow,'dustemcgwin_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1012 + cgwindow,'dustem_plot_dataset', st, dataset='QEXT',/norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uqsed too
  1013 + cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1014 1014 !dustemcgwin_ncmds.qext.nrm = cmdind_x
1015 1015  
1016 1016 endelse
... ... @@ -1018,38 +1018,38 @@ if test_x then begin
1018 1018 ;stop
1019 1019 if ~test_uext then begin ;uext is not present
1020 1020  
1021   - cgwindow,'dustemcgwin_dataset', st, dataset='UEXT', /nodata, position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1022   - cgwindow,'dustemcgwin_dataset', st, dataset='UEXT', /nodata, /norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1021 + cgwindow,'dustem_plot_dataset', st, dataset='UEXT', /nodata, position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1022 + cgwindow,'dustem_plot_dataset', st, dataset='UEXT', /nodata, /norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1023 1023  
1024 1024 endif else begin ;uext data is present
1025 1025  
1026 1026 if ~iswinext then begin
1027 1027 cmdind_x = !dustemcgwin_ncmds.uext.pl
1028 1028 ;refreshing the positive_only and negative_only plots if data is present in them
1029   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1029 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1030 1030  
1031   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
  1031 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
1032 1032  
1033 1033 cmdind_x = !dustemcgwin_ncmds.uext.nrm
1034   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /refresh, nodata=0, /norm,position=np_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1034 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /refresh, nodata=0, /norm,position=np_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1035 1035  
1036 1036 endif else begin
1037 1037 ;stop
1038 1038 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
1039   - cgwindow,'dustemcgwin_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
  1039 + cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
1040 1040  
1041 1041 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
1042   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1042 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1043 1043  
1044 1044 !dustemcgwin_ncmds.uext.pl = cmdind_x
1045 1045  
1046   - cgwindow,'dustemcgwin_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
  1046 + cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
1047 1047 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
1048   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1048 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1049 1049  
1050 1050  
1051   - cgwindow,'dustemcgwin_dataset', st, dataset='UEXT',/norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uused too
1052   - cgwindow,'dustemcgwin_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1051 + cgwindow,'dustem_plot_dataset', st, dataset='UEXT',/norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uused too
  1052 + cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1053 1053 !dustemcgwin_ncmds.uext.nrm = cmdind_x
1054 1054  
1055 1055 endelse
... ... @@ -1057,18 +1057,18 @@ if test_x then begin
1057 1057  
1058 1058 if ~test_psi_ext then begin ; psi_ext data is not present (For completeness) # This is only valid when !run_pol=1
1059 1059  
1060   - cgwindow,'dustemcgwin_dataset', st, dataset='PSI_EXT', /nodata, position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1060 + cgwindow,'dustem_plot_dataset', st, dataset='PSI_EXT', /nodata, position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1061 1061  
1062 1062 endif else begin ;psi_ext exists
1063 1063  
1064 1064 if ~iswinext then begin
1065 1065 cmdind_x = !dustemcgwin_ncmds.psi_ext.pl
1066   - cgwindow,'dustemcgwin_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='PSI_EXT', /refresh ,position=p_psiext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1066 + cgwindow,'dustem_plot_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='PSI_EXT', /refresh ,position=p_psiext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1067 1067  
1068 1068 endif else begin
1069 1069 ;stop
1070   - cgwindow,'dustemcgwin_dataset', st, dataset='psi_ext', position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1071   - cgwindow,'dustemcgwin_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1070 + cgwindow,'dustem_plot_dataset', st, dataset='psi_ext', position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1071 + cgwindow,'dustem_plot_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1072 1072 !dustemcgwin_ncmds.psi_ext.pl = cmdind_x
1073 1073  
1074 1074 endelse
... ... @@ -1077,23 +1077,23 @@ if test_x then begin
1077 1077  
1078 1078 if ~test_polext then begin ; polext data is not present (For completeness) # This is only valid when !run_pol=1
1079 1079  
1080   - cgwindow,'dustemcgwin_dataset', st, dataset='polext', /nodata, position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1081   - cgwindow,'dustemcgwin_dataset', st, dataset='polext', /nodata, /norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1080 + cgwindow,'dustem_plot_dataset', st, dataset='polext', /nodata, position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1081 + cgwindow,'dustem_plot_dataset', st, dataset='polext', /nodata, /norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1082 1082  
1083 1083 endif else begin ;polext exists
1084 1084  
1085 1085 if ~iswinext then begin
1086 1086 cmdind_x = !dustemcgwin_ncmds.polext.pl
1087   - cgwindow,'dustemcgwin_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1087 + cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1088 1088 cmdind_x = !dustemcgwin_ncmds.polext.nrm
1089   - cgwindow,'dustemcgwin_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1089 + cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1090 1090 endif else begin
1091 1091 ;stop
1092   - cgwindow,'dustemcgwin_dataset', st, dataset='polext', position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1093   - cgwindow,'dustemcgwin_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1092 + cgwindow,'dustem_plot_dataset', st, dataset='polext', position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1093 + cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1094 1094 !dustemcgwin_ncmds.polext.pl = cmdind_x
1095   - cgwindow,'dustemcgwin_dataset', st, dataset='polext',/norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be upolsed too
1096   - cgwindow,'dustemcgwin_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1095 + cgwindow,'dustem_plot_dataset', st, dataset='polext',/norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be upolsed too
  1096 + cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1097 1097 !dustemcgwin_ncmds.polext.nrm = cmdind_x
1098 1098 endelse
1099 1099 endelse
... ... @@ -1101,18 +1101,18 @@ if test_x then begin
1101 1101  
1102 1102 if ~test_fpolext then begin ; fpolext data is not present (For completeness) # This is only valid when !run_pol=1
1103 1103  
1104   - cgwindow,'dustemcgwin_dataset', st, dataset='fpolext', /nodata, position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1104 + cgwindow,'dustem_plot_dataset', st, dataset='fpolext', /nodata, position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1105 1105  
1106 1106 endif else begin ;fpolext exists
1107 1107  
1108 1108 if ~iswinext then begin
1109 1109 cmdind_x = !dustemcgwin_ncmds.fpolext.pl
1110   - cgwindow,'dustemcgwin_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
  1110 + cgwindow,'dustem_plot_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
1111 1111  
1112 1112 endif else begin
1113 1113  
1114   - cgwindow,'dustemcgwin_dataset', st, dataset='fpolext', position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1115   - cgwindow,'dustemcgwin_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1114 + cgwindow,'dustem_plot_dataset', st, dataset='fpolext', position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
  1115 + cgwindow,'dustem_plot_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
1116 1116 !dustemcgwin_ncmds.fpolext.pl = cmdind_x
1117 1117  
1118 1118 endelse
... ... @@ -1133,7 +1133,7 @@ IF ~iswinprms THEN BEGIN;(NEXT RUNS)
1133 1133 cgcontrol, winid_prms, execute=0
1134 1134 cgset, winid_prms
1135 1135 cmdind_prms = !dustemcgwin_ncmds.prms.pl
1136   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /refresh, winid=winid_prms,/replacecmd,cmdindex=cmdind_prms, _extra=_extra
  1136 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /refresh, winid=winid_prms,/replacecmd,cmdindex=cmdind_prms, _extra=_extra
1137 1137 cgcontrol, winid_prms ,execute=1
1138 1138 ENDIF ELSE BEGIN ;(FIRST RUN)
1139 1139 cgwindow,wxpos=param_wxpos,wypos=param_wypos,wxsize=param_wxsize,wysize=param_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot?
... ... @@ -1141,8 +1141,8 @@ ENDIF ELSE BEGIN ;(FIRST RUN)
1141 1141 winid_prms = cgquery(dimensions=dim_prms,/current) ;we don't need the dimension of the window so far/ I don't know why I needed it before
1142 1142 cgcontrol, winid_prms, execute=0
1143 1143 !dustemcgwin_id.prms = winid_prms
1144   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd , winid=winid_prms,_extra=_extra ;& cmdind_prms+=1
1145   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd, /refresh , winid=winid_prms, _extra=_extra & cmdind_prms+=1
  1144 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd , winid=winid_prms,_extra=_extra ;& cmdind_prms+=1
  1145 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd, /refresh , winid=winid_prms, _extra=_extra & cmdind_prms+=1
1146 1146 !dustemcgwin_ncmds.prms.pl = cmdind_prms
1147 1147 cgcontrol, winid_prms ,execute=1
1148 1148 ENDELSE
... ... @@ -1157,7 +1157,7 @@ IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN
1157 1157 cgcontrol, winid_plgns, execute=0
1158 1158 cgset, winid_plgns
1159 1159 cmdind_plgns = !dustemcgwin_ncmds.plgns.pl
1160   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PLUGINS', /refresh, winid=winid_plgns,/replacecmd,cmdindex=cmdind_plgns, _extra=_extra
  1160 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /refresh, winid=winid_plgns,/replacecmd,cmdindex=cmdind_plgns, _extra=_extra
1161 1161 cgcontrol, winid_plgns ,execute=1
1162 1162 ENDIF ELSE BEGIN ;(FIRST RUN)
1163 1163 cgwindow,wxpos=plugin_wxpos,wypos=plugin_wypos,wxsize=plugin_wxsize,wysize=plugin_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot?
... ... @@ -1165,8 +1165,8 @@ IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN
1165 1165 winid_plgns = cgquery(dimensions=dim_plgns,/current) ;we don't need the dimension of the window so far/ I don't know why I needed it before
1166 1166 cgcontrol, winid_plgns, execute=0
1167 1167 !dustemcgwin_id.plgns = winid_plgns
1168   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd , winid=winid_plgns,_extra=_extra ;& cmdind_prms+=1
1169   - cgwindow,'dustemcgwin_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd, /refresh , winid=winid_plgns, _extra=_extra & cmdind_plgns+=1
  1168 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd , winid=winid_plgns,_extra=_extra ;& cmdind_prms+=1
  1169 + cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd, /refresh , winid=winid_plgns, _extra=_extra & cmdind_plgns+=1
1170 1170 !dustemcgwin_ncmds.plgns.pl = cmdind_plgns
1171 1171 cgcontrol, winid_plgns ,execute=1
1172 1172 ENDELSE
... ...
src/idl/dustemwrap_plot_noobj.pro
... ... @@ -15,13 +15,13 @@ PRO dustemwrap_plot_noobj,p_dim,st, $
15 15  
16 16 ;+
17 17 ; NAME:
18   -; dustemwrap_plot
  18 +; dustemwrap_plot_noobj
19 19 ; PURPOSE:
20   -; plots dustemwrap observed sed, predicted sed, predicted spectra for total Intensity, polarization in emission and extinction
  20 +; plots dustemwrap observed sed, predicted sed, predicted spectra for total Intensity, polarization in emission and extinction without OOP routines
21 21 ; CATEGORY:
22 22 ; DustEMWrap
23 23 ; CALLING SEQUENCE:
24   -; dustemwrap_plot,p_dim,st,dustem_sed,SED_spec,dustem_qsed,Q_spec,dustem_used,U_spec,dustem_polsed,P_spec,dustem_polfrac,SP_spec,dustem_psi_em,PSI_spec,dustem_ext,EXT_spec,dustem_qext,QEXT_spec,dustem_uext,UEXT_spec,dustem_polext,POLEXT_spec,dustem_fpolext,SPEXT_spec,dustem_psi_ext,PSIEXT_spec,_extra=_extra
  24 +; dustemwrap_plot_noobj,p_dim,st,dustem_sed,SED_spec,dustem_qsed,Q_spec,dustem_used,U_spec,dustem_polsed,P_spec,dustem_polfrac,SP_spec,dustem_psi_em,PSI_spec,dustem_ext,EXT_spec,dustem_qext,QEXT_spec,dustem_uext,UEXT_spec,dustem_polext,POLEXT_spec,dustem_fpolext,SPEXT_spec,dustem_psi_ext,PSIEXT_spec,_extra=_extra
25 25 ; INPUTS:
26 26 ; p_dim
27 27 ; OPTIONAL INPUT PARAMETERS:
... ... @@ -155,9 +155,47 @@ ENDIF ELSE BEGIN ;st is provided
155 155  
156 156 ENDELSE
157 157  
158   -;help,(*!dustem_fit).CURRENT_PARAM_VALUES ;This is not currently filled up ...
159   -
160   -
  158 +;IC: Will come back for this to include all datasets and their associated data.
  159 +;ADDING THIS BLOCK FOR COMPLETENESS
  160 +dd=(*(*!dustem_data).sed).values
  161 +ss=(*(*!dustem_data).sed).sigma
  162 +recomputed_chi2_sed = total((dd-dustem_sed)^2/ss^2)
  163 +dof= n_elements((*(*!dustem_data).sed).values) - n_elements(*(*!dustem_fit).PARAM_DESCS)
  164 +recomputed_rchi2_sed = recomputed_chi2_sed / dof
  165 +
  166 +;print,'recomputed chi^2:',!dustem_iter.act,recomputed_rchi2_sed,recomputed_chi2_sed
  167 +mouchard=*!iteration_mouchard
  168 +new_mouchard=mouchard[0]
  169 +new_mouchard.iteration=!dustem_iter.act
  170 +new_mouchard.chi2=(*!dustem_fit).chi2
  171 +new_mouchard.rchi2=(*!dustem_fit).rchi2
  172 +
  173 +
  174 +
  175 +;IC: I've commented this test below but it was uncommented. I don't understand its function.
  176 +;Current parameter values including plugins have been available at each iteration prior to commenting this.
  177 +;Leaving as is.
  178 +
  179 +;JPB: need here to store values of current parameter values (including plugins) into !iteration_mouchard
  180 +help,(*!dustem_fit).CURRENT_PARAM_VALUES ;This is not currently filled up ...
  181 +
  182 +;Below will work only for non plugin parameters
  183 +goto,skip1
  184 +param_descs=*(*!dustem_fit).param_descs
  185 +params_current=[0.D0]
  186 +FOR i=0L,n_elements(param_descs)-1 DO BEGIN
  187 + str='params_current=[params_current,'+param_descs[i]+']'
  188 + print,str
  189 + toto=execute(str)
  190 +ENDFOR
  191 +params_current=params_current[1:*]
  192 +print,params_current
  193 +
  194 +stop
  195 +skip1:
  196 +
  197 +mouchard=[mouchard,new_mouchard]
  198 +!iteration_mouchard=ptr_new(mouchard)
161 199  
162 200 ;LIST OF TESTS THAT NEED TO BE RAN SO THAT THE PLOTTING OF THE MODEL SPECTRA OCCURS
163 201  
... ... @@ -192,140 +230,6 @@ frmt2='(10F10.2)'
192 230 ;Instead of setting the extra tags for plotting in dustemcgwin, we'll place them in this (parent) procedure.
193 231 tgnms_extra = tag_names(_extra)
194 232  
195   -;
196   -;
197   -;
198   -; ; ;Now testing on what is in the _extra structure.
199   -; IF test_m and ~test_x BEGIN ;EMISSION ALONE
200   -;
201   -;
202   -;
203   -; IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE DASHBOARD
204   -;
205   -; ;BECAUSE OF THE LATOUT OF THE DASHBOARD
206   -; ;U,PSI,P are forced to have the same x axis (this is untrue for the y range). Note that the y range of PSI is by default [-90,90] but the possibility to modify it (ie zoom-in, zoom-out, and move the curve) is possible.
207   -; ;Q,p,I are forced to have the same x axis (this is untrue for the y range).
208   -;
209   -;
210   -; ;#Test on the presence of x ranges for U,PSI and P:
211   -;
212   -; ;If only one of them is present, apply the x range to all three plots
213   -; ;If not
214   -;
215   -; ;Keyword use is a tiny bit flexible (ie: xr_sed, xrange_sed)
216   -;
217   -; ;We need to locate the underscore and use it in the test. If it's not present (in all tags in the _extra structure) we'll know that only xr or xrange has been used. This can also mean that xr hasn't been specified.
218   -;
219   -;
220   -;
221   -; ;NB: if a
222   -;
223   -;
224   -;
225   -;
226   -; IF
227   -;
228   -;
229   -;
230   -;
231   -;
232   -;
233   -;
234   -;
235   -;
236   -;
237   -;
238   -;
239   -;
240   -;
241   -;
242   -;
243   -;
244   -; ENDIF ELSE BEGIN ;ONE DATA SET : SED
245   -;
246   -;
247   -;
248   -;
249   -;
250   -;
251   -;
252   -; ENDELSE
253   -;
254   -;
255   -;
256   -;
257   -;
258   -;
259   -;
260   -; ENDIF
261   -;
262   -;
263   -; IF test_x and ~test_m THEN BEGIN ;EXTINCTION ALONE
264   -;
265   -;
266   -;
267   -; IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE DASHBOARD
268   -;
269   -;
270   -;
271   -;
272   -; ENDIF ELSE BEGIN ;ONE DATA SET : EXT
273   -;
274   -;
275   -;
276   -;
277   -;
278   -; ENDELSE
279   -;
280   -;
281   -;
282   -;
283   -;
284   -;
285   -;
286   -; ENDIF
287   -;
288   -;
289   -;
290   -; IF test_m and test_x BEGIN ;EMISSION and EXTINCTION
291   -;
292   -;
293   -;
294   -;
295   -;
296   -; IF !run_pol THEN BEGIN ;SEVERAL DATA SETS: THE SED DASHBOARD & EXT DASHBOARD
297   -;
298   -;
299   -;
300   -;
301   -; ENDIF ELSE BEGIN ;TWO DATA SETS : EXT AND SED
302   -;
303   -;
304   -;
305   -;
306   -;
307   -; ENDELSE
308   -;
309   -;
310   -;
311   -;
312   -;
313   -;
314   -;
315   -;
316   -;
317   -; ENDIF
318   -;
319   -;
320   -;
321   -
322   -
323   -
324   -
325   -
326   -
327   -
328   -
329 233  
330 234  
331 235 ;I have decided to keep track of the command index manually as I did not find any command online that does this.
... ... @@ -452,7 +356,7 @@ if test_m then begin
452 356 ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
453 357 cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35
454 358 ;Displaying refreshed part (first run . This is the command that will be replaced)
455   - cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0
  359 + cgtext, xxpos + widthtext*1.35 + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0
456 360  
457 361 ;plotting of (mostly) fixed data for rchi2
458 362 ;Since the format of the strings is specified, the length/width of the string in thex direction is fixed.
... ... @@ -567,18 +471,18 @@ if test_m then begin
567 471 ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
568 472 if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
569 473  
570   - dustemcgwin_dataset, st, dataset='SED', /nodata, position=p_sed, _extra=_extra
571   - dustemcgwin_dataset, st, dataset='SED', /nodata, /norm, position=np_sed, _extra=_extra
  474 + dustem_plot_dataset, st, dataset='SED', /nodata, position=p_sed, _extra=_extra
  475 + dustem_plot_dataset, st, dataset='SED', /nodata, /norm, position=np_sed, _extra=_extra
572 476  
573 477 endif else begin ;SED exists
574 478 ;this plots the observed SED
575   - dustemcgwin_dataset, st, dataset='SED', position=p_sed, _extra=_extra
  479 + dustem_plot_dataset, st, dataset='SED', position=p_sed, _extra=_extra
576 480 ;this plots the predicted spectrum and predicted SED
577   - dustemcgwin_dataset, st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, _extra=_extra
  481 + dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, _extra=_extra
578 482 ;This plots an empty normalized plot
579   - dustemcgwin_dataset, st, dataset='SED',/norm, position=np_sed, _extra=_extra ;I think nodata can also be used too
  483 + dustem_plot_dataset, st, dataset='SED',/norm, position=np_sed, _extra=_extra ;I think nodata can also be used too
580 484 ;This plots the normalized observed SED - best fit
581   - dustemcgwin_dataset, st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, _extra=_extra
  485 + dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, _extra=_extra
582 486 endelse
583 487  
584 488  
... ... @@ -586,24 +490,24 @@ if test_m then begin
586 490  
587 491 if ~test_qsed then begin ;Qsed is not present
588 492  
589   - dustemcgwin_dataset, st, dataset='QSED', /nodata, position=p_qsed, _extra=_extra
590   - dustemcgwin_dataset, st, dataset='QSED', /nodata, /norm, position=np_qsed, _extra=_extra
  493 + dustem_plot_dataset, st, dataset='QSED', /nodata, position=p_qsed, _extra=_extra
  494 + dustem_plot_dataset, st, dataset='QSED', /nodata, /norm, position=np_qsed, _extra=_extra
591 495  
592 496 endif else begin ;Qsed data is present
593 497  
594 498 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
595   - dustemcgwin_dataset, st, dataset='QSED', position=p_qsed,/positive_only, _extra=_extra
  499 + dustem_plot_dataset, st, dataset='QSED', position=p_qsed,/positive_only, _extra=_extra
596 500 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
597   - dustemcgwin_dataset, st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, _extra=_extra
  501 + dustem_plot_dataset, st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, _extra=_extra
598 502  
599 503  
600   - dustemcgwin_dataset, st, dataset='QSED', position=p_qsed, /addcmd,/negative_only, _extra=_extra
  504 + dustem_plot_dataset, st, dataset='QSED', position=p_qsed, /addcmd,/negative_only, _extra=_extra
601 505 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
602   - dustemcgwin_dataset, st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, _extra=_extra
  506 + dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, _extra=_extra
603 507  
604 508  
605   - dustemcgwin_dataset, st, dataset='QSED',/norm, position=np_qsed, _extra=_extra ;I think nodata can also be uqsed too
606   - dustemcgwin_dataset, st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, _extra=_extra
  509 + dustem_plot_dataset, st, dataset='QSED',/norm, position=np_qsed, _extra=_extra ;I think nodata can also be uqsed too
  510 + dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, _extra=_extra
607 511  
608 512 endelse
609 513  
... ... @@ -611,62 +515,62 @@ if test_m then begin
611 515  
612 516 if ~test_used then begin ;used is not present
613 517  
614   - dustemcgwin_dataset, st, dataset='USED', /nodata, position=p_used, _extra=_extra
615   - dustemcgwin_dataset, st, dataset='USED', /nodata, /norm, position=np_used, _extra=_extra
  518 + dustem_plot_dataset, st, dataset='USED', /nodata, position=p_used, _extra=_extra
  519 + dustem_plot_dataset, st, dataset='USED', /nodata, /norm, position=np_used, _extra=_extra
616 520  
617 521 endif else begin ;used data is present
618 522  
619 523 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
620   - dustemcgwin_dataset, st, dataset='USED', position=p_used,/positive_only, _extra=_extra
  524 + dustem_plot_dataset, st, dataset='USED', position=p_used,/positive_only, _extra=_extra
621 525 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
622   - dustemcgwin_dataset, st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, _extra=_extra
  526 + dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, _extra=_extra
623 527  
624   - dustemcgwin_dataset, st, dataset='USED', position=p_used, winid=winid_m,/negative_only, _extra=_extra
  528 + dustem_plot_dataset, st, dataset='USED', position=p_used, winid=winid_m,/negative_only, _extra=_extra
625 529 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
626   - dustemcgwin_dataset, st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, _extra=_extra
  530 + dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, _extra=_extra
627 531  
628   - dustemcgwin_dataset, st, dataset='USED',/norm, position=np_used, _extra=_extra ;I think nodata can also be uused too
629   - dustemcgwin_dataset, st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, _extra=_extra
  532 + dustem_plot_dataset, st, dataset='USED',/norm, position=np_used, _extra=_extra ;I think nodata can also be uused too
  533 + dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, _extra=_extra
630 534  
631 535 endelse
632 536  
633 537 if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1
634 538  
635   - dustemcgwin_dataset, st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra
  539 + dustem_plot_dataset, st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra
636 540  
637 541 endif else begin ;psi_em exists
638 542  
639   - dustemcgwin_dataset, st, dataset='psi_em', position=p_psised, _extra=_extra
640   - dustemcgwin_dataset, st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, _extra=_extra
  543 + dustem_plot_dataset, st, dataset='psi_em', position=p_psised, _extra=_extra
  544 + dustem_plot_dataset, st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, _extra=_extra
641 545  
642 546 endelse
643 547  
644 548  
645 549 if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1
646 550  
647   - dustemcgwin_dataset, st, dataset='polsed', /nodata, position=p_psed, _extra=_extra
648   - dustemcgwin_dataset, st, dataset='polsed', /nodata, /norm, position=np_psed, _extra=_extra
  551 + dustem_plot_dataset, st, dataset='polsed', /nodata, position=p_psed, _extra=_extra
  552 + dustem_plot_dataset, st, dataset='polsed', /nodata, /norm, position=np_psed, _extra=_extra
649 553  
650 554 endif else begin
651 555  
652   - dustemcgwin_dataset, st, dataset='polsed', position=p_psed, _extra=_extra
653   - dustemcgwin_dataset, st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, _extra=_extra
  556 + dustem_plot_dataset, st, dataset='polsed', position=p_psed, _extra=_extra
  557 + dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, _extra=_extra
654 558  
655   - dustemcgwin_dataset, st, dataset='polsed',/norm, position=np_psed, _extra=_extra ;I think nodata can also be upolsed too
656   - dustemcgwin_dataset, st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, _extra=_extra
  559 + dustem_plot_dataset, st, dataset='polsed',/norm, position=np_psed, _extra=_extra ;I think nodata can also be upolsed too
  560 + dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, _extra=_extra
657 561  
658 562 endelse
659 563  
660 564  
661 565 if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1
662 566  
663   - dustemcgwin_dataset, st, dataset='polfrac', /nodata, position=p_spsed, _extra=_extra
  567 + dustem_plot_dataset, st, dataset='polfrac', /nodata, position=p_spsed, _extra=_extra
664 568  
665 569 endif else begin ;polfrac exists
666 570  
667 571  
668   - dustemcgwin_dataset, st, dataset='polfrac', position=p_spsed, _extra=_extra
669   - dustemcgwin_dataset, st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, _extra=_extra
  572 + dustem_plot_dataset, st, dataset='polfrac', position=p_spsed, _extra=_extra
  573 + dustem_plot_dataset, st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, _extra=_extra
670 574  
671 575 endelse
672 576  
... ... @@ -791,55 +695,9 @@ if test_x then begin
791 695 xxpos+=thiswidth*1.6
792 696 cgtext, xxpos, yypos,' (RUNNING)',color=0,/normal,charsize = 1.6
793 697  
794   -
795   -; endif else begin
796   -;
797   -;
798   -; winid_x = !dustemcgwin_id.ext
799   -; cgcontrol, winid_x, execute=0
800   -; cgset, winid_x ;apparently specifying the window index isn't enough. This might be because of the use of cgcontrol
801   -;
802   -; ;Refreshing chi2 data:
803   -; cmdind_x = !dustemcgwin_ncmds.chi2.pl
804   -; xxpos = 1 - !dustemcgwin_ncmds.chi2.txtwdth - 0.03
805   -; yypos = 0.97
806   -; cgwindow,'cgtext', xxpos , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
807   -;
808   -;
809   -;
810   -; ;Refreshing rchi2 data:
811   -; cmdind_x = !dustemcgwin_ncmds.rchi2.pl
812   -; xxpos = 1 - !dustemcgwin_ncmds.rchi2.txtwdth - 0.03
813   -; yypos = 0.95
814   -; cgwindow,'cgtext', xxpos , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
815   -;
816   -;
817   -; ;Refreshing number of runs data:
818   -; cmdind_x = !dustemcgwin_ncmds.runs.pl
819   -; xxpos = 0.03 + !dustemcgwin_ncmds.runs.txtwdth*1.35 ;(because of charsize)
820   -; yypos = 0.015
821   -; cgwindow,'cgtext', xxpos , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
822   -;
823   -;
824   -; if !dustem_end EQ 1 then begin
825   -; ;replacing my count - 3
826   -; tit=!dustem_plot_extra.title
827   -; cmdind_x = !dustemcgwin_ncmds.pltit.pl
828   -;
829   -; xxpos = !dustemcgwin_ncmds.pltit.txtwdth
830   -; yypos = 0.96
831   -;
832   -; cgwindow,'cgtext', xxpos , yypos,' (Final Run)',color=0,/normal,charsize = 1.6,/replacecmd,cmdindex=cmdind_x, winid=winid_x
833   -;
834   -; endif
835   -;
836   -; endelse
837   -
838   - ;cgWindow_GetDefs,xsize=xsize,ysize=ysize
839   - ;cgcontrol, resize=[xsize,ysize]
  698 +
840 699 if !run_pol then begin
841   - ;,wback='grey'
842   -
  700 +
843 701 ;position arrays for plot and normalized graph
844 702  
845 703 ;THIS IS HARD-CODED IN A VERY SILLY WAY
... ... @@ -883,17 +741,17 @@ if test_x then begin
883 741 ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
884 742 if ~test_ext then begin ; EXT data is not present (For completeness) # This is only valid when !run_pol=1
885 743  
886   - dustemcgwin_dataset, st, dataset='EXT', /nodata, position=p_ext, _extra=_extra
887   - dustemcgwin_dataset, st, dataset='EXT', /nodata, /norm, position=np_ext, _extra=_extra
  744 + dustem_plot_dataset, st, dataset='EXT', /nodata, position=p_ext, _extra=_extra
  745 + dustem_plot_dataset, st, dataset='EXT', /nodata, /norm, position=np_ext, _extra=_extra
888 746  
889 747 endif else begin ;EXT exists
890 748  
891   - dustemcgwin_dataset, st, dataset='EXT', position=p_ext, _extra=_extra
892   - dustemcgwin_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, _extra=_extra
  749 + dustem_plot_dataset, st, dataset='EXT', position=p_ext, _extra=_extra
  750 + dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, _extra=_extra
893 751  
894   - dustemcgwin_dataset, st, dataset='EXT',/norm, position=np_ext, _extra=_extra ;I think nodata can also be used too
  752 + dustem_plot_dataset, st, dataset='EXT',/norm, position=np_ext, _extra=_extra ;I think nodata can also be used too
895 753  
896   - dustemcgwin_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, _extra=_extra
  754 + dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, _extra=_extra
897 755  
898 756 endelse
899 757  
... ... @@ -902,60 +760,60 @@ if test_x then begin
902 760  
903 761 if ~test_qext then begin ;Qext is not present
904 762  
905   - dustemcgwin_dataset, st, dataset='QEXT', /nodata, position=p_qext, _extra=_extra
906   - dustemcgwin_dataset, st, dataset='QEXT', /nodata, /norm, position=np_qext, _extra=_extra
  763 + dustem_plot_dataset, st, dataset='QEXT', /nodata, position=p_qext, _extra=_extra
  764 + dustem_plot_dataset, st, dataset='QEXT', /nodata, /norm, position=np_qext, _extra=_extra
907 765  
908 766 endif else begin ;Qext data is present
909 767  
910 768 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
911   - dustemcgwin_dataset, st, dataset='QEXT', position=p_qext,/positive_only, _extra=_extra
  769 + dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/positive_only, _extra=_extra
912 770 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
913 771  
914   - dustemcgwin_dataset, st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, _extra=_extra
  772 + dustem_plot_dataset, st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, _extra=_extra
915 773  
916   - dustemcgwin_dataset, st, dataset='QEXT', position=p_qext,/negative_only, _extra=_extra
  774 + dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/negative_only, _extra=_extra
917 775 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
918   - dustemcgwin_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, _extra=_extra
  776 + dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, _extra=_extra
919 777  
920   - dustemcgwin_dataset, st, dataset='QEXT',/norm, position=np_qext, _extra=_extra ;I think nodata can also be uqsed too
921   - dustemcgwin_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, _extra=_extra
  778 + dustem_plot_dataset, st, dataset='QEXT',/norm, position=np_qext, _extra=_extra ;I think nodata can also be uqsed too
  779 + dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, _extra=_extra
922 780  
923 781 endelse
924 782 ;stop
925 783 if ~test_uext then begin ;uext is not present
926 784  
927   - dustemcgwin_dataset, st, dataset='UEXT', /nodata, position=p_uext, _extra=_extra
928   - dustemcgwin_dataset, st, dataset='UEXT', /nodata, /norm, position=np_uext, _extra=_extra
  785 + dustem_plot_dataset, st, dataset='UEXT', /nodata, position=p_uext, _extra=_extra
  786 + dustem_plot_dataset, st, dataset='UEXT', /nodata, /norm, position=np_uext, _extra=_extra
929 787  
930 788 endif else begin ;uext data is present
931 789  
932 790 ;stop
933 791 ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
934   - dustemcgwin_dataset, st, dataset='UEXT', position=p_uext,/positive_only, _extra=_extra
  792 + dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/positive_only, _extra=_extra
935 793  
936 794 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
937   - dustemcgwin_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, _extra=_extra
  795 + dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, _extra=_extra
938 796  
939 797  
940   - dustemcgwin_dataset, st, dataset='UEXT', position=p_uext,/negative_only, _extra=_extra
  798 + dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/negative_only, _extra=_extra
941 799 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
942   - dustemcgwin_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, _extra=_extra
  800 + dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, _extra=_extra
943 801  
944 802  
945   - dustemcgwin_dataset, st, dataset='UEXT',/norm, position=np_uext, _extra=_extra ;I think nodata can also be uused too
946   - dustemcgwin_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, _extra=_extra
  803 + dustem_plot_dataset, st, dataset='UEXT',/norm, position=np_uext, _extra=_extra ;I think nodata can also be uused too
  804 + dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, _extra=_extra
947 805  
948 806  
949 807 endelse
950 808  
951 809 if ~test_psi_ext then begin ; psi_ext data is not present (For completeness) # This is only valid when !run_pol=1
952 810  
953   - dustemcgwin_dataset, st, dataset='PSI_EXT', /nodata, position=p_psiext, _extra=_extra
  811 + dustem_plot_dataset, st, dataset='PSI_EXT', /nodata, position=p_psiext, _extra=_extra
954 812  
955 813 endif else begin ;psi_ext exists
956 814  
957   - dustemcgwin_dataset, st, dataset='psi_ext', position=p_psiext, _extra=_extra
958   - dustemcgwin_dataset, st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, _extra=_extra
  815 + dustem_plot_dataset, st, dataset='psi_ext', position=p_psiext, _extra=_extra
  816 + dustem_plot_dataset, st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, _extra=_extra
959 817  
960 818  
961 819 endelse
... ... @@ -963,30 +821,30 @@ if test_x then begin
963 821  
964 822 if ~test_polext then begin ; polext data is not present (For completeness) # This is only valid when !run_pol=1
965 823  
966   - dustemcgwin_dataset, st, dataset='polext', /nodata, position=p_pext, _extra=_extra
967   - dustemcgwin_dataset, st, dataset='polext', /nodata, /norm, position=np_pext, _extra=_extra
  824 + dustem_plot_dataset, st, dataset='polext', /nodata, position=p_pext, _extra=_extra
  825 + dustem_plot_dataset, st, dataset='polext', /nodata, /norm, position=np_pext, _extra=_extra
968 826  
969 827 endif else begin ;polext exists
970 828  
971   - dustemcgwin_dataset, st, dataset='polext', position=p_pext, _extra=_extra
972   - dustemcgwin_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, _extra=_extra
  829 + dustem_plot_dataset, st, dataset='polext', position=p_pext, _extra=_extra
  830 + dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, _extra=_extra
973 831  
974   - dustemcgwin_dataset, st, dataset='polext',/norm, position=np_pext, _extra=_extra ;I think nodata can also be upolsed too
975   - dustemcgwin_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, _extra=_extra
  832 + dustem_plot_dataset, st, dataset='polext',/norm, position=np_pext, _extra=_extra ;I think nodata can also be upolsed too
  833 + dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, _extra=_extra
976 834  
977 835 endelse
978 836  
979 837  
980 838 if ~test_fpolext then begin ; fpolext data is not present (For completeness) # This is only valid when !run_pol=1
981 839  
982   - dustemcgwin_dataset, st, dataset='fpolext', /nodata, position=p_spext, _extra=_extra
  840 + dustem_plot_dataset, st, dataset='fpolext', /nodata, position=p_spext, _extra=_extra
983 841  
984 842  
985 843 endif else begin ;fpolext exists
986 844  
987 845  
988   - dustemcgwin_dataset, st, dataset='fpolext', position=p_spext, _extra=_extra
989   - dustemcgwin_dataset, st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, _extra=_extra
  846 + dustem_plot_dataset, st, dataset='fpolext', position=p_spext, _extra=_extra
  847 + dustem_plot_dataset, st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, _extra=_extra
990 848  
991 849  
992 850 endelse
... ... @@ -1001,15 +859,15 @@ ENDIF
1001 859  
1002 860 ;PLOTTING OF THE PARAMETERS
1003 861 window,2,xpos=param_wxpos,ypos=param_wypos,xsize=param_wxsize,ysize=param_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot?
1004   -dustemcgwin_dataset, st, res, errors, p_dim,dataset='PARAMETERS',_extra=_extra ;& cmdind_prms+=1
1005   -dustemcgwin_dataset, st, res, errors, p_dim,dataset='PARAMETERS',/refresh, _extra=_extra
  862 +dustem_plot_dataset, st, res, errors, p_dim,dataset='PARAMETERS',_extra=_extra ;& cmdind_prms+=1
  863 +dustem_plot_dataset, st, res, errors, p_dim,dataset='PARAMETERS',/refresh, _extra=_extra
1006 864  
1007 865 ;PLOTTING OF THE PLUGINS
1008 866 IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN
1009 867  
1010 868 window,3,xpos=plugin_wxpos,ypos=plugin_wypos,xsize=plugin_wxsize,ysize=plugin_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot?
1011   - dustemcgwin_dataset, st, res, errors, p_dim,dataset='PLUGINS',_extra=_extra ;& cmdind_prms+=1
1012   - dustemcgwin_dataset, st, res, errors, p_dim,dataset='PLUGINS', /refresh , winid=winid_plgns, _extra=_extra
  869 + dustem_plot_dataset, st, res, errors, p_dim,dataset='PLUGINS',_extra=_extra ;& cmdind_prms+=1
  870 + dustem_plot_dataset, st, res, errors, p_dim,dataset='PLUGINS', /refresh , winid=winid_plgns, _extra=_extra
1013 871  
1014 872 ENDIF
1015 873  
... ...