Blame view

src/idl/dustemcgwin_dataset.pro 243 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
if keyword_set(dataset) then begin
;!run_pol is implied for QSED/USED/POLSED etc...
    Case strupcase(dataset) of 
    
        'SED': begin
            
afde94a3   Ilyes Choubani   general update
53
54
55
56
57
58
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
b5314324   Ilyes Choubani   updating the plot...
59
60
61
62
63
64
65
66
67
68
69
            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 = ''
afde94a3   Ilyes Choubani   general update
70
                    cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
b5314324   Ilyes Choubani   updating the plot...
71
72
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
5f04fa07   Ilyes Choubani   general update
73
74
75
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
afde94a3   Ilyes Choubani   general update
76
                    ;/NODATA    
b5314324   Ilyes Choubani   updating the plot...
77
78
                    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
79
                    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...
80
                  
5f04fa07   Ilyes Choubani   general update
81
82
                ;endelse  
                endif
b5314324   Ilyes Choubani   updating the plot...
83
            
5f04fa07   Ilyes Choubani   general update
84
85
            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...
86
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
87
                    
b5314324   Ilyes Choubani   updating the plot...
88
89
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
b5314324   Ilyes Choubani   updating the plot...
90
91
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
92
                            yy=dustem_interp[idx_spec]
b5314324   Ilyes Choubani   updating the plot...
93
94
95
                            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...
96
                        ENDIF
b5314324   Ilyes Choubani   updating the plot...
97
                        
c8368c6e   Ilyes Choubani   updating plotting...
98
99
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
100
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
101
102
                            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...
103
                            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...
104
105
106
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
107
108
                    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...
109
                        
5f04fa07   Ilyes Choubani   general update
110
111
                    if not keyword_set(refresh) then begin 
                        ;stop   
afde94a3   Ilyes Choubani   general update
112
                        
b5314324   Ilyes Choubani   updating the plot...
113
                        xtit=textoidl('\lambda (\mum)')
fcb6eade   Ilyes Choubani   general update - ...
114
115
116
117
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
e0d00de0   Ilyes Choubani   removing stops
118
                        
afde94a3   Ilyes Choubani   general update
119
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
b5314324   Ilyes Choubani   updating the plot...
120
121
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
5f04fa07   Ilyes Choubani   general update
122
123
                    ;endelse
                    endif
b5314324   Ilyes Choubani   updating the plot...
124
125
                    
                
5f04fa07   Ilyes Choubani   general update
126
127
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
b5314324   Ilyes Choubani   updating the plot...
128
129
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
b5314324   Ilyes Choubani   updating the plot...
130
131
132
133
134
                        ;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...
135
                                                
b5314324   Ilyes Choubani   updating the plot...
136
137
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
138
139
140
141
142
143
144
145
146
                            
                            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...
147
                        endfor
c8368c6e   Ilyes Choubani   updating plotting...
148
                                                
b5314324   Ilyes Choubani   updating the plot...
149
                        ;PLotting of the interpolates corresponding to spectrum and filter points
c8368c6e   Ilyes Choubani   updating plotting...
150
                           
b5314324   Ilyes Choubani   updating the plot...
151
152
153
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
154
                            yy=dustem_interp[idx_spec]
abebbdf3   Ilyes Choubani   General update: A...
155
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
b5314324   Ilyes Choubani   updating the plot...
156
157
                        ENDIF
                        
c8368c6e   Ilyes Choubani   updating plotting...
158
159
160
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
161
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
162
163
164
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
b5314324   Ilyes Choubani   updating the plot...
165
                        
c8368c6e   Ilyes Choubani   updating plotting...
166
                        ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
167
                        cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
c8368c6e   Ilyes Choubani   updating plotting...
168
169
170
                         
                                        
                                
5f04fa07   Ilyes Choubani   general update
171
172
173
                    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...
174
175
176
177
                        ;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...
178
                            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...
179
180
181
182
183
184
185
186
                            
                            ;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...
187
                        
b5314324   Ilyes Choubani   updating the plot...
188
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
dfc68a85   Ilyes Choubani   Fixed some plotti...
189
190
                            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...
191
                            
b5314324   Ilyes Choubani   updating the plot...
192
193
194
195
                            
                            ;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...
196
                            
b5314324   Ilyes Choubani   updating the plot...
197
                        endif
c8368c6e   Ilyes Choubani   updating plotting...
198
199
                        
                        
b5314324   Ilyes Choubani   updating the plot...
200
                        ;Plotting of frequency axis
c8368c6e   Ilyes Choubani   updating plotting...
201
202
                        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
203
                        xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
c8368c6e   Ilyes Choubani   updating plotting...
204
                         
b5314324   Ilyes Choubani   updating the plot...
205
                        ;Locating all the hidden data points (spectrum+filter)
abebbdf3   Ilyes Choubani   General update: A...
206
                        match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
b5314324   Ilyes Choubani   updating the plot...
207
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
208
209
210
211
                        ;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...
212
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
213
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
214
215
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
dfc68a85   Ilyes Choubani   Fixed some plotti...
216
                                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...
217
218
219
220
221
                                
                                ;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...
222
                            
18e4331f   Ilyes Choubani   general update (f...
223
                            if ct_filt_hdn then begin
b5314324   Ilyes Choubani   updating the plot...
224
                            ;Plotting of hidden filter data points 
dfc68a85   Ilyes Choubani   Fixed some plotti...
225
                                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...
226
227
228
229
230
231
                                
                                ;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...
232
233
234
235
236
                                                           
                        endif    
                        
                        
                    
5f04fa07   Ilyes Choubani   general update
237
238
                    ;endelse 
                    endif
b5314324   Ilyes Choubani   updating the plot...
239
240
                
                
5f04fa07   Ilyes Choubani   general update
241
242
243
244
                ;endelse 
                endif            
            ;endelse
            endif 
18e4331f   Ilyes Choubani   general update (f...
245
        ;stop    
b5314324   Ilyes Choubani   updating the plot...
246
247
        end
        
afde94a3   Ilyes Choubani   general update
248
        'EXT': begin ;BE VERY CAREFUL THE EXTINCTION STRUCTURE AS REDERED BY DUSTEM IS DIFFERENT THAN THE EMISSION ONE
b5314324   Ilyes Choubani   updating the plot...
249
        
afde94a3   Ilyes Choubani   general update
250
251
252
253
254
255
256
257
258
259
;             ;So far manually changing xr and yr.
;             
;             xr=[0.01,30]
;             yr=[1.00E-06,10]
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
67bd858a   Ilyes Choubani   Replication of th...
260
261
262
263
264
265
266
267
268
269
270
            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 = ''
afde94a3   Ilyes Choubani   general update
271
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
272
273
274
275
276
                    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
afde94a3   Ilyes Choubani   general update
277
                    ;/NODATA    
67bd858a   Ilyes Choubani   Replication of th...
278
                    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  
afde94a3   Ilyes Choubani   general update
279
                    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...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
                    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.
afde94a3   Ilyes Choubani   general update
295
296
                            cgoplot,1/xx,((*!dustem_data.ext).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            cgerrplot,1/((*!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'
67bd858a   Ilyes Choubani   Replication of th...
297
298
299
300
301
302
                        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. 
afde94a3   Ilyes Choubani   general update
303
304
                            cgoplot,1/xx,((*!dustem_data.ext).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,1/((*!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 
67bd858a   Ilyes Choubani   Replication of th...
305
306
307
308
309
310
311
312
313
314
315
316
317
                        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
afde94a3   Ilyes Choubani   general update
318
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
319
320
321
322
323
324
325
326
327
328
329
330
331
                        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
afde94a3   Ilyes Choubani   general update
332
                    
67bd858a   Ilyes Choubani   Replication of th...
333
                        FOR i=0L,Ngrains-1 DO BEGIN
afde94a3   Ilyes Choubani   general update
334
                            cgoplot,1/st.ext.wav,((st.ext.(1))[i,*]+(st.ext.(2))[i,*])*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
335
336
337
338
339
340
341
342
343
                        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
afde94a3   Ilyes Choubani   general update
344
                                    cgoplot,1/st.ext.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
345
346
347
348
349
350
351
352
353
354
355
356
357
                                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]
afde94a3   Ilyes Choubani   general update
358
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
359
360
361
362
363
364
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.ext).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
365
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
366
367
368
369
                        ENDIF
                        
                        
                        ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
370
                        cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
67bd858a   Ilyes Choubani   Replication of th...
371
372
373
374
375
376
377
378
379
380
                         
                                        
                                
                    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)
afde94a3   Ilyes Choubani   general update
381
                            cgplot,1/((*!dustem_data.ext).wav)(idx_spec),((*!dustem_data.ext).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=16,syms=0.8,ytickformat='dstmwrp_exp'                
67bd858a   Ilyes Choubani   Replication of th...
382
383
384
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
385
                            cgerrplot,1/((*!dustem_data.ext).wav)(idx_spec),((*!dustem_data.ext).values)(idx_spec)-rms,((*!dustem_data.ext).values)(idx_spec)+rms,color='Powder Blue'
67bd858a   Ilyes Choubani   Replication of th...
386
387
388
389
390
391

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
afde94a3   Ilyes Choubani   general update
392
393
                            if ct_spec ne 0 then cgoplot,1/((*!dustem_data.ext).wav)(idx_filt),((*!dustem_data.ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,1/((*!dustem_data.ext).wav)(idx_filt),((*!dustem_data.ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
67bd858a   Ilyes Choubani   Replication of th...
394
395
396
397
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
afde94a3   Ilyes Choubani   general update
398
                            cgerrplot,1/((*!dustem_data.ext).wav)(idx_filt),((*!dustem_data.ext).values)(idx_filt)-rms,((*!dustem_data.ext).values)(idx_filt)+rms,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
399
400
401
402
403
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
afde94a3   Ilyes Choubani   general update
404
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
67bd858a   Ilyes Choubani   Replication of th...
405
406
407
408
409
410
411
412
413
414
415
416
417
418
                        
                        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
afde94a3   Ilyes Choubani   general update
419
                                cgoplot,1/(((*!dustem_show.ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=16,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
420
421
422
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
423
                                cgerrplot,1/(((*!dustem_show.ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
424
425
426
427
                            endif                                            
                            
                            if ct_filt_hdn then begin
                            ;Plotting of hidden filter data points 
afde94a3   Ilyes Choubani   general update
428
                                cgoplot,1/(((*!dustem_show.ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=16,syms=0.8                                           
67bd858a   Ilyes Choubani   Replication of th...
429
430
431
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
432
                                cgerrplot,1/(((*!dustem_show.ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*!dustem_show.ext).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    ;endelse 
                    endif
                
                
                ;endelse 
                endif            
            ;endelse
            endif
          
b5314324   Ilyes Choubani   updating the plot...
449
450
451
        
        end
        
67bd858a   Ilyes Choubani   Replication of th...
452
453
        'POLEXT': begin 
            
afde94a3   Ilyes Choubani   general update
454
455
456
457
458
459
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
67bd858a   Ilyes Choubani   Replication of th...
460
461
            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...
462
463
464
465
466
467
468
469
470
            
            ;#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 = ''
afde94a3   Ilyes Choubani   general update
471
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
18e4331f   Ilyes Choubani   general update (f...
472
473
474
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
afde94a3   Ilyes Choubani   general update
475
                    ;/NODATA
18e4331f   Ilyes Choubani   general update (f...
476
477
                    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...
478
                    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...
479
480
481
482
483
484
485
486
487
488
489
                  
                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...
490
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
491
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
492
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
493
494
                            cgoplot,1/xx,((*!dustem_data.polext).values)[idx_spec]/yy,color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                            cgerrplot,1/((*!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...
495
496
497
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
498
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
499
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
500
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2. 
afde94a3   Ilyes Choubani   general update
501
502
                            cgoplot,1/xx,((*!dustem_data.polext).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,1/((*!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...
503
504
505
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
506
                    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...
507
508
509
                        
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
510
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
18e4331f   Ilyes Choubani   general update (f...
511
512
513
514
515
516
517
518
519
520
521
                        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
afde94a3   Ilyes Choubani   general update
522
                            cgoplot,1/st.polext.wav,((st.polext.(1))[i,*]+(st.polext.(2))[i,*])*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
18e4331f   Ilyes Choubani   general update (f...
523
524
525
526
527
528
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
529
                            If isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
530
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
afde94a3   Ilyes Choubani   general update
531
                                    cgoplot,1/st.polext.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
3c479f24   Ilyes Choubani   Allowing to fix p...
532
533
                                ENDIF 
                            endif
18e4331f   Ilyes Choubani   general update (f...
534
535
536
537
538
539
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
67bd858a   Ilyes Choubani   Replication of th...
540
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
541
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
542
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
543
544
545
546
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
547
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
548
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
549
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
550
551
552
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
afde94a3   Ilyes Choubani   general update
553
                        cgoplot,1/st.polext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
5f04fa07   Ilyes Choubani   general update
554
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
18e4331f   Ilyes Choubani   general update (f...
555
556
557
558
559
560
561
562
                                        
                                
                    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)
afde94a3   Ilyes Choubani   general update
563
                            cgplot,1/((*!dustem_data.polext).wav)(idx_spec),((*!dustem_data.polext).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=8,syms=0.8,ytickformat='dstmwrp_exp'                
18e4331f   Ilyes Choubani   general update (f...
564
565
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
566
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
567
                            cgerrplot,1/((*!dustem_data.polext).wav)(idx_spec),((*!dustem_data.polext).values)(idx_spec)-rms,((*!dustem_data.polext).values)(idx_spec)+rms,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
568
569
570
571
572
573

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
afde94a3   Ilyes Choubani   general update
574
575
                            if ct_spec ne 0 then cgoplot,1/((*!dustem_data.polext).wav)(idx_filt),((*!dustem_data.polext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,1/((*!dustem_data.polext).wav)(idx_filt),((*!dustem_data.polext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
18e4331f   Ilyes Choubani   general update (f...
576
577
578
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
579
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
afde94a3   Ilyes Choubani   general update
580
                            cgerrplot,1/((*!dustem_data.polext).wav)(idx_filt),((*!dustem_data.polext).values)(idx_filt)-rms,((*!dustem_data.polext).values)(idx_filt)+rms,color='Dodger Blue'
18e4331f   Ilyes Choubani   general update (f...
581
582
583
584
585
586
587
                            
                        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...
588
                        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...
589
590
                         
                        ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
591
592
                        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:...
593
                        ;Locating the hidden spectrum and filter data points                                        
67bd858a   Ilyes Choubani   Replication of th...
594
595
                        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:...
596
                        
1355825c   Ilyes Choubani   General update
597
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
598
599
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
600
601
602
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
afde94a3   Ilyes Choubani   general update
603
                                cgoplot,1/(((*!dustem_show.polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
604
605
                                
                                ;Plotting of hidden spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
606
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
607
                                cgerrplot,1/(((*!dustem_show.polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
608
609
                            endif                                            
                            
1355825c   Ilyes Choubani   General update
610
                            if ct_filt_hdn ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
611
                            ;Plotting of hidden filter data points 
afde94a3   Ilyes Choubani   general update
612
                                cgoplot,1/(((*!dustem_show.polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8                                           
18e4331f   Ilyes Choubani   general update (f...
613
614
                                
                                ;Plotting of hidden filter error point
67bd858a   Ilyes Choubani   Replication of th...
615
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
616
                                cgerrplot,1/(((*!dustem_show.polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*!dustem_show.polext).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
67bd858a   Ilyes Choubani   Replication of th...
632
        
b5314324   Ilyes Choubani   updating the plot...
633
634
        end
        
67bd858a   Ilyes Choubani   Replication of th...
635
636
637
638
639
        '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
640
641
642
643
644
            
            ;#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...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
                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
666
                        
67bd858a   Ilyes Choubani   Replication of th...
667
668
669
670
671
672
673
                        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
674
                        
67bd858a   Ilyes Choubani   Replication of th...
675
676
677
678
679
680
681
682
                        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
683
                        
67bd858a   Ilyes Choubani   Replication of th...
684
                    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.
afde94a3   Ilyes Choubani   general update
685
686
687
688
                        vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
                        vectw=10^vectw[1:*]
                        vectw=[wavs,vectw]
                        vectx=vectw*0+1
67bd858a   Ilyes Choubani   Replication of th...
689
690
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
691
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
692
693
694
695
696
697
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
1355825c   Ilyes Choubani   General update
698
                        
67bd858a   Ilyes Choubani   Replication of th...
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
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
                    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
842
                            
5f04fa07   Ilyes Choubani   general update
843
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
844
                            
5f04fa07   Ilyes Choubani   general update
845
846
847
848
849
850
851
                            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
852
853
854
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
855
                         
1355825c   Ilyes Choubani   General update
856
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
857
                            
3c479f24   Ilyes Choubani   Allowing to fix p...
858
859
860
861
862
863
864
865
866
                            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
867
                            
1355825c   Ilyes Choubani   General update
868
869
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
870
871
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
872
873
874
875
876
877
                        
                         ;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
878
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
879
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
880
881
882
883
884
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
885
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
886
887
888
889
890
                             cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
891
                         cgoplot,st.polsed.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs               
1355825c   Ilyes Choubani   General update
892
893
894
895
896
897
898
899
900
                                
                    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...
901
                        
1355825c   Ilyes Choubani   General update
902
903
904
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
5f04fa07   Ilyes Choubani   general update
905
                            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
906
907
908
909
910
911
912
913
914
915
                            
                            ;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
916
917
                            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
918
919
920
921
922
923
924
925
926
927
                            
                            
                            ;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
928
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
929
930
931
932
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
abebbdf3   Ilyes Choubani   General update: A...
933
                        match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
1355825c   Ilyes Choubani   General update
934
935
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
936
937
938
                        ;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
939
940
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
941
942
943
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
5f04fa07   Ilyes Choubani   general update
944
                                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
945
946
947
948
949
950
951
952
953
954
                                
                                ;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
955
                                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
956
957
958
959
960
961
962
963
964
965
966
967
968
                                ;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...
969
970
971
        
        end
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
972
        'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
67bd858a   Ilyes Choubani   Replication of th...
973
974
975
976
        
        
            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...
977
            
18e4331f   Ilyes Choubani   general update (f...
978
979
980
981
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
67bd858a   Ilyes Choubani   Replication of th...
982
983
                    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...
984
985
986
987
988
989
990
991
                 
            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...
992
993
994
995
996
997
998
                        
                        ;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...
999
                        FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1000
                            
afde94a3   Ilyes Choubani   general update
1001
                            testneq = where(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]) ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
1002
1003
                            
                            if countneq ne 0 then begin 
afde94a3   Ilyes Choubani   general update
1004
                                vecfin = ((st.polext.(1))[i,*]+(st.polext.(2))[i,*])*0.0
5f04fa07   Ilyes Choubani   general update
1005
                                
afde94a3   Ilyes Choubani   general update
1006
                                vecfin[testneq] = ((((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))[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]
67bd858a   Ilyes Choubani   Replication of th...
1007
                                 
afde94a3   Ilyes Choubani   general update
1008
                                cgoplot,1/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]
67bd858a   Ilyes Choubani   Replication of th...
1009
                            endif   
18e4331f   Ilyes Choubani   general update (f...
1010
                        ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
1011
1012
1013
                       
                        ;Plotting of the plugins. 
                         
18e4331f   Ilyes Choubani   general update (f...
1014
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1015
1016
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
1017
1018
1019
1020
                            
                                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]        
afde94a3   Ilyes Choubani   general update
1021
                                    cgoplot,1/st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
1022
                                
3c479f24   Ilyes Choubani   Allowing to fix p...
1023
                                ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1024
1025
                            endif
                            
18e4331f   Ilyes Choubani   general update (f...
1026
                        endfor
67bd858a   Ilyes Choubani   Replication of th...
1027
1028
1029
                       
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
18e4331f   Ilyes Choubani   general update (f...
1030
1031
1032
1033
1034
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
67bd858a   Ilyes Choubani   Replication of th...
1035
                             xx=((*!dustem_data.fpolext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1036
                             yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
1037
                             cgoplot,1/xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
1038
1039
1040
1041
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
1042
                             xx=((*!dustem_data.fpolext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1043
                             yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
1044
                             cgoplot,1/xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
1045
1046
1047
1048
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
1049
                         cgoplot,1/st.polext.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
67bd858a   Ilyes Choubani   Replication of th...
1050
                                        
18e4331f   Ilyes Choubani   general update (f...
1051
1052
1053
1054
1055
1056
1057
1058
1059
                                
                    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...
1060
                        
18e4331f   Ilyes Choubani   general update (f...
1061
1062
1063
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
afde94a3   Ilyes Choubani   general update
1064
                            cgplot,1/((*!dustem_data.fpolext).wav)(idx_spec),((*!dustem_data.fpolext).values)(idx_spec)*100,/xlog,/ylog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[1.00E-04,50.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
18e4331f   Ilyes Choubani   general update (f...
1065
1066
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
1067
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
1068
                            cgerrplot,1/((*!dustem_data.fpolext).wav)(idx_spec),(((*!dustem_data.fpolext).values)(idx_spec)-rms)*100,(((*!dustem_data.fpolext).values)(idx_spec)+rms)*100,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
1069
1070
1071
1072
1073
1074

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
afde94a3   Ilyes Choubani   general update
1075
1076
                            if ct_spec ne 0 then cgoplot,1/((*!dustem_data.fpolext).wav)(idx_filt),((*!dustem_data.fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[1.00E-04,50.00],/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
                                cgplot,1/((*!dustem_data.fpolext).wav)(idx_filt),((*!dustem_data.fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[1.00E-04,50.00],/xlog,/ylog;,ytickformat='dstmwrp_exp'
18e4331f   Ilyes Choubani   general update (f...
1077
1078
1079
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
1080
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
afde94a3   Ilyes Choubani   general update
1081
                            cgerrplot,1/((*!dustem_data.fpolext).wav)(idx_filt),(((*!dustem_data.fpolext).values)(idx_filt)-rms)*100,(((*!dustem_data.fpolext).values)(idx_filt)+rms)*100,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
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
                            
                        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
d7a2d8eb   Ilyes Choubani   typo
1174
                                    cgoplot,st.polsed.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]   
67bd858a   Ilyes Choubani   Replication of th...
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
                                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
afde94a3   Ilyes Choubani   general update
1315
                            testneq = where((((st.polext.(1))[i,*]+(st.polext.(2))[i,*])) ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
1316
                            if countneq ne 0 then begin
afde94a3   Ilyes Choubani   general update
1317
                                vecfin = (((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))*0.0
67bd858a   Ilyes Choubani   Replication of th...
1318
1319
1320
                                
                                ;Not sure about the multiplicative factor here
                                
afde94a3   Ilyes Choubani   general update
1321
                                vecfin[testneq] = ((((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'. 
67bd858a   Ilyes Choubani   Replication of th...
1322
                                ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
afde94a3   Ilyes Choubani   general update
1323
                                polar_ippsi2iqu,(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
67bd858a   Ilyes Choubani   Replication of th...
1324
1325
                                
                                ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
afde94a3   Ilyes Choubani   general update
1326
                                cgoplot,1/st.polext.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
67bd858a   Ilyes Choubani   Replication of th...
1327
1328
1329
1330
1331
1332
1333
1334
1335
                            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
afde94a3   Ilyes Choubani   general update
1336
                                    cgoplot_mlog,1/st.polext.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]   
67bd858a   Ilyes Choubani   Replication of th...
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
                                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
afde94a3   Ilyes Choubani   general update
1514
1515
1516
1517
1518
                        ;stitching an array of 1000 more points (up to 1E7) after the end of the dustem wavelength array (dim=800 elements)
                        vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
                        vectw=10^vectw[1:*]
                        vectw=[wavs,vectw]
                        vectx=vectw*0+1
67bd858a   Ilyes Choubani   Replication of th...
1519
1520
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1521
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
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
                        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
67bd858a   Ilyes Choubani   Replication of th...
1712
                                
afde94a3   Ilyes Choubani   general update
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
                                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
;                                 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.     
67bd858a   Ilyes Choubani   Replication of th...
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
                            
                            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
e0d00de0   Ilyes Choubani   removing stops
1808
                                
67bd858a   Ilyes Choubani   Replication of th...
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
                                
                                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
                                    
67bd858a   Ilyes Choubani   Replication of th...
1833
                                        
afde94a3   Ilyes Choubani   general update
1834
                                endif else begin 
67bd858a   Ilyes Choubani   Replication of th...
1835
                                    
afde94a3   Ilyes Choubani   general update
1836
                                    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)'
67bd858a   Ilyes Choubani   Replication of th...
1837
                                        
afde94a3   Ilyes Choubani   general update
1838
1839
1840
1841
1842
1843
                                    
                                    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)'
                                    
                                    
                                    
                                endelse   
67bd858a   Ilyes Choubani   Replication of th...
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
                            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
afde94a3   Ilyes Choubani   general update
1930
1931
1932
1933
                        vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
                        vectw=10^vectw[1:*]
                        vectw=[wavs,vectw]
                        vectx=vectw*0+1
67bd858a   Ilyes Choubani   Replication of th...
1934
1935
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1936
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
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
2123
2124
2125
2126
                        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
44824100   Ilyes Choubani   fixed missing Sto...
2127
2128
2129
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
                                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

;                                 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
;                             
67bd858a   Ilyes Choubani   Replication of th...
2163
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
2164
                        
67bd858a   Ilyes Choubani   Replication of th...
2165
                        endif 
18e4331f   Ilyes Choubani   general update (f...
2166
                        
67bd858a   Ilyes Choubani   Replication of th...
2167
                        if keyword_set(negative_only) then begin
18e4331f   Ilyes Choubani   general update (f...
2168
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
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
                            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...
2221
                            
67bd858a   Ilyes Choubani   Replication of th...
2222
                            endif else begin
44824100   Ilyes Choubani   fixed missing Sto...
2223
2224
                                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

18e4331f   Ilyes Choubani   general update (f...
2225
                                
44824100   Ilyes Choubani   fixed missing Sto...
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
;                                 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
;                                     
;                             
;                                 endif
67bd858a   Ilyes Choubani   Replication of th...
2251
2252
2253
2254
                            ;stop
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2255
2256
2257
2258
2259
2260
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2261
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2262
            
67bd858a   Ilyes Choubani   Replication of th...
2263
2264
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2265
2266
2267
        
        end
        
afde94a3   Ilyes Choubani   general update
2268
        'QEXT': begin   ;Correct this like you corrected extinction...
67bd858a   Ilyes Choubani   Replication of th...
2269
2270
2271
        
            varvar=where((*!dustem_data.qext).values GT 0, testpstv)
            varvar=where((*!dustem_data.qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2272
            
18e4331f   Ilyes Choubani   general update (f...
2273
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2274
2275
            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...
2276
2277
2278
2279
2280
            ;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...
2281
            match2,((*!dustem_data.qext).wav),((*!dustem_show.qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2282
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2283
            
5f04fa07   Ilyes Choubani   general update
2284
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
            
            ;#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...
2299
2300
                    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...
2301
                    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...
2302
2303
2304
2305
2306
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2307
                
bc224f3e   Ilyes Choubani   Update of plottin...
2308
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2309
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2310
2311
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
c8368c6e   Ilyes Choubani   updating plotting...
2312
2313
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
18e4331f   Ilyes Choubani   general update (f...
2314
                        IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2315
                            xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2316
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2317
                            rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2318
2319
;                             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...
2320
2321
                            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...
2322
2323
2324
                        
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2325
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2326
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2327
                            xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2328
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2329
                            rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2. 
18e4331f   Ilyes Choubani   general update (f...
2330
2331
;                             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...
2332
2333
                            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...
2334
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2335
      
bc224f3e   Ilyes Choubani   Update of plottin...
2336
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2337
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2338
                        ;stop
afde94a3   Ilyes Choubani   general update
2339
2340
2341
2342
                        vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
                        vectw=10^vectw[1:*]
                        vectw=[wavs,vectw]
                        vectx=vectw*0+1
bc224f3e   Ilyes Choubani   Update of plottin...
2343
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
2344
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2345
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
bc224f3e   Ilyes Choubani   Update of plottin...
2346
2347
2348
2349
2350
2351
                        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...
2352
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2353
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
5f04fa07   Ilyes Choubani   general update
2354
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2355
2356
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2357
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
2358
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
2359
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2360
                                    
67bd858a   Ilyes Choubani   Replication of th...
2361
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
5f04fa07   Ilyes Choubani   general update
2362
2363
                                    ;stop
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2364
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2365
                                        ;stop
67bd858a   Ilyes Choubani   Replication of th...
2366
                                        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
2367
2368
                                        ;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...
2369
                                        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
2370
                                        
afde94a3   Ilyes Choubani   general update
2371
                                        stop
5f04fa07   Ilyes Choubani   general update
2372
                                        ;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...
2373
                                        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
2374
2375
2376
                                        ;stop
                                    endif
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2377
2378
2379
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2380
2381
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2382
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2383
2384
                                         
                                            ;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...
2385
                                            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...
2386
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2387
2388
2389
2390
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2391
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2392
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2393
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2394
                                    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...
2395
2396
2397
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2398
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2399
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2400
2401
2402
2403
                                    ;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...
2404
                                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...
2405
2406
2407
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2408
                        
18e4331f   Ilyes Choubani   general update (f...
2409
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2410
                        
5f04fa07   Ilyes Choubani   general update
2411
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2412
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2413
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2414
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2415
                            
5f04fa07   Ilyes Choubani   general update
2416
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2417
2418
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2419
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
5f04fa07   Ilyes Choubani   general update
2420
2421
                                    ;stop
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2422
                                        vecfin = st.polext.(i+1)*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2423
                                        ;stop
67bd858a   Ilyes Choubani   Replication of th...
2424
                                        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
2425
                                        ;stop    
67bd858a   Ilyes Choubani   Replication of th...
2426
                                        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
2427
2428
                                        ;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...
2429
                                        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
2430
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2431
2432
2433
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2434
2435
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2436
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2437
2438
     
                                            ;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...
2439
                                            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...
2440
2441
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2442
2443
2444
2445
                                    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...
2446
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2447
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2448
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2449
                                    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...
2450
2451
2452
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2453
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2454
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2455
2456
2457
2458
                                    ;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...
2459
                                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...
2460
2461
2462
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2463
                        
18e4331f   Ilyes Choubani   general update (f...
2464
2465
2466
2467
2468
2469
                        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...
2470
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{Q_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2471
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2472
                            
2df3360b   Ilyes Choubani   Correcting error:...
2473
2474
2475
2476
                        ;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...
2477
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2478
2479
2480
2481
                            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...
2482
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2483
                        
c8368c6e   Ilyes Choubani   updating plotting...
2484
                        
18e4331f   Ilyes Choubani   general update (f...
2485
                        if keyword_set(positive_only) then begin
afde94a3   Ilyes Choubani   general update
2486
                            
2df3360b   Ilyes Choubani   Correcting error:...
2487
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2488
                            ;stop
9cb38725   Ilyes Choubani   Fixed tests relat...
2489
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2490
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2491
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2492
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2493
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2494
2495
2496
                                        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...
2497
2498
2499
2500
2501
2502
2503
2504
                                        
                                        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...
2505
2506
2507
                                        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...
2508
2509
2510
2511
2512
                                        
                                        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...
2513
                                    
18e4331f   Ilyes Choubani   general update (f...
2514
2515
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2516
2517
                                
                                
18e4331f   Ilyes Choubani   general update (f...
2518
2519
                                if ct_spec ne 0 then begin
                                
67bd858a   Ilyes Choubani   Replication of th...
2520
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2521
                                    ;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)'
afde94a3   Ilyes Choubani   general update
2522
                                
67bd858a   Ilyes Choubani   Replication of th...
2523
                                    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)'
afde94a3   Ilyes Choubani   general update
2524
                                    stop
67bd858a   Ilyes Choubani   Replication of th...
2525
                                    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)'     
afde94a3   Ilyes Choubani   general update
2526
                                    stop 
18e4331f   Ilyes Choubani   general update (f...
2527
2528
2529
2530
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2531
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2532
                                   ; 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...
2533
2534
                                    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...
2535
2536
2537
2538
                                        
                                endif
                            endif else begin
                            
9cb38725   Ilyes Choubani   Fixed tests relat...
2539
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2540
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2541
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2542
2543
2544
                                        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...
2545
2546
2547
                                        
                                        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...
2548
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2549
2550
2551
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2552
                                    
67bd858a   Ilyes Choubani   Replication of th...
2553
2554
2555
                                        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...
2556
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2557
2558
                                        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...
2559
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2560
2561
2562
                                    endif
                                    
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2563
                                        
67bd858a   Ilyes Choubani   Replication of th...
2564
                                        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...
2565
2566
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
2567
                                        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...
2568
                                            
18e4331f   Ilyes Choubani   general update (f...
2569
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2570
2571
                                    endif
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
18e4331f   Ilyes Choubani   general update (f...
2572
2573
                            
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
2574
                        
18e4331f   Ilyes Choubani   general update (f...
2575
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2576
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2577
                        
18e4331f   Ilyes Choubani   general update (f...
2578
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
2579
                            
2df3360b   Ilyes Choubani   Correcting error:...
2580
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2581
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2582
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2583
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2584
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2585
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2586
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2587
2588
2589
                                         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...
2590
2591
2592
                                         
                                         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...
2593
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2594
2595
2596
2597
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2598
2599
2600
                                         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...
2601
2602
2603
2604
2605
2606
                                         
                                         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...
2607
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
2608

18e4331f   Ilyes Choubani   general update (f...
2609
2610
                                 if ct_spec ne 0 then begin
                                 
67bd858a   Ilyes Choubani   Replication of th...
2611
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2612
                                     ;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...
2613
                                    ; 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...
2614
                                         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)'
afde94a3   Ilyes Choubani   general update
2615
                                         stop
9cb38725   Ilyes Choubani   Fixed tests relat...
2616
                                     ;endelse;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2617
                                     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     
afde94a3   Ilyes Choubani   general update
2618
                                      stop                                        
18e4331f   Ilyes Choubani   general update (f...
2619
2620
2621
2622
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2623
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2624
                                    ; 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...
2625
                                     ;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...
2626
                                         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...
2627
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2628
                                     
67bd858a   Ilyes Choubani   Replication of th...
2629
                                     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...
2630
2631
                                         
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
2632
                            
c8368c6e   Ilyes Choubani   updating plotting...
2633
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
2634
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2635
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2636
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2637
                                    if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2638
2639
2640
                                        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...
2641
2642
2643
                                        
                                        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...
2644
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2645
2646
2647
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2648
                                    
67bd858a   Ilyes Choubani   Replication of th...
2649
2650
2651
                                        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...
2652
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2653
2654
                                        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...
2655
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2656
2657
2658
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2659
                                        
67bd858a   Ilyes Choubani   Replication of th...
2660
                                        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...
2661
2662
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
2663
                                        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...
2664
                                            
18e4331f   Ilyes Choubani   general update (f...
2665
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2666
2667
2668
                                    endif
                                        
                                endif    
18e4331f   Ilyes Choubani   general update (f...
2669
                            endelse
5f04fa07   Ilyes Choubani   general update
2670
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2671
2672
2673
2674
2675
2676
2677
2678
2679
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2680
            endelse ; 
18e4331f   Ilyes Choubani   general update (f...
2681
        
67bd858a   Ilyes Choubani   Replication of th...
2682
        end
18e4331f   Ilyes Choubani   general update (f...
2683
        
67bd858a   Ilyes Choubani   Replication of th...
2684
2685
2686
2687
2688
2689
        '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...
2690
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2691
2692
            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...
2693
2694
2695
2696
2697
            ;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...
2698
            match2,((*!dustem_data.uext).wav),((*!dustem_show.uext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2699
2700
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
5f04fa07   Ilyes Choubani   general update
2701
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2702
            
18e4331f   Ilyes Choubani   general update (f...
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
            ;#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...
2718
                    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...
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
                  
                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...
2732
                            xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2733
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2734
2735
2736
2737
2738
                            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...
2739
2740
2741
2742
2743
                        
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2744
                            xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2745
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2746
2747
2748
2749
2750
                            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...
2751
2752
2753
2754
2755
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
afde94a3   Ilyes Choubani   general update
2756
2757
2758
2759
                        vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
                        vectw=10^vectw[1:*]
                        vectw=[wavs,vectw]
                        vectx=vectw*0+1
18e4331f   Ilyes Choubani   general update (f...
2760
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
2761
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2762
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
2763
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
2764
2765
2766
2767
                    
                    endelse
                    
                
67bd858a   Ilyes Choubani   Replication of th...
2768
                endif else begin ; normal plot - STOPPED HERE FOR QSED
18e4331f   Ilyes Choubani   general update (f...
2769
2770
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
67bd858a   Ilyes Choubani   Replication of th...
2771
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2772
2773
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2774
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
2775
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
2776
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2777
                                    
67bd858a   Ilyes Choubani   Replication of th...
2778
2779
                                    testneq = where(st.polext.(i+1) ne 0,countneq)
                                    ;stop
5f04fa07   Ilyes Choubani   general update
2780
                                    if countneq ne 0 then begin 
67bd858a   Ilyes Choubani   Replication of th...
2781
2782
2783
2784
2785
2786
                                        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
2787
                                        
67bd858a   Ilyes Choubani   Replication of th...
2788
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2789
                                        ;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...
2790
2791
2792
                                        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
2793
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2794
                                ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
2795
                                
18e4331f   Ilyes Choubani   general update (f...
2796
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2797
2798
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2799
2800
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                         
3c479f24   Ilyes Choubani   Allowing to fix p...
2801
                                            ;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...
2802
                                            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...
2803
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2804
                                    ENDIF
18e4331f   Ilyes Choubani   general update (f...
2805
2806
2807
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2808
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2809
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2810
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2811
                                    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...
2812
2813
2814
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2815
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2816
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2817
2818
2819
2820
                                    ;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...
2821
                                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...
2822
2823
2824
2825
2826
2827
                            
                            endif
                                    
                        
                        endif
                        
67bd858a   Ilyes Choubani   Replication of th...
2828
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2829
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2830
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2831
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2832
                            
67bd858a   Ilyes Choubani   Replication of th...
2833
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2834
2835
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2836
2837
2838
2839
2840
2841
2842
2843
2844
                                    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
2845
                                        ;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...
2846
2847
                                        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...
2848
2849
                                ENDFOR
                                ;Plotting of the plugins
67bd858a   Ilyes Choubani   Replication of th...
2850
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2851
2852
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2853
2854
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
     
3c479f24   Ilyes Choubani   Allowing to fix p...
2855
                                            ;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...
2856
                                            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...
2857
                                        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2858
                                        
18e4331f   Ilyes Choubani   general update (f...
2859
                                    ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2860
                                endfor
18e4331f   Ilyes Choubani   general update (f...
2861
2862
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2863
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2864
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2865
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
2866
                                    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...
2867
2868
2869
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2870
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2871
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2872
2873
2874
                                    ;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...
2875
                                ;Plotting of the total dust emission spectrum
67bd858a   Ilyes Choubani   Replication of th...
2876
                                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...
2877
                            
18e4331f   Ilyes Choubani   general update (f...
2878
2879
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2880
2881
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
2882
2883
                                                   
                      ;stop             
67bd858a   Ilyes Choubani   Replication of th...
2884
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
bc224f3e   Ilyes Choubani   Update of plottin...
2885
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2886
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2887
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{U_ext}(\nu)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2888
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
67bd858a   Ilyes Choubani   Replication of th...
2889
                            
2df3360b   Ilyes Choubani   Correcting error:...
2890
2891
                        ;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...
2892
2893
                        ;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...
2894
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2895
2896
2897
2898
                            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...
2899
                        endif
67bd858a   Ilyes Choubani   Replication of th...
2900
                        
18e4331f   Ilyes Choubani   general update (f...
2901
2902
2903
                        
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
2904
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2905
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2906
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2907
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2908
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2909
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2910
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2911
2912
2913
                                        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...
2914
                                        
67bd858a   Ilyes Choubani   Replication of th...
2915
                                        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...
2916
                                        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...
2917
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2918
2919
2920
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2921
2922
2923
2924
                                    
                                        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...
2925
                                        
67bd858a   Ilyes Choubani   Replication of th...
2926
                                        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...
2927
2928
2929
                                        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...
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
                                    
                                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:...
2952
                            endif else begin
67bd858a   Ilyes Choubani   Replication of th...
2953
                            
9cb38725   Ilyes Choubani   Fixed tests relat...
2954
                                if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2955
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2956
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2957
2958
2959
                                        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...
2960
2961
2962
                                        
                                        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...
2963
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2964
2965
2966
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2967
                                    
67bd858a   Ilyes Choubani   Replication of th...
2968
2969
2970
                                        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...
2971
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2972
2973
2974
2975
                                        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...
2976
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2977
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2978
2979
                                        
                                        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...
2980
                                            
18e4331f   Ilyes Choubani   general update (f...
2981
                                        
67bd858a   Ilyes Choubani   Replication of th...
2982
                                        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...
2983
                                            
18e4331f   Ilyes Choubani   general update (f...
2984
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2985
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
2986
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
18e4331f   Ilyes Choubani   general update (f...
2987
                            
67bd858a   Ilyes Choubani   Replication of th...
2988
                            endelse                           
18e4331f   Ilyes Choubani   general update (f...
2989
2990
2991
                        
                        endif 
                        
67bd858a   Ilyes Choubani   Replication of th...
2992
                        
18e4331f   Ilyes Choubani   general update (f...
2993
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2994
                            
2df3360b   Ilyes Choubani   Correcting error:...
2995
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2996
                                 
67bd858a   Ilyes Choubani   Replication of th...
2997
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2998
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2999
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
3000
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
3001
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
3002
3003
3004
                                         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...
3005
                                         
67bd858a   Ilyes Choubani   Replication of th...
3006
                                         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...
3007
                                         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...
3008
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
3009
                                     endif 
18e4331f   Ilyes Choubani   general update (f...
3010
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
3011
3012
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
3013
3014
3015
                                         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...
3016
                                         
67bd858a   Ilyes Choubani   Replication of th...
3017
                                         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...
3018
3019
3020
                                         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...
3021
3022
                                
                                 endif
18e4331f   Ilyes Choubani   general update (f...
3023

67bd858a   Ilyes Choubani   Replication of th...
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
                                 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...
3045
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
3046
                            
2df3360b   Ilyes Choubani   Correcting error:...
3047
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
3048
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
3049
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
3050
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
3051
                                    if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
3052
3053
3054
                                        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...
3055
3056
3057
                                        
                                        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...
3058
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3059
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
3060
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3061
3062
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
3063
3064
3065
                                        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...
3066
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
3067
3068
3069
3070
                                        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...
3071
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3072
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
3073
                                        
67bd858a   Ilyes Choubani   Replication of th...
3074
                                        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...
3075
3076
                                            
                                        
67bd858a   Ilyes Choubani   Replication of th...
3077
                                        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...
3078
                                            
18e4331f   Ilyes Choubani   general update (f...
3079
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
3080
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
3081
3082
                                        
                                endif    
2df3360b   Ilyes Choubani   Correcting error:...
3083
                            endelse
5f04fa07   Ilyes Choubani   general update
3084
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
3085
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
3086
3087
3088
3089
                        
                    
                    endelse 
                
bc224f3e   Ilyes Choubani   Update of plottin...
3090
3091
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
3092
            endelse 
b5314324   Ilyes Choubani   updating the plot...
3093
3094
        
        end
5f04fa07   Ilyes Choubani   general update
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
        
        '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 - ...
3115
                    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
3116
3117
3118
3119
3120
                      
                        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...
3121
                        yypos = 0.85 - k*0.09 
5f04fa07   Ilyes Choubani   general update
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
                        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 - ...
3141
3142
3143
3144
3145
3146
3147
3148
3149
                    
                    
                    
                    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...
3150
                        yypos = 0.85 - k*0.09 
fcb6eade   Ilyes Choubani   general update - ...
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
                        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
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
                
                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 - ...
3190
                    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
3191
3192
3193
3194
3195
                      
                        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...
3196
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
                        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 - ...
3211
3212
3213
3214
3215
3216
3217
3218
                  
                  
                  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...
3219
                      yypos = 0.85 - k*0.09
fcb6eade   Ilyes Choubani   general update - ...
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
                      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
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
                
                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...
3262
3263
                        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
3264
3265
3266
                        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...
3267
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
                        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...
3301
3302
                        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
3303
3304
3305
3306
                        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...
3307
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
                        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
3331
3332
        end
        
b5314324   Ilyes Choubani   updating the plot...
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
    
    endcase


endif











 


 
  












END