Blame view

src/idl/dustemcgwin_dataset.pro 126 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
22
clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
scopes=tag_names((*!dustem_scope))
b5314324   Ilyes Choubani   updating the plot...
23
24
25
26
27
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...
28

5f04fa07   Ilyes Choubani   general update
29
30
31
32

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


5f04fa07   Ilyes Choubani   general update
35
;############################################################################################
b5314324   Ilyes Choubani   updating the plot...
36

b5314324   Ilyes Choubani   updating the plot...
37

abebbdf3   Ilyes Choubani   General update: A...
38
39
40
41
42
43
44
;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...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
if keyword_set(dataset) then begin
;!run_pol is implied for QSED/USED/POLSED etc...
    Case strupcase(dataset) of 
    
        'SED': begin
            
            idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
5f04fa07   Ilyes Choubani   general update
65
66
67
68
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
                        
b5314324   Ilyes Choubani   updating the plot...
69
70
                    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
71
                    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...
72
                  
5f04fa07   Ilyes Choubani   general update
73
74
                ;endelse  
                endif
b5314324   Ilyes Choubani   updating the plot...
75
            
5f04fa07   Ilyes Choubani   general update
76
77
            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...
78
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
79
                    
b5314324   Ilyes Choubani   updating the plot...
80
81
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
b5314324   Ilyes Choubani   updating the plot...
82
83
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
84
                            yy=dustem_interp[idx_spec]
b5314324   Ilyes Choubani   updating the plot...
85
86
87
                            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...
88
                        ENDIF
b5314324   Ilyes Choubani   updating the plot...
89
                        
c8368c6e   Ilyes Choubani   updating plotting...
90
91
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
92
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
93
94
                            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...
95
                            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...
96
97
98
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
99
100
                    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...
101
                        
5f04fa07   Ilyes Choubani   general update
102
103
                    if not keyword_set(refresh) then begin 
                        ;stop   
b5314324   Ilyes Choubani   updating the plot...
104
                        xtit=textoidl('\lambda (\mum)')
fcb6eade   Ilyes Choubani   general update - ...
105
106
107
108
109
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
b5314324   Ilyes Choubani   updating the plot...
110
111
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
5f04fa07   Ilyes Choubani   general update
112
113
                    ;endelse
                    endif
b5314324   Ilyes Choubani   updating the plot...
114
115
                    
                
5f04fa07   Ilyes Choubani   general update
116
117
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
b5314324   Ilyes Choubani   updating the plot...
118
119
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
b5314324   Ilyes Choubani   updating the plot...
120
121
122
123
124
                        ;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...
125
                                                
b5314324   Ilyes Choubani   updating the plot...
126
127
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
18e4331f   Ilyes Choubani   general update (f...
128
129
130
                            IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN begin
                                cgoplot,st.sed.wav,((*(*!dustem_plugin).(i))[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                            ENDIF
b5314324   Ilyes Choubani   updating the plot...
131
                        endfor
c8368c6e   Ilyes Choubani   updating plotting...
132
                                                
b5314324   Ilyes Choubani   updating the plot...
133
                        ;PLotting of the interpolates corresponding to spectrum and filter points
c8368c6e   Ilyes Choubani   updating plotting...
134
                           
b5314324   Ilyes Choubani   updating the plot...
135
136
137
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
138
                            yy=dustem_interp[idx_spec]
abebbdf3   Ilyes Choubani   General update: A...
139
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
b5314324   Ilyes Choubani   updating the plot...
140
141
                        ENDIF
                        
c8368c6e   Ilyes Choubani   updating plotting...
142
143
144
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
145
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
146
147
148
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
b5314324   Ilyes Choubani   updating the plot...
149
                        
c8368c6e   Ilyes Choubani   updating plotting...
150
                        ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
151
                        cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
c8368c6e   Ilyes Choubani   updating plotting...
152
153
154
                         
                                        
                                
5f04fa07   Ilyes Choubani   general update
155
156
157
                    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...
158
159
160
161
                        ;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...
162
                            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...
163
164
165
166
167
168
169
170
                            
                            ;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...
171
                        
b5314324   Ilyes Choubani   updating the plot...
172
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
dfc68a85   Ilyes Choubani   Fixed some plotti...
173
174
                            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...
175
                            
b5314324   Ilyes Choubani   updating the plot...
176
177
178
179
                            
                            ;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...
180
                            
b5314324   Ilyes Choubani   updating the plot...
181
                        endif
c8368c6e   Ilyes Choubani   updating plotting...
182
183
                        
                        
b5314324   Ilyes Choubani   updating the plot...
184
                        ;Plotting of frequency axis
c8368c6e   Ilyes Choubani   updating plotting...
185
186
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
                        
5f04fa07   Ilyes Choubani   general update
187
                        xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
c8368c6e   Ilyes Choubani   updating plotting...
188
                         
b5314324   Ilyes Choubani   updating the plot...
189
                        ;Locating all the hidden data points (spectrum+filter)
abebbdf3   Ilyes Choubani   General update: A...
190
                        match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
b5314324   Ilyes Choubani   updating the plot...
191
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
192
193
194
195
                        ;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...
196
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
197
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
198
199
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
dfc68a85   Ilyes Choubani   Fixed some plotti...
200
                                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...
201
202
203
204
205
                                
                                ;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...
206
                            
18e4331f   Ilyes Choubani   general update (f...
207
                            if ct_filt_hdn then begin
b5314324   Ilyes Choubani   updating the plot...
208
                            ;Plotting of hidden filter data points 
dfc68a85   Ilyes Choubani   Fixed some plotti...
209
                                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...
210
211
212
213
214
215
                                
                                ;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...
216
217
218
219
220
                                                           
                        endif    
                        
                        
                    
5f04fa07   Ilyes Choubani   general update
221
222
                    ;endelse 
                    endif
b5314324   Ilyes Choubani   updating the plot...
223
224
                
                
5f04fa07   Ilyes Choubani   general update
225
226
227
228
                ;endelse 
                endif            
            ;endelse
            endif 
18e4331f   Ilyes Choubani   general update (f...
229
        ;stop    
b5314324   Ilyes Choubani   updating the plot...
230
231
232
233
234
235
236
237
238
239
        end
        
        'EXT': begin
        
        end
        
        'POLEXT': begin
        
        end
        
1355825c   Ilyes Choubani   General update
240
241
        'POLSED': begin ;#NB: There seems to be an issue with the display of the dust species. 'Carbonaceous grains' 's emission exceeds the total emission.
                        ;MABE AN ISSUE WITH HOW 'SPECPOL' refreshes?
5f04fa07   Ilyes Choubani   general update
242
                        
1355825c   Ilyes Choubani   General update
243
                        ;PROCEEDING TO POLFRAC  
b5314324   Ilyes Choubani   updating the plot...
244
        
18e4331f   Ilyes Choubani   general update (f...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
            idx_filt=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
                    cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    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
263
                    xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
264
265
266
267
268
269
270
271
272
273
274
275
                  
                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
                            xx=((*!dustem_data.polsed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
276
                            yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
277
278
279
280
281
282
283
                            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
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
284
                            yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
285
286
287
288
289
290
                            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
                            
                        
5f04fa07   Ilyes Choubani   general update
291
                    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...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
                        
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            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 total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_polsed') THEN begin
                                cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                            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]
5f04fa07   Ilyes Choubani   general update
324
                            yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
325
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
326
327
328
329
330
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
331
                            yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
332
333
334
335
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
5f04fa07   Ilyes Choubani   general update
336
337
                        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
18e4331f   Ilyes Choubani   general update (f...
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
                                        
                                
                    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)')
                        
5f04fa07   Ilyes Choubani   general update
371
                        xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
372
373
                         
                        ;Locating all the hidden data points (spectrum+filter)
abebbdf3   Ilyes Choubani   General update: A...
374
                        match2,((*!dustem_data.polsed).wav),((*!dustem_show.polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
18e4331f   Ilyes Choubani   general update (f...
375
                        idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
376
377
378
379
                        ;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)
                        
1355825c   Ilyes Choubani   General update
380
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
381
382
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
383
384
385
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
5f04fa07   Ilyes Choubani   general update
386
                                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
18e4331f   Ilyes Choubani   general update (f...
387
388
389
390
391
392
                                
                                ;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                                            
                            
1355825c   Ilyes Choubani   General update
393
                            if ct_filt_hdn ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
394
                            ;Plotting of hidden filter data points 
5f04fa07   Ilyes Choubani   general update
395
                                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                                           
18e4331f   Ilyes Choubani   general update (f...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
                                
                                ;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
        
b5314324   Ilyes Choubani   updating the plot...
415
416
        end
        
1355825c   Ilyes Choubani   General update
417
418
419
420
421
422
423
424
425
        'POLFRAC': begin ; YOU NEED TO CODE THIS PART - TOU STILL HAVE'NT FINISHED. 
            idx_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polfrac).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 = ''
5f04fa07   Ilyes Choubani   general update
426
427
                    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
1355825c   Ilyes Choubani   General update
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
                 
            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
                            
5f04fa07   Ilyes Choubani   general update
445
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
446
                            
5f04fa07   Ilyes Choubani   general update
447
448
449
450
451
452
453
                            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
454
455
456
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
457
                         
1355825c   Ilyes Choubani   General update
458
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
459
                            
1355825c   Ilyes Choubani   General update
460
                            IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
5f04fa07   Ilyes Choubani   general update
461
462
463
                                vecfin = st.polsed.em_tot*0.0
                                vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i))[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i))[*,2])^2)[testneq])/((*(*!dustem_plugin).(i))[*,0])[testneq]        
                                cgoplot,st.polsed.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
1355825c   Ilyes Choubani   General update
464
465
466
467
                            
                            ENDIF
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
468
469
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
470
471
472
473
474
475
                        
                         ;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
476
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
477
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
478
479
480
481
482
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
483
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
484
485
486
487
488
                             cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
489
                         cgoplot,st.polsed.wav,dustem_spec*100*(st.sed.em_tot*fact/extra_spec),pos=position,noerase=1,/xlog,/ys,/xs
1355825c   Ilyes Choubani   General update
490
491
492
493
494
495
496
497
498
499
                                        
                                
                    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...
500
                        
1355825c   Ilyes Choubani   General update
501
502
503
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
5f04fa07   Ilyes Choubani   general update
504
                            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
505
506
507
508
509
510
511
512
513
514
                            
                            ;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
515
516
                            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
517
518
519
520
521
522
523
524
525
526
                            
                            
                            ;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
527
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p_{\nu} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
528
529
530
531
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
abebbdf3   Ilyes Choubani   General update: A...
532
                        match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
1355825c   Ilyes Choubani   General update
533
534
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
535
536
537
                        ;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
538
539
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
540
541
542
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
5f04fa07   Ilyes Choubani   general update
543
                                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
544
545
546
547
548
549
550
551
552
553
                                
                                ;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
554
                                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
555
556
557
558
559
560
561
562
563
564
565
566
567
                                ;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...
568
569
570
        
        end
        
18e4331f   Ilyes Choubani   general update (f...
571
572
573
574
575
576
577
578
579
580
581
        '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  
5f04fa07   Ilyes Choubani   general update
582
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
583
584
585
586
587
588
589
590
591
                 
            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
5f04fa07   Ilyes Choubani   general update
592
593
594
595
596
597
598
599
600
601
602
                            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 
18e4331f   Ilyes Choubani   general update (f...
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
                        ENDFOR
                                                                        
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                cgoplot_mlog,st.polsed.wav,0.5*atan((*(*!dustem_plugin).(i))[*,2],(*(*!dustem_plugin).(i))[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]   
                            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]
5f04fa07   Ilyes Choubani   general update
618
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
619
                             cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
620
621
622
623
624
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.psi_em).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
625
                             yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
626
627
628
629
630
                             cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
631
632
                         ;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               
18e4331f   Ilyes Choubani   general update (f...
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
                                
                    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
                        
                        
                        
5f04fa07   Ilyes Choubani   general update
668
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{\nu} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
669
670
671
672
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
abebbdf3   Ilyes Choubani   General update: A...
673
                        match2,((*!dustem_data.psi_em).wav),((*!dustem_show.psi_em).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
18e4331f   Ilyes Choubani   general update (f...
674
675
                        idx_rmv_psi_em=where(show_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
676
677
678
                        ;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)
18e4331f   Ilyes Choubani   general update (f...
679
680
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
                            
                            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
           
           
b5314324   Ilyes Choubani   updating the plot...
725
726
        end
        
18e4331f   Ilyes Choubani   general update (f...
727
        'PSI_EXT': begin 
b5314324   Ilyes Choubani   updating the plot...
728
729
730
        
        end
        
bc224f3e   Ilyes Choubani   Update of plottin...
731
        'QSED': begin ; THE ONE I WILL BE WORKING ON
c8368c6e   Ilyes Choubani   updating plotting...
732
733
734
            
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
2df3360b   Ilyes Choubani   Correcting error:...
735
736
737
738
739
            ;WHAT HAPPENS TO NULL VALUES ? 
            
            varvar=where((*!dustem_data.qsed).values GT 0, testpstv)
            varvar=where((*!dustem_data.qsed).values LT 0, testngtv)
            
18e4331f   Ilyes Choubani   general update (f...
740
            ;stop
c8368c6e   Ilyes Choubani   updating plotting...
741
742
            idx_filt=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM' , ct_spec)
18e4331f   Ilyes Choubani   general update (f...
743
744
745
746
747
            ;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)
abebbdf3   Ilyes Choubani   General update: A...
748
            match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
749
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
750
            
5f04fa07   Ilyes Choubani   general update
751
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
752
753
754
755
756
757
758
759
760
761
762
763
764
765
            
            ;#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...
766
767
                    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
5f04fa07   Ilyes Choubani   general update
768
                    xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
769
770
771
772
773
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
774
                
bc224f3e   Ilyes Choubani   Update of plottin...
775
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
776
                    
bc224f3e   Ilyes Choubani   Update of plottin...
777
778
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
c8368c6e   Ilyes Choubani   updating plotting...
779
780
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
18e4331f   Ilyes Choubani   general update (f...
781
782
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.qsed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
783
                            yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
784
785
786
787
788
789
790
791
                            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
                        
bc224f3e   Ilyes Choubani   Update of plottin...
792
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
793
                            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
794
                            xx=((*!dustem_data.qsed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
795
                            yy=dustem_interp[idx_filt]
bc224f3e   Ilyes Choubani   Update of plottin...
796
                            rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2. 
18e4331f   Ilyes Choubani   general update (f...
797
798
799
;                             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 
bc224f3e   Ilyes Choubani   Update of plottin...
800
801
                            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
c8368c6e   Ilyes Choubani   updating plotting...
802
      
bc224f3e   Ilyes Choubani   Update of plottin...
803
                        
bc224f3e   Ilyes Choubani   Update of plottin...
804
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
805
                        ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
806
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
807
808
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
bc224f3e   Ilyes Choubani   Update of plottin...
809
810
811
812
813
814
                        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...
815
                              
bc224f3e   Ilyes Choubani   Update of plottin...
816
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
5f04fa07   Ilyes Choubani   general update
817
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
818
819
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
820
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
821
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
822
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
                                    
                                    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
18e4331f   Ilyes Choubani   general update (f...
840
841
842
843
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
                                    IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
5f04fa07   Ilyes Choubani   general update
844
                                     
18e4331f   Ilyes Choubani   general update (f...
845
846
847
848
849
850
851
                                        ;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))[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
852
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
853
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
854
                                    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...
855
856
857
858
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
859
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
860
861
862
863
                                    ;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
                                
5f04fa07   Ilyes Choubani   general update
864
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
865
866
867
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
868
                        
18e4331f   Ilyes Choubani   general update (f...
869
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
870
                        
5f04fa07   Ilyes Choubani   general update
871
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
872
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
873
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
874
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
875
                            
5f04fa07   Ilyes Choubani   general update
876
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
877
878
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
879
880
881
882
883
884
885
886
887
888
889
890
                                    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 
18e4331f   Ilyes Choubani   general update (f...
891
892
893
894
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
                                    IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
5f04fa07   Ilyes Choubani   general update
895
 
18e4331f   Ilyes Choubani   general update (f...
896
897
898
899
900
901
902
                                        ;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))[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                    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]
5f04fa07   Ilyes Choubani   general update
903
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
904
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
905
                                    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...
906
907
908
909
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.qsed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
910
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
911
912
913
914
                                    ;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
5f04fa07   Ilyes Choubani   general update
915
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
916
917
918
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
919
                        
18e4331f   Ilyes Choubani   general update (f...
920
921
922
923
924
925
                        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)'
5f04fa07   Ilyes Choubani   general update
926
                        xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
927
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
928
                            
2df3360b   Ilyes Choubani   Correcting error:...
929
930
931
932
                        ;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...
933
934
935
936
937
938
                        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
bc224f3e   Ilyes Choubani   Update of plottin...
939
                        
c8368c6e   Ilyes Choubani   updating plotting...
940
                        
18e4331f   Ilyes Choubani   general update (f...
941
942
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
943
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
944
                            ;stop
9cb38725   Ilyes Choubani   Fixed tests relat...
945
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
946
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
947
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
948
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
                                    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
18e4331f   Ilyes Choubani   general update (f...
969
                                    
18e4331f   Ilyes Choubani   general update (f...
970
971
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
972
973
                                
                                
18e4331f   Ilyes Choubani   general update (f...
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
                                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
                            
9cb38725   Ilyes Choubani   Fixed tests relat...
993
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
994
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
995
996
997
998
999
1000
1001
                                    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
18e4331f   Ilyes Choubani   general update (f...
1002
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1003
1004
1005
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1006
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1007
1008
1009
                                        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.
18e4331f   Ilyes Choubani   general update (f...
1010
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1011
1012
                                        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...
1013
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1014
1015
1016
                                    endif
                                    
                                    if ct_spec_hdn_pstv eq 0 and ct_filt_hdn_pstv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1017
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1018
1019
1020
1021
1022
                                        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)'
                                            
18e4331f   Ilyes Choubani   general update (f...
1023
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1024
1025
                                    endif
                                endif ;add condition here for the plotting of empty plots using the lines above if they work.     
18e4331f   Ilyes Choubani   general update (f...
1026
1027
                            
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
1028
                        
18e4331f   Ilyes Choubani   general update (f...
1029
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
1030
                        
bc224f3e   Ilyes Choubani   Update of plottin...
1031
                        
18e4331f   Ilyes Choubani   general update (f...
1032
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
1033
                            
2df3360b   Ilyes Choubani   Correcting error:...
1034
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1035
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1036
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
1037
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1038
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1039
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1040
1041
1042
1043
1044
1045
1046
                                     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
18e4331f   Ilyes Choubani   general update (f...
1047
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
                                     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
                                
18e4331f   Ilyes Choubani   general update (f...
1061
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
1062

18e4331f   Ilyes Choubani   general update (f...
1063
1064
1065
1066
                                 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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1067
                                    ; 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
18e4331f   Ilyes Choubani   general update (f...
1068
                                         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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1069
1070
                                     ;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     
18e4331f   Ilyes Choubani   general update (f...
1071
1072
1073
1074
1075
1076
1077
                                  
                                 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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1078
                                     ;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
18e4331f   Ilyes Choubani   general update (f...
1079
                                         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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1080
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1081
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1082
                                     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)'
18e4331f   Ilyes Choubani   general update (f...
1083
1084
                                         
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
1085
                            
c8368c6e   Ilyes Choubani   updating plotting...
1086
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
1087
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1088
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1089
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1090
1091
1092
1093
1094
1095
1096
                                    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
18e4331f   Ilyes Choubani   general update (f...
1097
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1098
1099
1100
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1101
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1102
1103
1104
                                        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.
18e4331f   Ilyes Choubani   general update (f...
1105
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1106
1107
                                        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...
1108
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1109
1110
1111
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1112
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1113
1114
1115
1116
1117
                                        if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-((*!dustem_data.qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
18e4331f   Ilyes Choubani   general update (f...
1118
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1119
1120
1121
                                    endif
                                        
                                endif    
18e4331f   Ilyes Choubani   general update (f...
1122
                            endelse
5f04fa07   Ilyes Choubani   general update
1123
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

        
        END
        
        'USED': begin
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
2df3360b   Ilyes Choubani   Correcting error:...
1141
1142
            varvar=where((*!dustem_data.used).values LT 0, testngtv)
            varvar=where((*!dustem_data.used).values GT 0, testpstv)
18e4331f   Ilyes Choubani   general update (f...
1143
1144
1145
1146
1147
1148
1149
1150
            ;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)
abebbdf3   Ilyes Choubani   General update: A...
1151
            match2,((*!dustem_data.used).wav),((*!dustem_show.used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
1152
1153
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
5f04fa07   Ilyes Choubani   general update
1154
            ;stop
18e4331f   Ilyes Choubani   general update (f...
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
            ;#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
5f04fa07   Ilyes Choubani   general update
1170
                    xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
                  
                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]
5f04fa07   Ilyes Choubani   general update
1185
                            yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
                            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]
5f04fa07   Ilyes Choubani   general update
1197
                            yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
                            rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2. 
;                             if testsgq ne 0 then dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/negative_only,/overplot else $
;                                 dustem_plot_mlog,xx,((*!dustem_data.used).values)(idx_filt),ppositions=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/positive_only,/overplot
                            cgoplot,xx,((*!dustem_data.used).values)(idx_filt)/yy,pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                            cgerrplot,((*!dustem_data.used).wav)(idx_filt),(((*!dustem_data.used).values)[idx_filt]-rms)/yy,(((*!dustem_data.used).values)[idx_filt]+rms)/yy,color='Dodger Blue' 
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
                        xtit=textoidl('\lambda (\mum)')
1355825c   Ilyes Choubani   General update
1209
1210
                        ;if !run_pol then xtit = ''
                        cgplot,wavs,wavs/wavs,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
2df3360b   Ilyes Choubani   Correcting error:...
1211
                        xyouts,pospltxt-[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
                    
                    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
     
2df3360b   Ilyes Choubani   Correcting error:...
1222
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
1223
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
1224
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
                                    
                                    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
18e4331f   Ilyes Choubani   general update (f...
1238
                                ENDFOR
5f04fa07   Ilyes Choubani   general update
1239
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
1240
1241
                                for i=0L,n_plgns-1 do begin
                                    IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_POLSED') THEN begin
5f04fa07   Ilyes Choubani   general update
1242
                                        
18e4331f   Ilyes Choubani   general update (f...
1243
1244
1245
1246
1247
1248
1249
                                        ;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))[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1250
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1251
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
1252
                                    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...
1253
1254
1255
1256
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1257
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1258
1259
1260
1261
                                    ;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
                                
5f04fa07   Ilyes Choubani   general update
1262
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
1263
1264
1265
1266
1267
1268
1269
1270
1271
                            
                            endif
                                    
                        
                        endif
                        
                        
                        if keyword_set(negative_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
1272
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
1273
                            
18e4331f   Ilyes Choubani   general update (f...
1274
1275
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
                                    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    
18e4331f   Ilyes Choubani   general update (f...
1287
1288
                                ENDFOR
                                ;Plotting of the plugins
5f04fa07   Ilyes Choubani   general update
1289
                                FOR i=0L,n_plgns-1 do begin
18e4331f   Ilyes Choubani   general update (f...
1290
1291
1292
1293
                                    IF total(strsplit((*(*!dustem_scope).(i)),'+',/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))[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                    ENDIF
5f04fa07   Ilyes Choubani   general update
1294
                                ENDFOR
18e4331f   Ilyes Choubani   general update (f...
1295
1296
1297
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1298
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1299
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
1300
                                    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...
1301
1302
1303
1304
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1305
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1306
1307
1308
                                    ;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
5f04fa07   Ilyes Choubani   general update
1309
                                
18e4331f   Ilyes Choubani   general update (f...
1310
                                ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
1311
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
bc224f3e   Ilyes Choubani   Update of plottin...
1312
                            
18e4331f   Ilyes Choubani   general update (f...
1313
1314
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
1315
1316
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
1317
1318
1319
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.
bc224f3e   Ilyes Choubani   Update of plottin...
1320
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
1321
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
5f04fa07   Ilyes Choubani   general update
1322
                        xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
1323
1324
1325
1326
1327
1328
                        ;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)
9cb38725   Ilyes Choubani   Fixed tests relat...
1329
1330
1331
1332
1333
1334
                        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
5f04fa07   Ilyes Choubani   general update
1335
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
1336
1337
1338
                        
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1339
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1340
1341
1342
1343
1344
1345
1346
1347
                            ;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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1348
                                    ;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
18e4331f   Ilyes Choubani   general update (f...
1349
                                        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
9cb38725   Ilyes Choubani   Fixed tests relat...
1350
                                    ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1351
1352
1353
1354
1355
1356
1357
1358
                                    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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1359
                                    ;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
5f04fa07   Ilyes Choubani   general update
1360
                                    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
9cb38725   Ilyes Choubani   Fixed tests relat...
1361
                                    ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1362
1363
1364
1365
                                    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
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1366
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1367
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1368
1369
1370
1371
1372
1373
1374
1375
                                    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
18e4331f   Ilyes Choubani   general update (f...
1376
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
                                    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   
2df3360b   Ilyes Choubani   Correcting error:...
1390
                            endif else begin
9cb38725   Ilyes Choubani   Fixed tests relat...
1391
1392
1393
                                ;stop
                                if ct_hdnpts then begin
                                    if ct_spec_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1394
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1395
1396
1397
1398
1399
1400
                                        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
18e4331f   Ilyes Choubani   general update (f...
1401
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1402
1403
1404
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1405
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1406
1407
1408
                                        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.
18e4331f   Ilyes Choubani   general update (f...
1409
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1410
1411
1412
1413
                                        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...
1414
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1415
1416
1417
1418
                                    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)'
                                            
18e4331f   Ilyes Choubani   general update (f...
1419
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1420
1421
                                        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)'
                                            
18e4331f   Ilyes Choubani   general update (f...
1422
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1423
1424
                                    endif
                                endif
18e4331f   Ilyes Choubani   general update (f...
1425
                            
2df3360b   Ilyes Choubani   Correcting error:...
1426
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
1427
1428
1429
1430
                        
                        endif 
                        
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
1431
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1432
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1433
1434
1435
1436
1437
1438
1439
1440
                                 
                                 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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1441
                                     ;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
5f04fa07   Ilyes Choubani   general update
1442
                                     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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1443
                                     ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1444
1445
1446
1447
1448
1449
1450
1451
                                     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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1452
                                     ;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
5f04fa07   Ilyes Choubani   general update
1453
                                     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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
1454
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1455
1456
1457
1458
1459
                                     
                                     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
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1460
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1461
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1462
1463
1464
1465
1466
1467
1468
                                     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
18e4331f   Ilyes Choubani   general update (f...
1469
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1470
                                     endif 
18e4331f   Ilyes Choubani   general update (f...
1471
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
                                     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
18e4331f   Ilyes Choubani   general update (f...
1482

9cb38725   Ilyes Choubani   Fixed tests relat...
1483
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
1484
                            
2df3360b   Ilyes Choubani   Correcting error:...
1485
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
1486
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1487
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1488
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1489
1490
1491
1492
1493
1494
1495
                                    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
18e4331f   Ilyes Choubani   general update (f...
1496
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1497
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
1498
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1499
1500
1501
1502
1503
                                    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.
18e4331f   Ilyes Choubani   general update (f...
1504
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1505
1506
1507
1508
                                        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...
1509
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1510
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1511
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1512
1513
1514
1515
1516
                                        if ct_spec ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
                                        
                                        if ct_filt ne 0 then  dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-((*!dustem_data.used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                            
18e4331f   Ilyes Choubani   general update (f...
1517
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1518
1519
                                    endif
                                endif
18e4331f   Ilyes Choubani   general update (f...
1520
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1521
                            endelse
5f04fa07   Ilyes Choubani   general update
1522
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
1523
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
1524
1525
1526
1527
1528
1529
1530
1531
1532
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;
18e4331f   Ilyes Choubani   general update (f...
1533

b5314324   Ilyes Choubani   updating the plot...
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
        
        end
        
        'QEXT': begin
        
        end
        
        'UEXT': begin
        
        end
5f04fa07   Ilyes Choubani   general update
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
        
        '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 - ...
1564
                    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
1565
1566
1567
1568
1569
                      
                        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...
1570
                        yypos = 0.85 - k*0.09 
5f04fa07   Ilyes Choubani   general update
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
                        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 - ...
1590
1591
1592
1593
1594
1595
1596
1597
1598
                    
                    
                    
                    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...
1599
                        yypos = 0.85 - k*0.09 
fcb6eade   Ilyes Choubani   general update - ...
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
                        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
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
                
                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 - ...
1639
                    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
1640
1641
1642
1643
1644
                      
                        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...
1645
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
                        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 - ...
1660
1661
1662
1663
1664
1665
1666
1667
                  
                  
                  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...
1668
                      yypos = 0.85 - k*0.09
fcb6eade   Ilyes Choubani   general update - ...
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
                      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
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
                
                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 
                        mm = where(tag_names(*!dustem_scope) 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_paramtag).(mm))
                        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...
1716
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
                        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 
                        mm = where(tag_names(*!dustem_scope) 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_paramtag).(mm))
                        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...
1756
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
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
                        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
         
        
        
        
        
        end
        
        
        
        
        
b5314324   Ilyes Choubani   updating the plot...
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
    
    endcase


endif











 


 
  












END