Blame view

src/idl/dustemcgwin_dataset.pro 240 KB
5f04fa07   Ilyes Choubani   general update
1
PRO dustemcgwin_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
b5314324   Ilyes Choubani   updating the plot...
2

b5314324   Ilyes Choubani   updating the plot...
3

b5314324   Ilyes Choubani   updating the plot...
4
;############################################################################################
5f04fa07   Ilyes Choubani   general update
5
6
7
8
9
10
11
12
if !run_pol then begin
    if isa(position) then begin
        if keyword_set(norm) then pospltxt = [position(0)+0.02,position(3)-0.02] else pospltxt = [position(0)+0.02,position(3)-0.03]  
    endif
endif else begin
    if isa(position) then pospltxt = [position(0)+0.02,position(3)-0.05] ;hard-coded but we can find a way 
endelse 

b5314324   Ilyes Choubani   updating the plot...
13
14
15
16
17
18
wavs=dustem_get_wavelengths()
n_plgns = n_tags(*!dustem_plugin)
Ngrains=(*!dustem_params).Ngrains
use_cols=dustem_grains_colors(Ngrains,/cgplot)
use_cols[1]='Cornflower'
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
18e4331f   Ilyes Choubani   general update (f...
19
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.
5f04fa07   Ilyes Choubani   general update
20
 
b5314324   Ilyes Choubani   updating the plot...
21
clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
67bd858a   Ilyes Choubani   Replication of th...
22
23
;NB: plugins need to have different colors for extinction because they are not the same plugins. New array required.

3c479f24   Ilyes Choubani   Allowing to fix p...
24
scopes=tag_names((*!dustem_plugin))
b5314324   Ilyes Choubani   updating the plot...
25
26
27
28
29
tgnms_extra = tag_names(_extra)
ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR')
ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR')
if ind_xr EQ -1 then xr=[1.00E+00,1.00E+05] else xr=(_extra.(ind_xr))
if ind_yr EQ -1 then yr=[5.00E-03,1.00E+08] else yr=(_extra.(ind_yr))
c8368c6e   Ilyes Choubani   updating plotting...
30

5f04fa07   Ilyes Choubani   general update
31
32
33
34

frmt0='(A46)'
frmt1='(1E11.4)'
frmt2='(10F10.2)'
b5314324   Ilyes Choubani   updating the plot...
35
36


5f04fa07   Ilyes Choubani   general update
37
;############################################################################################
b5314324   Ilyes Choubani   updating the plot...
38

b5314324   Ilyes Choubani   updating the plot...
39

abebbdf3   Ilyes Choubani   General update: A...
40
41
42
43
44
45
46
;NB: SUSPETING A MAJR ERROR IN THE MATCHING OF STRUCTURE (FOR THE PLOTTING OF THE HIDDEN POINTS)
;INVERTING ALL THE INDICES THAT ARE CONCERNED BY THIS. 
;THIS CAN CREATE ERRORS (EVEN THOUGH IT WAS WRONG AND WORKE) SO REMEMBER YOU DID THIS. 

  


b5314324   Ilyes Choubani   updating the plot...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
if keyword_set(dataset) then begin
;!run_pol is implied for QSED/USED/POLSED etc...
    Case strupcase(dataset) of 
    
        'SED': begin
            
            idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
5f04fa07   Ilyes Choubani   general update
67
68
69
70
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
                        
b5314324   Ilyes Choubani   updating the plot...
71
72
                    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  
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
5f04fa07   Ilyes Choubani   general update
73
                    xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
b5314324   Ilyes Choubani   updating the plot...
74
                  
5f04fa07   Ilyes Choubani   general update
75
76
                ;endelse  
                endif
b5314324   Ilyes Choubani   updating the plot...
77
            
5f04fa07   Ilyes Choubani   general update
78
79
            endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
            if not keyword_set(nodata) then begin
b5314324   Ilyes Choubani   updating the plot...
80
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
81
                    
b5314324   Ilyes Choubani   updating the plot...
82
83
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
b5314324   Ilyes Choubani   updating the plot...
84
85
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
86
                            yy=dustem_interp[idx_spec]
b5314324   Ilyes Choubani   updating the plot...
87
88
89
                            rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
                            cgoplot,xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            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'
c8368c6e   Ilyes Choubani   updating plotting...
90
                        ENDIF
b5314324   Ilyes Choubani   updating the plot...
91
                        
c8368c6e   Ilyes Choubani   updating plotting...
92
93
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
94
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
95
96
                            rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
18e4331f   Ilyes Choubani   general update (f...
97
                            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 
c8368c6e   Ilyes Choubani   updating plotting...
98
99
100
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
101
102
                    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.
                        ;stop
b5314324   Ilyes Choubani   updating the plot...
103
                        
5f04fa07   Ilyes Choubani   general update
104
105
                    if not keyword_set(refresh) then begin 
                        ;stop   
b5314324   Ilyes Choubani   updating the plot...
106
                        xtit=textoidl('\lambda (\mum)')
fcb6eade   Ilyes Choubani   general update - ...
107
108
109
110
111
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
                        cgplot,wavs,wavs/wavs,/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
b5314324   Ilyes Choubani   updating the plot...
112
113
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
5f04fa07   Ilyes Choubani   general update
114
115
                    ;endelse
                    endif
b5314324   Ilyes Choubani   updating the plot...
116
117
                    
                
5f04fa07   Ilyes Choubani   general update
118
119
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
b5314324   Ilyes Choubani   updating the plot...
120
121
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
b5314324   Ilyes Choubani   updating the plot...
122
123
124
125
126
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            cgoplot,st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
                        ENDFOR
                        
c8368c6e   Ilyes Choubani   updating plotting...
127
                                                
b5314324   Ilyes Choubani   updating the plot...
128
129
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
130
131
132
133
134
135
136
137
138
                            
                            if isa((*!dustem_plugin).(0).spec) then begin 
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_SED') THEN begin
                                    cgoplot,st.sed.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                ENDIF
                                
                            endif
                            
b5314324   Ilyes Choubani   updating the plot...
139
                        endfor
c8368c6e   Ilyes Choubani   updating plotting...
140
                                                
b5314324   Ilyes Choubani   updating the plot...
141
                        ;PLotting of the interpolates corresponding to spectrum and filter points
c8368c6e   Ilyes Choubani   updating plotting...
142
                           
b5314324   Ilyes Choubani   updating the plot...
143
144
145
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
146
                            yy=dustem_interp[idx_spec]
abebbdf3   Ilyes Choubani   General update: A...
147
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
b5314324   Ilyes Choubani   updating the plot...
148
149
                        ENDIF
                        
c8368c6e   Ilyes Choubani   updating plotting...
150
151
152
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
153
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
154
155
156
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
b5314324   Ilyes Choubani   updating the plot...
157
                        
c8368c6e   Ilyes Choubani   updating plotting...
158
                        ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
159
                        cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
c8368c6e   Ilyes Choubani   updating plotting...
160
161
162
                         
                                        
                                
5f04fa07   Ilyes Choubani   general update
163
164
165
                    endif ;else begin ;The data points in the plot that remain unchanged.
                        ;stop
                    if not keyword_set(refresh) then begin
b5314324   Ilyes Choubani   updating the plot...
166
167
168
169
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
dfc68a85   Ilyes Choubani   Fixed some plotti...
170
                            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'                
b5314324   Ilyes Choubani   updating the plot...
171
172
173
174
175
176
177
178
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec)-rms,((*!dustem_data.sed).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
179
                        
b5314324   Ilyes Choubani   updating the plot...
180
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
dfc68a85   Ilyes Choubani   Fixed some plotti...
181
182
                            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 $
                                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
c8368c6e   Ilyes Choubani   updating plotting...
183
                            
b5314324   Ilyes Choubani   updating the plot...
184
185
186
187
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
                            cgerrplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt)-rms,((*!dustem_data.sed).values)(idx_filt)+rms,color='Dodger Blue'
c8368c6e   Ilyes Choubani   updating plotting...
188
                            
b5314324   Ilyes Choubani   updating the plot...
189
                        endif
c8368c6e   Ilyes Choubani   updating plotting...
190
191
                        
                        
b5314324   Ilyes Choubani   updating the plot...
192
                        ;Plotting of frequency axis
c8368c6e   Ilyes Choubani   updating plotting...
193
194
                        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)')
                        
5f04fa07   Ilyes Choubani   general update
195
                        xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
c8368c6e   Ilyes Choubani   updating plotting...
196
                         
b5314324   Ilyes Choubani   updating the plot...
197
                        ;Locating all the hidden data points (spectrum+filter)
abebbdf3   Ilyes Choubani   General update: A...
198
                        match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
b5314324   Ilyes Choubani   updating the plot...
199
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
200
201
202
203
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.sed).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                         
c8368c6e   Ilyes Choubani   updating plotting...
204
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
205
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
206
207
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
dfc68a85   Ilyes Choubani   Fixed some plotti...
208
                                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
18e4331f   Ilyes Choubani   general update (f...
209
210
211
212
213
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
                                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'
                            endif                                            
b5314324   Ilyes Choubani   updating the plot...
214
                            
18e4331f   Ilyes Choubani   general update (f...
215
                            if ct_filt_hdn then begin
b5314324   Ilyes Choubani   updating the plot...
216
                            ;Plotting of hidden filter data points 
dfc68a85   Ilyes Choubani   Fixed some plotti...
217
                                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                                           
18e4331f   Ilyes Choubani   general update (f...
218
219
220
221
222
223
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
                                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'
                                
                            endif
b5314324   Ilyes Choubani   updating the plot...
224
225
226
227
228
                                                           
                        endif    
                        
                        
                    
5f04fa07   Ilyes Choubani   general update
229
230
                    ;endelse 
                    endif
b5314324   Ilyes Choubani   updating the plot...
231
232
                
                
5f04fa07   Ilyes Choubani   general update
233
234
235
236
                ;endelse 
                endif            
            ;endelse
            endif 
18e4331f   Ilyes Choubani   general update (f...
237
        ;stop    
b5314324   Ilyes Choubani   updating the plot...
238
239
        end
        
67bd858a   Ilyes Choubani   Replication of th...
240
        'EXT': begin 
b5314324   Ilyes Choubani   updating the plot...
241
        
b5314324   Ilyes Choubani   updating the plot...
242
        
67bd858a   Ilyes Choubani   Replication of th...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
            idx_filt=where((*!dustem_data.ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.ext).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
                        
                    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  
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                ;endelse  
                endif
            
            endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
            if not keyword_set(nodata) then begin
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.ext).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.ext).sigma)(idx_spec)/2.
                            cgoplot,xx,((*!dustem_data.ext).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.ext).wav)(idx_spec),(((*!dustem_data.ext).values)[idx_spec]-rms)/yy,(((*!dustem_data.ext).values)[idx_spec]+rms)/yy,color='Powder Blue'
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN ; There are no filter points for now...
                            xx=((*!dustem_data.ext).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*!dustem_data.ext).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.ext).wav)(idx_filt),(((*!dustem_data.ext).values)[idx_filt]-rms)/yy,(((*!dustem_data.ext).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot 
                        ENDIF
                            
                        
                    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.
                        ;stop
                        
                    if not keyword_set(refresh) then begin 
                        ;stop   
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
                        cgplot,wavs,wavs/wavs,/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
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    ;endelse
                    endif
                    
                
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;not so sure about the multiplicative factor
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            cgoplot,st.ext.wav,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
                        ENDFOR
                        
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin 
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_EXT') THEN begin
                                    cgoplot,st.ext.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                ENDIF
                                
                            endif
                            
                        endfor
                        
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.ext).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.ext).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        
                        ;Plotting of the total dust emission spectrum
                        cgoplot,st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                         
                                        
                                
                    endif ;else begin ;The data points in the plot that remain unchanged.
                        ;stop
                    if not keyword_set(refresh) then begin
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            cgplot,((*!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'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.ext).wav)(idx_spec),((*!dustem_data.ext).values)(idx_spec)-rms,((*!dustem_data.ext).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            if ct_spec ne 0 then cgoplot,((*!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 $
                                cgplot,((*!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
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
                            cgerrplot,((*!dustem_data.ext).wav)(idx_filt),((*!dustem_data.ext).values)(idx_filt)-rms,((*!dustem_data.ext).values)(idx_filt)+rms,color='Dodger Blue'
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
                        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)')
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        match2,((*!dustem_data.ext).wav),((*!dustem_show.ext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.ext).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.ext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                         
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgoplot,(((*!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
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
                                cgerrplot,(((*!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'
                            endif                                            
                            
                            if ct_filt_hdn then begin
                            ;Plotting of hidden filter data points 
                                cgoplot,(((*!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                                           
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
                                cgerrplot,(((*!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'
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    ;endelse 
                    endif
                
                
                ;endelse 
                endif            
            ;endelse
            endif
          
b5314324   Ilyes Choubani   updating the plot...
431
432
433
        
        end
        
67bd858a   Ilyes Choubani   Replication of th...
434
435
436
437
        'POLEXT': begin 
            
            idx_filt=where((*!dustem_data.polext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polext).filt_names EQ 'SPECTRUM',ct_spec)
18e4331f   Ilyes Choubani   general update (f...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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  
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
67bd858a   Ilyes Choubani   Replication of th...
454
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{P_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
455
456
457
458
459
460
461
462
463
464
465
                  
                endelse  
                
            
            endif else begin ;when the data is present 
            
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
466
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
467
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
468
469
470
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
                            cgoplot,xx,((*!dustem_data.polext).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.polext).wav)(idx_spec),(((*!dustem_data.polext).values)[idx_spec]-rms)/yy,(((*!dustem_data.polext).values)[idx_spec]+rms)/yy,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
471
472
473
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
474
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
475
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
476
477
478
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*!dustem_data.polext).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.polext).wav)(idx_filt),(((*!dustem_data.polext).values)[idx_filt]-rms)/yy,(((*!dustem_data.polext).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot 
18e4331f   Ilyes Choubani   general update (f...
479
480
481
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
482
                    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.
18e4331f   Ilyes Choubani   general update (f...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
                        
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
67bd858a   Ilyes Choubani   Replication of th...
498
                            cgoplot,st.polext.wav,st.polext.(i+1)*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
18e4331f   Ilyes Choubani   general update (f...
499
500
501
502
503
504
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
505
                            If isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
506
507
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                    cgoplot,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               
3c479f24   Ilyes Choubani   Allowing to fix p...
508
509
                                ENDIF 
                            endif
18e4331f   Ilyes Choubani   general update (f...
510
511
512
513
514
515
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
67bd858a   Ilyes Choubani   Replication of th...
516
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
517
                            yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
518
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
519
520
521
522
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
523
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
524
                            yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
525
526
527
528
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
67bd858a   Ilyes Choubani   Replication of th...
529
                        cgoplot,st.polext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
5f04fa07   Ilyes Choubani   general update
530
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
18e4331f   Ilyes Choubani   general update (f...
531
532
533
534
535
536
537
538
                                        
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
67bd858a   Ilyes Choubani   Replication of th...
539
                            cgplot,((*!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'                
18e4331f   Ilyes Choubani   general update (f...
540
541
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
542
543
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.polext).wav)(idx_spec),((*!dustem_data.polext).values)(idx_spec)-rms,((*!dustem_data.polext).values)(idx_spec)+rms,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
544
545
546
547
548
549

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
67bd858a   Ilyes Choubani   Replication of th...
550
551
                            if ct_spec ne 0 then cgoplot,((*!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 $
                                cgplot,((*!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
18e4331f   Ilyes Choubani   general update (f...
552
553
554
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
555
556
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
                            cgerrplot,((*!dustem_data.polext).wav)(idx_filt),((*!dustem_data.polext).values)(idx_filt)-rms,((*!dustem_data.polext).values)(idx_filt)+rms,color='Dodger Blue'
18e4331f   Ilyes Choubani   general update (f...
557
558
559
560
561
562
563
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
                        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)')
                        
67bd858a   Ilyes Choubani   Replication of th...
564
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{P_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
565
566
                         
                        ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
567
568
                        match2,((*!dustem_data.polext).wav),((*!dustem_show.polext).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
                        idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide  - not renaming this and keeping the polsed notation
2df3360b   Ilyes Choubani   Correcting error:...
569
                        ;Locating the hidden spectrum and filter data points                                        
67bd858a   Ilyes Choubani   Replication of th...
570
571
                        idx_filt_hdn = where((((*!dustem_show.polext).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.polext).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
2df3360b   Ilyes Choubani   Correcting error:...
572
                        
1355825c   Ilyes Choubani   General update
573
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
574
575
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
576
577
578
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
67bd858a   Ilyes Choubani   Replication of th...
579
                                cgoplot,(((*!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
18e4331f   Ilyes Choubani   general update (f...
580
581
                                
                                ;Plotting of hidden spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
582
583
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
                                cgerrplot,(((*!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'
18e4331f   Ilyes Choubani   general update (f...
584
585
                            endif                                            
                            
1355825c   Ilyes Choubani   General update
586
                            if ct_filt_hdn ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
587
                            ;Plotting of hidden filter data points 
67bd858a   Ilyes Choubani   Replication of th...
588
                                cgoplot,(((*!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                                           
18e4331f   Ilyes Choubani   general update (f...
589
590
                                
                                ;Plotting of hidden filter error point
67bd858a   Ilyes Choubani   Replication of th...
591
592
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
                                cgerrplot,(((*!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'
18e4331f   Ilyes Choubani   general update (f...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
67bd858a   Ilyes Choubani   Replication of th...
608
        
b5314324   Ilyes Choubani   updating the plot...
609
610
        end
        
67bd858a   Ilyes Choubani   Replication of th...
611
612
613
614
615
        'POLSED': begin 
        
            
            idx_filt=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',ct_spec)
1355825c   Ilyes Choubani   General update
616
617
618
619
620
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
67bd858a   Ilyes Choubani   Replication of th...
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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  
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
            
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
1355825c   Ilyes Choubani   General update
642
                        
67bd858a   Ilyes Choubani   Replication of th...
643
644
645
646
647
648
649
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
                            cgoplot,xx,((*!dustem_data.polsed).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_spec),(((*!dustem_data.polsed).values)[idx_spec]-rms)/yy,(((*!dustem_data.polsed).values)[idx_spec]+rms)/yy,color='Powder Blue'
                        ENDIF
1355825c   Ilyes Choubani   General update
650
                        
67bd858a   Ilyes Choubani   Replication of th...
651
652
653
654
655
656
657
658
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*!dustem_data.polsed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_filt),(((*!dustem_data.polsed).values)[idx_filt]-rms)/yy,(((*!dustem_data.polsed).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot 
                        ENDIF
                            
1355825c   Ilyes Choubani   General update
659
                        
67bd858a   Ilyes Choubani   Replication of th...
660
                    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.
1355825c   Ilyes Choubani   General update
661
                        
67bd858a   Ilyes Choubani   Replication of th...
662
663
664
665
666
667
668
669
670
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
1355825c   Ilyes Choubani   General update
671
                        
67bd858a   Ilyes Choubani   Replication of th...
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            cgoplot,st.polsed.wav,st.polsed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            If isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    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               
                                ENDIF 
                            endif
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.polsed).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
                        cgoplot,st.polsed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                                        
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            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'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_spec),((*!dustem_data.polsed).values)(idx_spec)-rms,((*!dustem_data.polsed).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            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 $
                                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
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt)-rms,((*!dustem_data.polsed).values)(idx_filt)+rms,color='Dodger Blue'
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
                        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)')
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        match2,((*!dustem_data.polsed).wav),((*!dustem_show.polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
                        idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.polsed).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.polsed).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
                        
                        ;stop
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                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
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
                                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'
                            endif                                            
                            
                            if ct_filt_hdn ne 0 then begin
                            ;Plotting of hidden filter data points 
                                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                                           
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
                                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'
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
        end
        
        'POLFRAC': begin 
        
            idx_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',ct_spec)
            
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    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=[1.00E-04,50.00],/ylog,psym=8,syms=0.8  
                    xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
                 
            endif else begin ;when the data is present ; normal plot     
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;##################TAKEN FROM SED
                        
                        ;Plotting of the spectra of the dust species
                        
                        ;I THINK I WILL HAVE AN ERROR HERE BECAUSE I WILL HAVE TO DIVIDE TWO ARRAYS FOR EACH DUST SPECIES. 
                        ; (st.polsed.(i+1)/st.sed.(i+1))*fact
                        ;There is an issue with the fact that there are grain species that are not polarized
                        ;test and set a counter? YES FOR NOW 
                        ;
                        
                        FOR i=0L,Ngrains-1 DO BEGIN
1355825c   Ilyes Choubani   General update
815
                            
5f04fa07   Ilyes Choubani   general update
816
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
817
                            
5f04fa07   Ilyes Choubani   general update
818
819
820
821
822
823
824
                            if countneq ne 0 then begin 
                                vecfin = st.polsed.(i+1)*0.0
                                
                                vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                 
                                cgoplot,st.polsed.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=[1.00E-04,50.00]
                            endif   
1355825c   Ilyes Choubani   General update
825
826
827
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
828
                         
1355825c   Ilyes Choubani   General update
829
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
830
                            
3c479f24   Ilyes Choubani   Allowing to fix p...
831
832
833
834
835
836
837
838
839
                            if isa((*!dustem_plugin).(0).spec) then begin
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    vecfin = st.polsed.em_tot*0.0
                                    vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i).spec)[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i).spec)[*,2])^2)[testneq])/((*(*!dustem_plugin).(i).spec)[*,0])[testneq]        
                                    cgoplot,st.polsed.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                
                                ENDIF
                            endif
1355825c   Ilyes Choubani   General update
840
                            
1355825c   Ilyes Choubani   General update
841
842
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
843
844
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
845
846
847
848
849
850
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.polfrac).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
851
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
852
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
853
854
855
856
857
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
858
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
859
860
861
862
863
                             cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
864
                         cgoplot,st.polsed.wav,dustem_spec*100*(st.sed.em_tot*fact/extra_spec),pos=position,noerase=1,/xlog,/ys,/xs
1355825c   Ilyes Choubani   General update
865
866
867
868
869
870
871
872
873
874
                                        
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        
                        ;Plotting of frequency axis
                        ;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)')
                        
                        
                        ;Spectrum points are treated before for plotting reasons. 
9cb38725   Ilyes Choubani   Fixed tests relat...
875
                        
1355825c   Ilyes Choubani   General update
876
877
878
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
5f04fa07   Ilyes Choubani   general update
879
                            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=[1.00E-04,50.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
1355825c   Ilyes Choubani   General update
880
881
882
883
884
885
886
887
888
889
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.polfrac).sigma)(idx_spec)/2.
                            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'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
5f04fa07   Ilyes Choubani   general update
890
891
                            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=[1.00E-04,50.00],/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
                                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=[1.00E-04,50.00],/xlog,/ylog;,ytickformat='dstmwrp_exp'
1355825c   Ilyes Choubani   General update
892
893
894
895
896
897
898
899
900
901
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.polfrac).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            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'
                            
                        endif
                        
                        
                        
5f04fa07   Ilyes Choubani   general update
902
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
903
904
905
906
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
abebbdf3   Ilyes Choubani   General update: A...
907
                        match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
1355825c   Ilyes Choubani   General update
908
909
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
910
911
912
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
1355825c   Ilyes Choubani   General update
913
914
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
915
916
917
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
5f04fa07   Ilyes Choubani   general update
918
                                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=[1.00E-04,50.00],psym=8,syms=0.8
1355825c   Ilyes Choubani   General update
919
920
921
922
923
924
925
926
927
928
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                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'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
5f04fa07   Ilyes Choubani   general update
929
                                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=[1.00E-04,50.00],psym=8,syms=0.8                                           
1355825c   Ilyes Choubani   General update
930
931
932
933
934
935
936
937
938
939
940
941
942
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                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'
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse 
b5314324   Ilyes Choubani   updating the plot...
943
944
945
        
        end
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
946
        'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
67bd858a   Ilyes Choubani   Replication of th...
947
948
949
950
        
        
            idx_filt=where((*!dustem_data.fpolext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.fpolext).filt_names EQ 'SPECTRUM',ct_spec)
18e4331f   Ilyes Choubani   general update (f...
951
            
18e4331f   Ilyes Choubani   general update (f...
952
953
954
955
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
67bd858a   Ilyes Choubani   Replication of th...
956
957
                    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=[1.00E-04,50.00],/ylog,psym=8,syms=0.8  
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{P_ext}/\tau_{ext} (\nu) (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
958
959
960
961
962
963
964
965
                 
            endif else begin ;when the data is present ; normal plot     
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;##################TAKEN FROM SED
                        
                        ;Plotting of the spectra of the dust species
67bd858a   Ilyes Choubani   Replication of th...
966
967
968
969
970
971
972
                        
                        ;I THINK I WILL HAVE AN ERROR HERE BECAUSE I WILL HAVE TO DIVIDE TWO ARRAYS FOR EACH DUST SPECIES. 
                        ; (st.polsed.(i+1)/st.sed.(i+1))*fact
                        ;There is an issue with the fact that there are grain species that are not polarized
                        ;test and set a counter? YES FOR NOW 
                        ;
                        
18e4331f   Ilyes Choubani   general update (f...
973
                        FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
974
                            
67bd858a   Ilyes Choubani   Replication of th...
975
976
977
978
                            testneq = where(st.polext.(i+1) ne 0,countneq)
                            
                            if countneq ne 0 then begin 
                                vecfin = st.polext.(i+1)*0.0
5f04fa07   Ilyes Choubani   general update
979
                                
67bd858a   Ilyes Choubani   Replication of th...
980
981
982
983
                                vecfin[testneq] = ((st.polext.(i+1))[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]
                                 
                                cgoplot,st.polext.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=[1.00E-04,50.00]
                            endif   
18e4331f   Ilyes Choubani   general update (f...
984
                        ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
985
986
987
                       
                        ;Plotting of the plugins. 
                         
18e4331f   Ilyes Choubani   general update (f...
988
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
989
990
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
991
992
993
994
995
996
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                    vecfin = st.polext.ext_tot*0.0
                                    vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i).spec)[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i).spec)[*,2])^2)[testneq])/((*(*!dustem_plugin).(i).spec)[*,0])[testneq]        
                                    cgoplot,st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                
3c479f24   Ilyes Choubani   Allowing to fix p...
997
                                ENDIF
67bd858a   Ilyes Choubani   Replication of th...
998
999
                            endif
                            
18e4331f   Ilyes Choubani   general update (f...
1000
                        endfor
67bd858a   Ilyes Choubani   Replication of th...
1001
1002
1003
                       
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
18e4331f   Ilyes Choubani   general update (f...
1004
1005
1006
1007
1008
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
67bd858a   Ilyes Choubani   Replication of th...
1009
                             xx=((*!dustem_data.fpolext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1010
                             yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1011
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
1012
1013
1014
1015
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
1016
                             xx=((*!dustem_data.fpolext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1017
                             yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1018
                             cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
1019
1020
1021
1022
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
67bd858a   Ilyes Choubani   Replication of th...
1023
1024
                         cgoplot,st.polext.wav,dustem_spec*100*(st.ext.ext_tot*fact/extra_spec),pos=position,noerase=1,/xlog,/ys,/xs
                                        
18e4331f   Ilyes Choubani   general update (f...
1025
1026
1027
1028
1029
1030
1031
1032
1033
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        
                        ;Plotting of frequency axis
                        ;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)')
                        
                        
                        ;Spectrum points are treated before for plotting reasons. 
67bd858a   Ilyes Choubani   Replication of th...
1034
                        
18e4331f   Ilyes Choubani   general update (f...
1035
1036
1037
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
67bd858a   Ilyes Choubani   Replication of th...
1038
                            cgplot,((*!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=[1.00E-04,50.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
18e4331f   Ilyes Choubani   general update (f...
1039
1040
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
1041
1042
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_spec)/2.
                            cgerrplot,((*!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'
18e4331f   Ilyes Choubani   general update (f...
1043
1044
1045
1046
1047
1048

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
67bd858a   Ilyes Choubani   Replication of th...
1049
1050
                            if ct_spec ne 0 then cgoplot,((*!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=[1.00E-04,50.00],/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
                                cgplot,((*!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=[1.00E-04,50.00],/xlog,/ylog;,ytickformat='dstmwrp_exp'
18e4331f   Ilyes Choubani   general update (f...
1051
1052
1053
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            cgerrplot,((*!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'
                            
                        endif
                        
                        
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
                        match2,((*!dustem_data.fpolext).wav),((*!dustem_show.fpolext).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide; 
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.fpolext).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.fpolext).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgplot,(((*!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=[1.00E-04,50.00],psym=8,syms=0.8
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.fpolext).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                cgerrplot,(((*!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'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
                                cgplot,(((*!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=[1.00E-04,50.00],psym=8,syms=0.8                                           
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.fpolext).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                cgerrplot,(((*!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'
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse
        
        
        END
        
        
     
        '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
            
            idx_filt=where((*!dustem_data.psi_em).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.psi_em).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[-90.00,90.00],psym=8,syms=0.8  
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
                 
            endif else begin ;when the data is present ; normal plot     
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;##################TAKEN FROM SED
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
                            if countneq ne 0 then begin
                                vecfin = st.polsed.(i+1)*0.0
                            
                                vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'. 
                                ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
                                polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                
                                ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                cgoplot,st.polsed.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
                            endif 
                        ENDFOR
                                                                        
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                    cgoplot_mlog,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=[-90.00,90.00]   
                                ENDIF
                            ENDIF
                        endfor
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.psi_em).wav)[idx_spec]
                             yy=dustem_interp[idx_spec]
                             cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.psi_em).wav)[idx_filt]
                             yy=dustem_interp[idx_filt]
                             cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
                         ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
                         cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        
                        ;Plotting of frequency axis
                        ;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)')
                        
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            cgplot,((*!dustem_data.psi_em).wav)(idx_spec),((*!dustem_data.psi_em).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.psi_em).sigma)(idx_spec)/2.
                            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'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            if ct_spec ne 0 then cgoplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[-90.00,90.00],/xlog else $;,ytickformat='dstmwrp_exp'
                                cgplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[-90.00,90.00],/xlog;,ytickformat='dstmwrp_exp'
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.psi_em).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
                            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'
                            
                        endif
                        
                        
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
                        match2,((*!dustem_data.psi_em).wav),((*!dustem_show.psi_em).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
                        idx_rmv_psi_em=where(show_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
                                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'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
                                cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8                                           
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
                                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'
                                 
                            endif 
                                                           
                        endif 
                        
                        
                           
                        ;stop
                        
                        
                        
                        
                        
                        
                    
                    endelse 
                
                
                
                ;endelse 
            
            endelse 
        ;stop
           
           
        end
        
        '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. 
        
        
            idx_filt=where((*!dustem_data.psi_ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.psi_ext).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[-90.00,90.00],psym=8,syms=0.8  
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} ext (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
                 
            endif else begin ;when the data is present ; normal plot     
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;##################TAKEN FROM SED
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            testneq = where(st.polext.(i+1) ne 0,countneq)
                            if countneq ne 0 then begin
                                vecfin = st.polext.(i+1)*0.0
                                
                                ;Not sure about the multiplicative factor here
                                
                                vecfin[testneq] = ((st.polext.(i+1))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'. 
                                ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
                                polar_ippsi2iqu,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                
                                ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                cgoplot,st.polext.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
                            endif 
                        ENDFOR
                                                                        
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                    ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                    cgoplot_mlog,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=[-90.00,90.00]   
                                ENDIF
                            ENDIF
                        endfor
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.psi_ext).wav)[idx_spec]
                             yy=dustem_interp[idx_spec]
                             cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.psi_ext).wav)[idx_filt]
                             yy=dustem_interp[idx_filt]
                             cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
                         ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
                         cgoplot,st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        
                        ;Plotting of frequency axis
                        ;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)')
                        
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            cgplot,((*!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=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.psi_ext).sigma)(idx_spec)/2.
                            cgerrplot,((*!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'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            if ct_spec ne 0 then cgoplot,((*!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=[-90.00,90.00],/xlog else $;,ytickformat='dstmwrp_exp'
                                cgplot,((*!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=[-90.00,90.00],/xlog;,ytickformat='dstmwrp_exp'
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.psi_ext).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
                            cgerrplot,((*!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'
                            
                        endif
                        
                        
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} ext (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
                        match2,((*!dustem_data.psi_ext).wav),((*!dustem_show.psi_ext).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
                        idx_rmv_psi_em=where(show_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
                        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...
                        idx_spec_hdn = where(((*!dustem_show.psi_ext).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgplot,(((*!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=[-90.00,90.00],psym=8,syms=0.8
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.psi_ext).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
                                cgerrplot,(((*!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'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
                                cgplot,(((*!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=[-90.00,90.00],psym=8,syms=0.8                                           
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.psi_ext).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
                                cgerrplot,(((*!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'
                                 
                            endif 
                                                           
                        endif 
                        
                    endelse 
                
            endelse 
        
        end
        
        'QSED': begin ; THE ONE I WILL BE WORKING ON
            
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
            ;WHAT HAPPENS TO NULL VALUES ? 
            
            varvar=where((*!dustem_data.qsed).values GT 0, testpstv)
            varvar=where((*!dustem_data.qsed).values LT 0, testngtv)
            
            ;stop
            idx_filt=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM' , ct_spec)
            ;Plotting of frequency axis
            ;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)') 
            
            ;stop
            ;Locating all the hidden data points (spectrum+filter)
            match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
            ;stop
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.qsed).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.qsed).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.qsed).wav)(idx_spec),(((*!dustem_data.qsed).values)[idx_spec]-rms)/yy,(((*!dustem_data.qsed).values)[idx_spec]+rms)/yy,color='Powder Blue'
                        
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
                            xx=((*!dustem_data.qsed).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2. 
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.qsed).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.qsed).wav)(idx_filt),(((*!dustem_data.qsed).values)[idx_filt]-rms)/yy,(((*!dustem_data.qsed).values)[idx_filt]+rms)/yy,color='Dodger Blue' 
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/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
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot - STOPPED HERE FOR QSED
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        ;stop
                        if keyword_set(positive_only) then begin
     
                            if testpstv ne 0 then begin
                                ;stop
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    ;stop
                                    if countneq ne 0 then begin 
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        ;stop
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                        ;stop
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                        
                                        ;stop
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                        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
                                        ;stop
                                    endif
                                    ;stop
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                         
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            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      
                                        ENDIF
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    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 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                        
                        ;stop
                        if keyword_set(negative_only) then begin
                            ;stop     
                            if testngtv ne 0 then begin
                            
                                ;stop    
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    ;stop
                                    if countneq ne 0 then begin 
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        ;stop
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
                                        ;stop    
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                        ;stop
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                        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
                                    endif 
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
     
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            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      
                                        ENDIF
                                        
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    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 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                ;Plotting of the total dust emission spectrum
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
                        ;stop
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
                        xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
                        ;idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        ;idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts then begin
                            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)
                            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)
                            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)
                            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)
                        endif
                        
                        
                        if keyword_set(positive_only) then begin
                            ;stop
                            if testpstv ne 0 then begin
                            ;stop
                                ;plotsym, 0
                                
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                endif
                                
                                
                                
                                if ct_spec ne 0 then begin
                                
                                    rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
                                    ;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)'
                                    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)'
                                    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)'     
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
                                    rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
                                   ; 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)'
                                    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)'
                                    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)'
                                        
                                endif
                            endif else begin
                            
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
                                        
                                        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)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-((*!dustem_data.qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                    
                                    endif
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
                            
                            endelse                           
                        
                        endif 
                        
                        
                        if keyword_set(negative_only) then begin
                            
                            if testngtv ne 0 then begin
                                 
                                 ;plotsym, 0
                                 
                                 if ct_hdnpts then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
                                         xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
                                         xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif
                                
                                 endif

                                 if ct_spec ne 0 then begin
                                 
                                     rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
                                     ;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)'
                                    ; 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
                                         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)'
                                     ;endelse;,ytickformat='(A1)'
                                     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     
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
                                    ; 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)'
                                     ;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
                                         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)'
                                     ;endelse ;,ytickformat='(A1)'
                                     
                                     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)'
                                         
                                 endif 
                            
                            endif else begin
                                
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*!dustem_show.qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
                                        
                                        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)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-((*!dustem_data.qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                    
                                    endif
                                        
                                endif    
                            endelse
                            ;stop
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

        
        END
        
        'USED': begin
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
            varvar=where((*!dustem_data.used).values LT 0, testngtv)
            varvar=where((*!dustem_data.used).values GT 0, testpstv)
            ;stop
            idx_filt=where((*!dustem_data.used).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.used).filt_names EQ 'SPECTRUM' , ct_spec)
            ;Plotting of frequency axis
            ;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)') 
            
            ;stop
            ;Locating all the hidden data points (spectrum+filter)
            match2,((*!dustem_data.used).wav),((*!dustem_show.used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
            ;stop
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.used).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_spec),ppositions=position,((*!dustem_data.used).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.used).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.used).wav)(idx_spec),(((*!dustem_data.used).values)[idx_spec]-rms)/yy,(((*!dustem_data.used).values)[idx_spec]+rms)/yy,color='Powder Blue'
                        
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
                            xx=((*!dustem_data.used).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2. 
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.used).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.used).wav)(idx_filt),(((*!dustem_data.used).values)[idx_filt]-rms)/yy,(((*!dustem_data.used).values)[idx_filt]+rms)/yy,color='Dodger Blue' 
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/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
                        xyouts,pospltxt-[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot - STOPPED HERE FOR used
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        if keyword_set(positive_only) then begin
     
                            if testpstv ne 0 then begin
                                ;stop
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    
                                    if countneq ne 0 then begin 
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                            
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                        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
                                    endif 
                                    ;stop
                                ENDFOR
                                ;stop
                                for i=0L,n_plgns-1 do begin
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            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      
                                        ENDIF
                                        
                                    ENDIF
                                    
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    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 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                        
                        
                        if keyword_set(negative_only) then begin
     
                            if testngtv ne 0 then begin
                            
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    if countneq ne 0 then begin
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                        
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)/st.sed.(i+1),replicate(!dustem_psi,n_elements(spec)) ;temporary solution
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                        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
                                    endif    
                                ENDFOR
                                ;Plotting of the plugins
                                FOR i=0L,n_plgns-1 do begin
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            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      
                                        ENDIF
                                    ENDIF
                                ENDFOR
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    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 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                
                                ;Plotting of the total dust emission spectrum
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.
                        ;stop
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
                        xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                        
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
                        ;idx_filt_hdn = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        ;idx_spec_hdn = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts then begin
                            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)
                            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)
                            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)
                            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)
                        endif
                        ;stop
                        
                        if keyword_set(positive_only) then begin
                            ;stop
                            if testpstv ne 0 then begin
                            ;stop
                                plotsym, 0
                                
                                 
                                if ct_spec ne 0 then begin
                                
                                    rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
                                    ;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)'
                                    ;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
                                        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
                                    ;endelse;,ytickformat='(A1)'
                                    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
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
                                    rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
                                   ; 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)'
                                    ;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
                                    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
                                    ;endelse;,ytickformat='(A1)'
                                    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
                                        
                                endif
                                
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        ;stop
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
                                        
                                        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
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                        ;stop
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
                                        
                                        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   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                endif   
                            endif else begin
                                ;stop
                                if ct_hdnpts then begin
                                    if ct_spec_hdn_pstv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
                                       ; stop
                                        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)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-((*!dustem_data.used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                    
                                    endif
                                endif
18e4331f   Ilyes Choubani   general update (f...
2123
                            
67bd858a   Ilyes Choubani   Replication of th...
2124
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
2125
                        
67bd858a   Ilyes Choubani   Replication of th...
2126
                        endif 
18e4331f   Ilyes Choubani   general update (f...
2127
                        
67bd858a   Ilyes Choubani   Replication of th...
2128
                        if keyword_set(negative_only) then begin
18e4331f   Ilyes Choubani   general update (f...
2129
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
                            if testngtv ne 0 then begin
                                 
                                 plotsym, 0
                                 
                                 
                                 if ct_spec ne 0 then begin
                                 
                                     rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
                                     ;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)'
                                     ;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
                                     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)'
                                     ;endelse;,ytickformat='(A1)'
                                     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)'     
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
                                    ; 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)'
                                     ;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
                                     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)'
                                     ;endelse ;,ytickformat='(A1)'
                                     
                                     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)'
                                         
                                 endif
                                 
                                 if ct_hdnpts then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
                                         xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
                                         
                                         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
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
                                         xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
                                         
                                         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   
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif

                                 endif 
18e4331f   Ilyes Choubani   general update (f...
2182
                            
67bd858a   Ilyes Choubani   Replication of th...
2183
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
2184
                                
67bd858a   Ilyes Choubani   Replication of th...
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
                                        
                                        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)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-((*!dustem_data.used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                    
                                    endif
                                endif
                            ;stop
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2222
2223
2224
2225
2226
2227
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2228
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2229
            
67bd858a   Ilyes Choubani   Replication of th...
2230
2231
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2232
2233
2234
        
        end
        
67bd858a   Ilyes Choubani   Replication of th...
2235
2236
2237
2238
        'QEXT': begin
        
            varvar=where((*!dustem_data.qext).values GT 0, testpstv)
            varvar=where((*!dustem_data.qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2239
            
18e4331f   Ilyes Choubani   general update (f...
2240
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2241
2242
            idx_filt=where((*!dustem_data.qext).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.qext).filt_names EQ 'SPECTRUM' , ct_spec)
18e4331f   Ilyes Choubani   general update (f...
2243
2244
2245
2246
2247
            ;Plotting of frequency axis
            ;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)') 
            
            ;stop
            ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
2248
            match2,((*!dustem_data.qext).wav),((*!dustem_show.qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2249
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2250
            
5f04fa07   Ilyes Choubani   general update
2251
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
18e4331f   Ilyes Choubani   general update (f...
2266
2267
                    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  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
67bd858a   Ilyes Choubani   Replication of th...
2268
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{Q_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
2269
2270
2271
2272
2273
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2274
                
bc224f3e   Ilyes Choubani   Update of plottin...
2275
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2276
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2277
2278
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
c8368c6e   Ilyes Choubani   updating plotting...
2279
2280
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
18e4331f   Ilyes Choubani   general update (f...
2281
                        IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2282
                            xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2283
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2284
                            rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2285
2286
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
67bd858a   Ilyes Choubani   Replication of th...
2287
2288
                            cgoplot,xx,((*!dustem_data.qext).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.qext).wav)(idx_spec),(((*!dustem_data.qext).values)[idx_spec]-rms)/yy,(((*!dustem_data.qext).values)[idx_spec]+rms)/yy,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
2289
2290
2291
                        
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2292
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2293
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2294
                            xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2295
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2296
                            rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2. 
18e4331f   Ilyes Choubani   general update (f...
2297
2298
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
67bd858a   Ilyes Choubani   Replication of th...
2299
2300
                            cgoplot,xx,((*!dustem_data.qext).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.qext).wav)(idx_filt),(((*!dustem_data.qext).values)[idx_filt]-rms)/yy,(((*!dustem_data.qext).values)[idx_filt]+rms)/yy,color='Dodger Blue' 
bc224f3e   Ilyes Choubani   Update of plottin...
2301
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2302
      
bc224f3e   Ilyes Choubani   Update of plottin...
2303
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2304
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2305
                        ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2306
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
2307
2308
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/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
bc224f3e   Ilyes Choubani   Update of plottin...
2309
2310
2311
2312
2313
2314
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot - STOPPED HERE FOR QSED
c8368c6e   Ilyes Choubani   updating plotting...
2315
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2316
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
5f04fa07   Ilyes Choubani   general update
2317
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2318
2319
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2320
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
2321
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
2322
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2323
                                    
67bd858a   Ilyes Choubani   Replication of th...
2324
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
5f04fa07   Ilyes Choubani   general update
2325
2326
                                    ;stop
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2327
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2328
                                        ;stop
67bd858a   Ilyes Choubani   Replication of th...
2329
                                        vecfin[testneq] = ((st.polext.(i+1))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
5f04fa07   Ilyes Choubani   general update
2330
2331
                                        ;stop
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
67bd858a   Ilyes Choubani   Replication of th...
2332
                                        polar_ippsi2iqu,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2333
2334
2335
                                        
                                        ;stop
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
67bd858a   Ilyes Choubani   Replication of th...
2336
                                        dustem_plot_mlog,st.polext.wav,specqgrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
5f04fa07   Ilyes Choubani   general update
2337
2338
2339
                                        ;stop
                                    endif
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2340
2341
2342
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2343
2344
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2345
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2346
2347
                                         
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
67bd858a   Ilyes Choubani   Replication of th...
2348
                                            dustem_plot_mlog,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      
3c479f24   Ilyes Choubani   Allowing to fix p...
2349
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2350
2351
2352
2353
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2354
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2355
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2356
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2357
                                    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 
18e4331f   Ilyes Choubani   general update (f...
2358
2359
2360
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2361
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2362
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2363
2364
2365
2366
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                
67bd858a   Ilyes Choubani   Replication of th...
2367
                                dustem_plot_mlog,st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
2368
2369
2370
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2371
                        
18e4331f   Ilyes Choubani   general update (f...
2372
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2373
                        
5f04fa07   Ilyes Choubani   general update
2374
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2375
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2376
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2377
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2378
                            
5f04fa07   Ilyes Choubani   general update
2379
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2380
2381
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2382
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
5f04fa07   Ilyes Choubani   general update
2383
2384
                                    ;stop
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2385
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2386
                                        ;stop
67bd858a   Ilyes Choubani   Replication of th...
2387
                                        vecfin[testneq] = ((st.polext.(i+1))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
5f04fa07   Ilyes Choubani   general update
2388
                                        ;stop    
67bd858a   Ilyes Choubani   Replication of th...
2389
                                        polar_ippsi2iqu,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2390
2391
                                        ;stop
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
67bd858a   Ilyes Choubani   Replication of th...
2392
                                        dustem_plot_mlog,st.polext.wav,specqgrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
5f04fa07   Ilyes Choubani   general update
2393
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2394
2395
2396
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2397
2398
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2399
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2400
2401
     
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
67bd858a   Ilyes Choubani   Replication of th...
2402
                                            dustem_plot_mlog,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      
3c479f24   Ilyes Choubani   Allowing to fix p...
2403
2404
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2405
2406
2407
2408
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2409
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2410
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2411
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2412
                                    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 
18e4331f   Ilyes Choubani   general update (f...
2413
2414
2415
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2416
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2417
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2418
2419
2420
2421
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                ;Plotting of the total dust emission spectrum
67bd858a   Ilyes Choubani   Replication of th...
2422
                                dustem_plot_mlog,st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
2423
2424
2425
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2426
                        
18e4331f   Ilyes Choubani   general update (f...
2427
2428
2429
2430
2431
2432
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
                        ;stop
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2433
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{Q_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2434
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2435
                            
2df3360b   Ilyes Choubani   Correcting error:...
2436
2437
2438
2439
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
                        ;idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        ;idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
9cb38725   Ilyes Choubani   Fixed tests relat...
2440
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2441
2442
2443
2444
                            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)
                            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)
                            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)
                            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)
9cb38725   Ilyes Choubani   Fixed tests relat...
2445
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2446
                        
c8368c6e   Ilyes Choubani   updating plotting...
2447
                        
18e4331f   Ilyes Choubani   general update (f...
2448
2449
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
2450
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2451
                            ;stop
9cb38725   Ilyes Choubani   Fixed tests relat...
2452
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2453
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2454
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2455
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2456
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2457
2458
2459
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2460
2461
2462
2463
2464
2465
2466
2467
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2468
2469
2470
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2471
2472
2473
2474
2475
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2476
                                    
18e4331f   Ilyes Choubani   general update (f...
2477
2478
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2479
2480
                                
                                
18e4331f   Ilyes Choubani   general update (f...
2481
2482
                                if ct_spec ne 0 then begin
                                
67bd858a   Ilyes Choubani   Replication of th...
2483
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2484
                                    ;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)'
67bd858a   Ilyes Choubani   Replication of th...
2485
2486
                                    dustem_plot_mlog,((*!dustem_data.qext).wav)(idx_spec),((*!dustem_data.qext).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)'
                                    dustem_plot_mlog,((*!dustem_data.qext).wav)(idx_spec),((*!dustem_data.qext).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)'     
18e4331f   Ilyes Choubani   general update (f...
2487
2488
2489
2490
2491
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2492
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2493
                                   ; 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)'
67bd858a   Ilyes Choubani   Replication of th...
2494
2495
                                    dustem_plot_mlog,((*!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)'
                                    dustem_plot_mlog,((*!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)'
18e4331f   Ilyes Choubani   general update (f...
2496
2497
2498
2499
                                        
                                endif
                            endif else begin
                            
9cb38725   Ilyes Choubani   Fixed tests relat...
2500
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2501
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2502
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2503
2504
2505
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2506
2507
2508
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2509
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2510
2511
2512
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2513
                                    
67bd858a   Ilyes Choubani   Replication of th...
2514
2515
2516
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
18e4331f   Ilyes Choubani   general update (f...
2517
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2518
2519
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2520
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2521
2522
2523
                                    endif
                                    
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2524
                                        
67bd858a   Ilyes Choubani   Replication of th...
2525
                                        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,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2526
2527
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
2528
                                        if ct_filt ne 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,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2529
                                            
18e4331f   Ilyes Choubani   general update (f...
2530
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2531
2532
                                    endif
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
18e4331f   Ilyes Choubani   general update (f...
2533
2534
                            
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
2535
                        
18e4331f   Ilyes Choubani   general update (f...
2536
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2537
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2538
                        
18e4331f   Ilyes Choubani   general update (f...
2539
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
2540
                            
2df3360b   Ilyes Choubani   Correcting error:...
2541
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2542
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2543
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2544
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2545
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2546
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2547
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2548
2549
2550
                                         xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2551
2552
2553
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2554
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2555
2556
2557
2558
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2559
2560
2561
                                         xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2562
2563
2564
2565
2566
2567
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif
                                
18e4331f   Ilyes Choubani   general update (f...
2568
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
2569

18e4331f   Ilyes Choubani   general update (f...
2570
2571
                                 if ct_spec ne 0 then begin
                                 
67bd858a   Ilyes Choubani   Replication of th...
2572
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2573
                                     ;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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2574
                                    ; 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
67bd858a   Ilyes Choubani   Replication of th...
2575
                                         dustem_plot_mlog,((*!dustem_data.qext).wav)(idx_spec),((*!dustem_data.qext).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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2576
                                     ;endelse;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2577
                                     dustem_plot_mlog,((*!dustem_data.qext).wav)(idx_spec),((*!dustem_data.qext).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     
18e4331f   Ilyes Choubani   general update (f...
2578
2579
2580
2581
2582
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2583
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2584
                                    ; 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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2585
                                     ;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
67bd858a   Ilyes Choubani   Replication of th...
2586
                                         dustem_plot_mlog,((*!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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2587
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2588
                                     
67bd858a   Ilyes Choubani   Replication of th...
2589
                                     dustem_plot_mlog,((*!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)'
18e4331f   Ilyes Choubani   general update (f...
2590
2591
                                         
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
2592
                            
c8368c6e   Ilyes Choubani   updating plotting...
2593
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
2594
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2595
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2596
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2597
                                    if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2598
2599
2600
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2601
2602
2603
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2604
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2605
2606
2607
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2608
                                    
67bd858a   Ilyes Choubani   Replication of th...
2609
2610
2611
                                        xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
18e4331f   Ilyes Choubani   general update (f...
2612
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2613
2614
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2615
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2616
2617
2618
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2619
                                        
67bd858a   Ilyes Choubani   Replication of th...
2620
                                        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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2621
2622
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
2623
                                        if ct_filt ne 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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2624
                                            
18e4331f   Ilyes Choubani   general update (f...
2625
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2626
2627
2628
                                    endif
                                        
                                endif    
18e4331f   Ilyes Choubani   general update (f...
2629
                            endelse
5f04fa07   Ilyes Choubani   general update
2630
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2631
2632
2633
2634
2635
2636
2637
2638
2639
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2640
            endelse ; 
18e4331f   Ilyes Choubani   general update (f...
2641
        
67bd858a   Ilyes Choubani   Replication of th...
2642
        end
18e4331f   Ilyes Choubani   general update (f...
2643
        
67bd858a   Ilyes Choubani   Replication of th...
2644
2645
2646
2647
2648
2649
        'UEXT': begin
        
        
            varvar=where((*!dustem_data.uext).values GT 0, testpstv)
            varvar=where((*!dustem_data.uext).values LT 0, testngtv)
            
18e4331f   Ilyes Choubani   general update (f...
2650
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2651
2652
            idx_filt=where((*!dustem_data.uext).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.uext).filt_names EQ 'SPECTRUM' , ct_spec)
18e4331f   Ilyes Choubani   general update (f...
2653
2654
2655
2656
2657
            ;Plotting of frequency axis
            ;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)') 
            
            ;stop
            ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
2658
            match2,((*!dustem_data.uext).wav),((*!dustem_show.uext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2659
2660
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
5f04fa07   Ilyes Choubani   general update
2661
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2662
            
18e4331f   Ilyes Choubani   general update (f...
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
67bd858a   Ilyes Choubani   Replication of th...
2678
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{U_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2692
                            xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2693
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2694
2695
2696
2697
2698
                            rms=3.*((*!dustem_data.uext).sigma)(idx_spec)/2.
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,psym=16,color='Powder Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_spec),ppositions=position,((*!dustem_data.qsed).values)[idx_spec]/yy,psym=16,color='Powder Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.uext).values)(idx_spec)/yy,pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.uext).wav)(idx_spec),(((*!dustem_data.uext).values)[idx_spec]-rms)/yy,(((*!dustem_data.uext).values)[idx_spec]+rms)/yy,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
2699
2700
2701
2702
2703
                        
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2704
                            xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2705
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2706
2707
2708
2709
2710
                            rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2. 
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.qsed).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.uext).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.uext).wav)(idx_filt),(((*!dustem_data.uext).values)[idx_filt]-rms)/yy,(((*!dustem_data.uext).values)[idx_filt]+rms)/yy,color='Dodger Blue' 
18e4331f   Ilyes Choubani   general update (f...
2711
2712
2713
2714
2715
2716
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
2717
2718
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/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
67bd858a   Ilyes Choubani   Replication of th...
2719
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
2720
2721
2722
2723
                    
                    endelse
                    
                
67bd858a   Ilyes Choubani   Replication of th...
2724
                endif else begin ; normal plot - STOPPED HERE FOR QSED
18e4331f   Ilyes Choubani   general update (f...
2725
2726
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
67bd858a   Ilyes Choubani   Replication of th...
2727
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2728
2729
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2730
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
2731
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
2732
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2733
                                    
67bd858a   Ilyes Choubani   Replication of th...
2734
2735
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
                                    ;stop
5f04fa07   Ilyes Choubani   general update
2736
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2737
2738
2739
2740
2741
2742
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
                                        ;stop
                                        vecfin[testneq] = ((st.polext.(i+1))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                        ;stop
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
                                        polar_ippsi2iqu,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2743
                                        
67bd858a   Ilyes Choubani   Replication of th...
2744
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2745
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
67bd858a   Ilyes Choubani   Replication of th...
2746
2747
2748
                                        dustem_plot_mlog,st.polext.wav,specugrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                        ;stop
                                    endif
5f04fa07   Ilyes Choubani   general update
2749
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2750
                                ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
2751
                                
18e4331f   Ilyes Choubani   general update (f...
2752
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2753
2754
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2755
2756
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                         
3c479f24   Ilyes Choubani   Allowing to fix p...
2757
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
67bd858a   Ilyes Choubani   Replication of th...
2758
                                            dustem_plot_mlog,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      
3c479f24   Ilyes Choubani   Allowing to fix p...
2759
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2760
                                    ENDIF
18e4331f   Ilyes Choubani   general update (f...
2761
2762
2763
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2764
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2765
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2766
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2767
                                    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 
18e4331f   Ilyes Choubani   general update (f...
2768
2769
2770
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2771
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2772
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2773
2774
2775
2776
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
                                
67bd858a   Ilyes Choubani   Replication of th...
2777
                                dustem_plot_mlog,st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
2778
2779
2780
2781
2782
2783
                            
                            endif
                                    
                        
                        endif
                        
67bd858a   Ilyes Choubani   Replication of th...
2784
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2785
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2786
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2787
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2788
                            
67bd858a   Ilyes Choubani   Replication of th...
2789
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2790
2791
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2792
2793
2794
2795
2796
2797
2798
2799
2800
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
                                    ;stop
                                    if countneq ne 0 then begin 
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
                                        ;stop
                                        vecfin[testneq] = ((st.polext.(i+1))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
                                        ;stop    
                                        polar_ippsi2iqu,st.ext.(i+1)*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2801
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
67bd858a   Ilyes Choubani   Replication of th...
2802
2803
                                        dustem_plot_mlog,st.polext.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2804
2805
                                ENDFOR
                                ;Plotting of the plugins
67bd858a   Ilyes Choubani   Replication of th...
2806
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2807
2808
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2809
2810
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
     
3c479f24   Ilyes Choubani   Allowing to fix p...
2811
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
67bd858a   Ilyes Choubani   Replication of th...
2812
                                            dustem_plot_mlog,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      
3c479f24   Ilyes Choubani   Allowing to fix p...
2813
                                        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2814
                                        
18e4331f   Ilyes Choubani   general update (f...
2815
                                    ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2816
                                endfor
18e4331f   Ilyes Choubani   general update (f...
2817
2818
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2819
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2820
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2821
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2822
                                    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 
18e4331f   Ilyes Choubani   general update (f...
2823
2824
2825
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2826
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2827
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2828
2829
2830
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    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
                                ENDIF
18e4331f   Ilyes Choubani   general update (f...
2831
                                ;Plotting of the total dust emission spectrum
67bd858a   Ilyes Choubani   Replication of th...
2832
                                dustem_plot_mlog,st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2833
                            
18e4331f   Ilyes Choubani   general update (f...
2834
2835
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2836
2837
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
2838
2839
                                                   
                      ;stop             
67bd858a   Ilyes Choubani   Replication of th...
2840
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
bc224f3e   Ilyes Choubani   Update of plottin...
2841
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2842
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2843
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{U_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2844
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
67bd858a   Ilyes Choubani   Replication of th...
2845
                            
2df3360b   Ilyes Choubani   Correcting error:...
2846
2847
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
67bd858a   Ilyes Choubani   Replication of th...
2848
2849
                        ;idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        ;idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
9cb38725   Ilyes Choubani   Fixed tests relat...
2850
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2851
2852
2853
2854
                            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)
                            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)
                            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)
                            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)
9cb38725   Ilyes Choubani   Fixed tests relat...
2855
                        endif
67bd858a   Ilyes Choubani   Replication of th...
2856
                        
18e4331f   Ilyes Choubani   general update (f...
2857
2858
2859
                        
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
2860
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2861
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2862
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2863
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2864
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2865
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2866
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2867
2868
2869
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2870
                                        
67bd858a   Ilyes Choubani   Replication of th...
2871
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
9cb38725   Ilyes Choubani   Fixed tests relat...
2872
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2873
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2874
2875
2876
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2877
2878
2879
2880
                                    
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2881
                                        
67bd858a   Ilyes Choubani   Replication of th...
2882
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
9cb38725   Ilyes Choubani   Fixed tests relat...
2883
2884
2885
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
                                    
                                endif
                                
                                
                                
                                if ct_spec ne 0 then begin
                                
                                    rms=3.*((*!dustem_data.uext).sigma)(idx_spec)/2.
                                    ;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)'
                                    dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),((*!dustem_data.uext).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)'
                                    dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),((*!dustem_data.uext).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)'     
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
                                    rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2.
                                   ; 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)'
                                    dustem_plot_mlog,((*!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)'
                                    dustem_plot_mlog,((*!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)'
                                        
                                endif
2df3360b   Ilyes Choubani   Correcting error:...
2908
                            endif else begin
67bd858a   Ilyes Choubani   Replication of th...
2909
                            
9cb38725   Ilyes Choubani   Fixed tests relat...
2910
                                if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2911
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2912
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2913
2914
2915
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2916
2917
2918
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2919
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2920
2921
2922
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2923
                                    
67bd858a   Ilyes Choubani   Replication of th...
2924
2925
2926
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
18e4331f   Ilyes Choubani   general update (f...
2927
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2928
2929
2930
2931
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2932
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2933
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2934
2935
                                        
                                        if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),-((*!dustem_data.uext).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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2936
                                            
18e4331f   Ilyes Choubani   general update (f...
2937
                                        
67bd858a   Ilyes Choubani   Replication of th...
2938
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2939
                                            
18e4331f   Ilyes Choubani   general update (f...
2940
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2941
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
2942
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
18e4331f   Ilyes Choubani   general update (f...
2943
                            
67bd858a   Ilyes Choubani   Replication of th...
2944
                            endelse                           
18e4331f   Ilyes Choubani   general update (f...
2945
2946
2947
                        
                        endif 
                        
67bd858a   Ilyes Choubani   Replication of th...
2948
                        
18e4331f   Ilyes Choubani   general update (f...
2949
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2950
                            
2df3360b   Ilyes Choubani   Correcting error:...
2951
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2952
                                 
67bd858a   Ilyes Choubani   Replication of th...
2953
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2954
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2955
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2956
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2957
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2958
2959
2960
                                         xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2961
                                         
67bd858a   Ilyes Choubani   Replication of th...
2962
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
9cb38725   Ilyes Choubani   Fixed tests relat...
2963
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
2964
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2965
                                     endif 
18e4331f   Ilyes Choubani   general update (f...
2966
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2967
2968
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2969
2970
2971
                                         xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2972
                                         
67bd858a   Ilyes Choubani   Replication of th...
2973
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
9cb38725   Ilyes Choubani   Fixed tests relat...
2974
2975
2976
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif
67bd858a   Ilyes Choubani   Replication of th...
2977
2978
                                
                                 endif
18e4331f   Ilyes Choubani   general update (f...
2979

67bd858a   Ilyes Choubani   Replication of th...
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
                                 if ct_spec ne 0 then begin
                                 
                                     rms=3.*((*!dustem_data.uext).sigma)(idx_spec)/2.
                                     ;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)'
                                    ; 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
                                         dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),((*!dustem_data.uext).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)'
                                     ;endelse;,ytickformat='(A1)'
                                     dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),((*!dustem_data.uext).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     
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2.
                                    ; 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)'
                                     ;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
                                         dustem_plot_mlog,((*!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)'
                                     ;endelse ;,ytickformat='(A1)'
                                     
                                     dustem_plot_mlog,((*!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)'
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
3001
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
3002
                            
2df3360b   Ilyes Choubani   Correcting error:...
3003
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
3004
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
3005
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
3006
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
3007
                                    if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
3008
3009
3010
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
3011
3012
3013
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
3014
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3015
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
3016
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3017
3018
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
3019
3020
3021
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
18e4331f   Ilyes Choubani   general update (f...
3022
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
3023
3024
3025
3026
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
3027
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3028
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
3029
                                        
67bd858a   Ilyes Choubani   Replication of th...
3030
                                        if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.uext).wav)(idx_spec),-((*!dustem_data.uext).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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
3031
3032
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
3033
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
3034
                                            
18e4331f   Ilyes Choubani   general update (f...
3035
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3036
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
3037
3038
                                        
                                endif    
2df3360b   Ilyes Choubani   Correcting error:...
3039
                            endelse
5f04fa07   Ilyes Choubani   general update
3040
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
3041
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
3042
3043
3044
3045
                        
                    
                    endelse 
                
bc224f3e   Ilyes Choubani   Update of plottin...
3046
3047
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
3048
            endelse 
b5314324   Ilyes Choubani   updating the plot...
3049
3050
        
        end
5f04fa07   Ilyes Choubani   general update
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
        
        'PARAMETERS':begin ;needs the followingd data (errors+res+formats)
         ;I will declare the formats whithin this procedure and will use the required keywords of this procedure to intorduce res and errors. 
            p_dim = extra_spec
            ;stop
            Npar=n_elements(p_dim)
            
            if keyword_set(refresh) then begin ;data in the parameter window that is being refreshed
                ;stop
                k=0    
                res = dustem_interp
                errors = dustem_spec
                ;This is a wrong block because it is not written for the refreshing 
                
                FOR i=0L,Npar-1 DO BEGIN   
                  
                  parameter_description = (*(*!dustem_fit).param_descs)[i]
                  parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                  
                      
fcb6eade   Ilyes Choubani   general update - ...
3071
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).' and STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O' then begin
5f04fa07   Ilyes Choubani   general update
3072
3073
3074
3075
3076
                      
                        indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                        string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                        
                        ;choosing a step of 0.03 in norm coordinates 
dfc68a85   Ilyes Choubani   Fixed some plotti...
3077
                        yypos = 0.85 - k*0.09 
5f04fa07   Ilyes Choubani   general update
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
                        xxpos = 0.0
                        
                        ;original line
                        ;str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1)
                        
                        str = strtrim(string(string_name+' = ',format=frmt0),2)+ string(res[i],format=frmt1) + textoidl(' \pm ') +string(errors(i),format=frmt1)
                        ;will this work? 
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos = (1-thiswidth)/2
                        str = strtrim(string(string_name+' = ',format=frmt0),2)
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos+= thiswidth 
                        
                        str= string(res[i],format=frmt1) + textoidl(' \pm ') + string(errors(i),format=frmt1)
                        ;stop
                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        k+=1            
                        
                    ENDIF
fcb6eade   Ilyes Choubani   general update - ...
3097
3098
3099
3100
3101
3102
3103
3104
3105
                    
                    
                    
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).' and ~(STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O') then begin
                      
                        ;indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                        ;string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                          
                        ;choosing a step of 0.03 in norm coordinates 
dfc68a85   Ilyes Choubani   Fixed some plotti...
3106
                        yypos = 0.85 - k*0.09 
fcb6eade   Ilyes Choubani   general update - ...
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
                        xxpos = 0.0
                        
                        ;original line
                        ;str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1)
                        
                        str = strtrim(string(string_name+' = ',format=frmt0),2)+ string(res[i],format=frmt1) + textoidl(' \pm ') +string(errors(i),format=frmt1)
                        ;will this work? 
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos = (1-thiswidth)/2
                        str = strtrim(string(string_name+' = ',format=frmt0),2)
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos+= thiswidth 
                        
                        str= string(res[i],format=frmt1) + textoidl(' \pm ') + string(errors(i),format=frmt1)
                        ;stop
                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        k+=1            
                        
                    ENDIF
                    
                    
                    
5f04fa07   Ilyes Choubani   general update
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
                
                ENDFOR        
                
                                        
                
            endif else begin ;data in the parameter window that is unchanged 
                ;stop
                k=0   
                res = dustem_interp
                errors = dustem_spec
                ;stop
                FOR i=0L,Npar-1 DO BEGIN  
                  ;stop
                  parameter_description = (*(*!dustem_fit).param_descs)[i]
                  parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                  
                  ;stop    
fcb6eade   Ilyes Choubani   general update - ...
3146
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).' and STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O' then begin
5f04fa07   Ilyes Choubani   general update
3147
3148
3149
3150
3151
                      
                        indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                        string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                        ;stop
                        ;choosing a step of 0.03 in norm coordinates 
dfc68a85   Ilyes Choubani   Fixed some plotti...
3152
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
                        xxpos = 0.0    
                                                    
                        str=strtrim(string(string_name+' = ',format=frmt0),2)
                        ;stop    
                        str1=str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
                        ;stop
                        cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                        xxpos=(1-thiswidth)/2 
                        ;stop
                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        
                        k+=1            
                        ;stop
                  ENDIF
fcb6eade   Ilyes Choubani   general update - ...
3167
3168
3169
3170
3171
3172
3173
3174
                  
                  
                  IF STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).' and ~(STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O') then begin
                    
                      ;indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                      ;string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                      ;stop
                      ;choosing a step of 0.03 in norm coordinates 
dfc68a85   Ilyes Choubani   Fixed some plotti...
3175
                      yypos = 0.85 - k*0.09
fcb6eade   Ilyes Choubani   general update - ...
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
                      xxpos = 0.0    
                                                  
                      str=strtrim(string(string_name+' = ',format=frmt0),2)
                      ;stop    
                      str1=str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
                      ;stop
                      cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                      xxpos=(1-thiswidth)/2 
                      ;stop
                      xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                      
                      k+=1            
                      ;stop
                ENDIF
5f04fa07   Ilyes Choubani   general update
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
                
                ENDFOR
                
                
            endelse
        
        end
        
        'PLUGINS':begin ;NOT SO SURE ABOUT THIS BLOCK . TEST IT WHEN YOU GET HOME
           
            p_dim = extra_spec
        
            Npar=n_elements(p_dim)
        
            if keyword_set(refresh) then begin ;(REFRESHED RUN) 
                
                k=0
                res = dustem_interp
                errors = dustem_spec
                
                FOR i=0L,Npar-1 DO BEGIN  
                  ;stop
                    parameter_description = (*(*!dustem_fit).param_descs)[i]
                    parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                  
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,6)) eq 'DUSTEM' THEN BEGIN
                        
                        ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
3c479f24   Ilyes Choubani   Allowing to fix p...
3218
3219
                        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
                        prmtg = (*(*!dustem_plugin).(mm).paramtag)
5f04fa07   Ilyes Choubani   general update
3220
3221
3222
                        indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)     
                        indtg = fix(indtg)
                        prmtg = prmtg[indtg-1] 
dfc68a85   Ilyes Choubani   Fixed some plotti...
3223
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
                        xxpos = 0.0 
                        
                        str = strtrim(string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0),2)
                        str1 = str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
                        cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                        xxpos=(1-thiswidth)/2
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos+=thiswidth;(1-thiswidth)/2
                        str = string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)

                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        k+=1
                        
                    ENDIF          
                            
                
                ENDFOR
            
            endif else begin ;(FROZEN RUN = title strings)
                
                k=0
                res = dustem_interp
                errors = dustem_spec
                    
                FOR i=0L,Npar-1 DO BEGIN  
                  ;stop
                    parameter_description = (*(*!dustem_fit).param_descs)[i]
                    parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                    
                    
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,6)) eq 'DUSTEM' THEN BEGIN
                        
                        ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
3c479f24   Ilyes Choubani   Allowing to fix p...
3257
3258
                        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
                        prmtg = (*(*!dustem_plugin).(mm).paramtag)
5f04fa07   Ilyes Choubani   general update
3259
3260
3261
3262
                        indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)     
                        indtg = fix(indtg)
                        prmtg = prmtg[indtg-1] 
                         
dfc68a85   Ilyes Choubani   Fixed some plotti...
3263
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
                        xxpos = 0.0;15 
                        
                        str = string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0)
                        str=strtrim(str,2)
                        str1 = str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)           
                        ;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
                        
                        cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                        xxpos=(1-thiswidth)/2 
                       
                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        k+=1
                        
                    ENDIF
                      
                    
                
                ENDFOR
            
            endelse
         
        
        
5f04fa07   Ilyes Choubani   general update
3287
3288
        end
        
b5314324   Ilyes Choubani   updating the plot...
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
    
    endcase


endif











 


 
  












END