Blame view

src/idl/dustemcgwin_dataset.pro 128 KB
5f04fa07   Ilyes Choubani   general update
1
PRO dustemcgwin_dataset, st, dustem_interp, dustem_spec, extra_spec, dataset=dataset, norm=norm, refresh=refresh, nodata=nodata, position=position,positive_only=positive_only, negative_only=negative_only, _extra=_extra
b5314324   Ilyes Choubani   updating the plot...
2

b5314324   Ilyes Choubani   updating the plot...
3

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

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

18e4331f   Ilyes Choubani   general update (f...
1085
1086
1087
1088
                                 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...
1089
                                    ; 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...
1090
                                         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...
1091
1092
                                     ;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...
1093
1094
1095
1096
1097
1098
1099
                                  
                                 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...
1100
                                     ;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...
1101
                                         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...
1102
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1103
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1104
                                     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...
1105
1106
                                         
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
1107
                            
c8368c6e   Ilyes Choubani   updating plotting...
1108
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
1109
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1110
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1111
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1112
1113
1114
1115
1116
1117
1118
                                    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...
1119
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1120
1121
1122
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1123
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1124
1125
1126
                                        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...
1127
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1128
1129
                                        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...
1130
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1131
1132
1133
                                    endif
                                    
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1134
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1135
1136
1137
1138
1139
                                        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...
1140
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1141
1142
1143
                                    endif
                                        
                                endif    
18e4331f   Ilyes Choubani   general update (f...
1144
                            endelse
5f04fa07   Ilyes Choubani   general update
1145
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
                        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:...
1163
1164
            varvar=where((*!dustem_data.used).values LT 0, testngtv)
            varvar=where((*!dustem_data.used).values GT 0, testpstv)
18e4331f   Ilyes Choubani   general update (f...
1165
1166
1167
1168
1169
1170
1171
1172
            ;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...
1173
            match2,((*!dustem_data.used).wav),((*!dustem_show.used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
1174
1175
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
5f04fa07   Ilyes Choubani   general update
1176
            ;stop
18e4331f   Ilyes Choubani   general update (f...
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
            ;#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
1192
                    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...
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
                  
                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
1207
                            yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
                            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
1219
                            yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
                            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
1231
1232
                        ;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:...
1233
                        xyouts,pospltxt-[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
                    
                    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:...
1244
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
1245
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
1246
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
                                    
                                    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...
1260
                                ENDFOR
5f04fa07   Ilyes Choubani   general update
1261
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
1262
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1263
1264
1265
1266
1267
1268
1269
1270
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
5f04fa07   Ilyes Choubani   general update
1271
                                        
18e4331f   Ilyes Choubani   general update (f...
1272
                                    ENDIF
3c479f24   Ilyes Choubani   Allowing to fix p...
1273
                                    
18e4331f   Ilyes Choubani   general update (f...
1274
1275
1276
1277
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1278
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1279
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
1280
                                    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...
1281
1282
1283
1284
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1285
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1286
1287
1288
1289
                                    ;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
1290
                                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...
1291
1292
1293
1294
1295
1296
1297
1298
1299
                            
                            endif
                                    
                        
                        endif
                        
                        
                        if keyword_set(negative_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
1300
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
1301
                            
18e4331f   Ilyes Choubani   general update (f...
1302
1303
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
                                    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...
1315
1316
                                ENDFOR
                                ;Plotting of the plugins
5f04fa07   Ilyes Choubani   general update
1317
                                FOR i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1318
1319
1320
1321
1322
1323
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
1324
                                    ENDIF
5f04fa07   Ilyes Choubani   general update
1325
                                ENDFOR
18e4331f   Ilyes Choubani   general update (f...
1326
1327
1328
                                ;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
1329
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
1330
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
fcb6eade   Ilyes Choubani   general update - ...
1331
                                    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...
1332
1333
1334
1335
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1336
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
1337
1338
1339
                                    ;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
1340
                                
18e4331f   Ilyes Choubani   general update (f...
1341
                                ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
1342
                                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...
1343
                            
18e4331f   Ilyes Choubani   general update (f...
1344
1345
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
1346
1347
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
1348
1349
1350
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.
bc224f3e   Ilyes Choubani   Update of plottin...
1351
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
1352
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
5f04fa07   Ilyes Choubani   general update
1353
                        xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
1354
1355
1356
1357
1358
1359
                        ;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...
1360
1361
1362
1363
1364
1365
                        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
1366
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
1367
1368
1369
                        
                        if keyword_set(positive_only) then begin
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1370
                            if testpstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1371
1372
1373
1374
1375
1376
1377
1378
                            ;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...
1379
                                    ;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...
1380
                                        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...
1381
                                    ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1382
1383
1384
1385
1386
1387
1388
1389
                                    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...
1390
                                    ;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
1391
                                    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...
1392
                                    ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1393
1394
1395
1396
                                    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...
1397
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1398
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1399
1400
1401
1402
1403
1404
1405
1406
                                    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...
1407
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
                                    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:...
1421
                            endif else begin
9cb38725   Ilyes Choubani   Fixed tests relat...
1422
1423
1424
                                ;stop
                                if ct_hdnpts then begin
                                    if ct_spec_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1425
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1426
1427
1428
1429
1430
1431
                                        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...
1432
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1433
1434
1435
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1436
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1437
1438
1439
                                        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...
1440
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1441
1442
1443
1444
                                        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...
1445
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1446
1447
1448
1449
                                    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...
1450
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1451
1452
                                        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...
1453
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1454
1455
                                    endif
                                endif
18e4331f   Ilyes Choubani   general update (f...
1456
                            
2df3360b   Ilyes Choubani   Correcting error:...
1457
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
1458
1459
1460
1461
                        
                        endif 
                        
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
1462
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1463
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1464
1465
1466
1467
1468
1469
1470
1471
                                 
                                 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...
1472
                                     ;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
1473
                                     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...
1474
                                     ;endelse;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1475
1476
1477
1478
1479
1480
1481
1482
                                     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...
1483
                                     ;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
1484
                                     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...
1485
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
1486
1487
1488
1489
1490
                                     
                                     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...
1491
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1492
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
1493
1494
1495
1496
1497
1498
1499
                                     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...
1500
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1501
                                     endif 
18e4331f   Ilyes Choubani   general update (f...
1502
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
                                     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...
1513

9cb38725   Ilyes Choubani   Fixed tests relat...
1514
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
1515
                            
2df3360b   Ilyes Choubani   Correcting error:...
1516
                            endif else begin
18e4331f   Ilyes Choubani   general update (f...
1517
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1518
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
1519
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
1520
1521
1522
1523
1524
1525
1526
                                    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...
1527
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1528
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
1529
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1530
1531
1532
1533
1534
                                    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...
1535
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1536
1537
1538
1539
                                        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...
1540
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1541
                                    if ct_spec_hdn_ngtv eq 0 and ct_filt_hdn_ngtv eq 0 then begin
18e4331f   Ilyes Choubani   general update (f...
1542
                                        
9cb38725   Ilyes Choubani   Fixed tests relat...
1543
1544
1545
1546
1547
                                        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...
1548
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
1549
1550
                                    endif
                                endif
18e4331f   Ilyes Choubani   general update (f...
1551
                            ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1552
                            endelse
5f04fa07   Ilyes Choubani   general update
1553
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
1554
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
1555
1556
1557
1558
1559
1560
1561
1562
1563
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;
18e4331f   Ilyes Choubani   general update (f...
1564

b5314324   Ilyes Choubani   updating the plot...
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
        
        end
        
        'QEXT': begin
        
        end
        
        'UEXT': begin
        
        end
5f04fa07   Ilyes Choubani   general update
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
        
        '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 - ...
1595
                    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
1596
1597
1598
1599
1600
                      
                        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...
1601
                        yypos = 0.85 - k*0.09 
5f04fa07   Ilyes Choubani   general update
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
                        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 - ...
1621
1622
1623
1624
1625
1626
1627
1628
1629
                    
                    
                    
                    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...
1630
                        yypos = 0.85 - k*0.09 
fcb6eade   Ilyes Choubani   general update - ...
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
                        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
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
                
                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 - ...
1670
                    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
1671
1672
1673
1674
1675
                      
                        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...
1676
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
                        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 - ...
1691
1692
1693
1694
1695
1696
1697
1698
                  
                  
                  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...
1699
                      yypos = 0.85 - k*0.09
fcb6eade   Ilyes Choubani   general update - ...
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
                      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
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
                
                ENDFOR
                
                
            endelse
        
        end
        
        'PLUGINS':begin ;NOT SO SURE ABOUT THIS BLOCK . TEST IT WHEN YOU GET HOME
           
            p_dim = extra_spec
        
            Npar=n_elements(p_dim)
        
            if keyword_set(refresh) then begin ;(REFRESHED RUN) 
                
                k=0
                res = dustem_interp
                errors = dustem_spec
                
                FOR i=0L,Npar-1 DO BEGIN  
                  ;stop
                    parameter_description = (*(*!dustem_fit).param_descs)[i]
                    parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                  
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,6)) eq 'DUSTEM' THEN BEGIN
                        
                        ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
3c479f24   Ilyes Choubani   Allowing to fix p...
1742
1743
                        mm = where(tag_names(*!dustem_plugin) eq strupcase(strmid(string_name,7,ii-7))) ;,coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector
                        prmtg = (*(*!dustem_plugin).(mm).paramtag)
5f04fa07   Ilyes Choubani   general update
1744
1745
1746
                        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...
1747
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
                        xxpos = 0.0 
                        
                        str = strtrim(string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0),2)
                        str1 = str+string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)
                        cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                        xxpos=(1-thiswidth)/2
                        cgtext, xxpos, yypos, str, charsize=-1, width=thiswidth, /normal
                        xxpos+=thiswidth;(1-thiswidth)/2
                        str = string(res[i],format=frmt1)+textoidl(' \pm ')+string(errors(i),format=frmt1)

                        xyouts,xxpos,yypos,str,color=0,/normal,charsize=1.
                        k+=1
                        
                    ENDIF          
                            
                
                ENDFOR
            
            endif else begin ;(FROZEN RUN = title strings)
                
                k=0
                res = dustem_interp
                errors = dustem_spec
                    
                FOR i=0L,Npar-1 DO BEGIN  
                  ;stop
                    parameter_description = (*(*!dustem_fit).param_descs)[i]
                    parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                    
                    
                    IF STRUPCASE(strmid(strtrim(parameter_description,2),0,6)) eq 'DUSTEM' THEN BEGIN
                        
                        ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
3c479f24   Ilyes Choubani   Allowing to fix p...
1781
1782
                        mm = where(tag_names(*!dustem_plugin) eq strupcase(strmid(string_name,7,ii-7))) ;,coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector
                        prmtg = (*(*!dustem_plugin).(mm).paramtag)
5f04fa07   Ilyes Choubani   general update
1783
1784
1785
1786
                        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...
1787
                        yypos = 0.85 - k*0.09
5f04fa07   Ilyes Choubani   general update
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
                        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...
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
    
    endcase


endif











 


 
  












END