Blame view

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

b5314324   Ilyes Choubani   updating the plot...
3

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

b5314324   Ilyes Choubani   updating the plot...
13
14
15
16
17
18
wavs=dustem_get_wavelengths()
n_plgns = n_tags(*!dustem_plugin)
Ngrains=(*!dustem_params).Ngrains
use_cols=dustem_grains_colors(Ngrains,/cgplot)
use_cols[1]='Cornflower'
fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 ; st.sed.wav and st.polsed.wav should remain the same
18e4331f   Ilyes Choubani   general update (f...
19
degtorad = !pi/180 ;factor that the arctan will be devided by in order to have an axis in degrees. Talk to JP maybe he wants angle in radians.
5f04fa07   Ilyes Choubani   general update
20
 
b5314324   Ilyes Choubani   updating the plot...
21
clrs_plgns = ['Rosy Brown','Gold','Light Coral','Slate Blue','Dark Khaki','Salmon','Dark Green'] ;FOR NOW
67bd858a   Ilyes Choubani   Replication of th...
22
23
;NB: plugins need to have different colors for extinction because they are not the same plugins. New array required.

3c479f24   Ilyes Choubani   Allowing to fix p...
24
scopes=tag_names((*!dustem_plugin))
b5314324   Ilyes Choubani   updating the plot...
25
tgnms_extra = tag_names(_extra)
c8368c6e   Ilyes Choubani   updating plotting...
26

96a72c8b   Ilyes Choubani   seperating xrange...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
ind_xrm = where(strmid(tgnms_extra,0,4) EQ 'XR_M',ct_xrm)
ind_xrx = where(strmid(tgnms_extra,0,4) EQ 'XR_X',ct_xrx)
ind_yrm = where(strmid(tgnms_extra,0,4) EQ 'YR_M',ct_yrm)
ind_yrx = where(strmid(tgnms_extra,0,4) EQ 'YR_X',ct_yrx)
ct_m = ct_xrm+ct_yrm
ct_x = ct_xrx+ct_yrx

IF ct_m+ct_x NE 0 THEN BEGIN

    IF ct_xrm NE 0 THEN xr_m = (_extra.(ind_xrm))
    IF ct_xrx NE 0 THEN xr_x = (_extra.(ind_xrx))
    IF ct_yrm NE 0 THEN yr_m = (_extra.(ind_yrm))
    IF ct_yrx NE 0 THEN yr_x = (_extra.(ind_yrx))

ENDIF ELSE BEGIN

    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))
    
ENDELSE 
5f04fa07   Ilyes Choubani   general update
49
50
51
52

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


5f04fa07   Ilyes Choubani   general update
55
;############################################################################################
b5314324   Ilyes Choubani   updating the plot...
56

b5314324   Ilyes Choubani   updating the plot...
57

abebbdf3   Ilyes Choubani   General update: A...
58
59
;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. 
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
60
61
62
;THIS CAN CREATE ERRORS (EVEN THOUGH IT WAS WRONG AND WORKED) SO REMEMBER YOU DID THIS. 

;I DO NOT REMEMBER RUNNING ANY OF THE TESTS HERE. 
abebbdf3   Ilyes Choubani   General update: A...
63

abebbdf3   Ilyes Choubani   General update: A...
64

b5314324   Ilyes Choubani   updating the plot...
65
66
67
68
69
70
if keyword_set(dataset) then begin
;!run_pol is implied for QSED/USED/POLSED etc...
    Case strupcase(dataset) of 
    
        'SED': begin
            
4b745987   Ilyes Choubani   minor update
71
72
73
74
            IF ct_m NE 0 then begin
                xr=xr_m
                yr=yr_m 
            endif
afde94a3   Ilyes Choubani   general update
75
76
77
78
79
80
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
81
82
            idx_filt=where((*(*!dustem_data).sed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).sed).filt_names EQ 'SPECTRUM',ct_spec)
b5314324   Ilyes Choubani   updating the plot...
83
84
85
86
87
88
89
90
91
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
92
                    cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
b5314324   Ilyes Choubani   updating the plot...
93
94
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
5f04fa07   Ilyes Choubani   general update
95
96
97
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
afde94a3   Ilyes Choubani   general update
98
                    ;/NODATA    
b5314324   Ilyes Choubani   updating the plot...
99
100
                    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
101
                    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...
102
                  
5f04fa07   Ilyes Choubani   general update
103
104
                ;endelse  
                endif
b5314324   Ilyes Choubani   updating the plot...
105
            
5f04fa07   Ilyes Choubani   general update
106
107
            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...
108
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
109
                    
b5314324   Ilyes Choubani   updating the plot...
110
111
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
b5314324   Ilyes Choubani   updating the plot...
112
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
113
                            xx=((*(*!dustem_data).sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
114
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
115
116
117
                            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...
118
                        ENDIF
b5314324   Ilyes Choubani   updating the plot...
119
                        
c8368c6e   Ilyes Choubani   updating plotting...
120
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
121
                            xx=((*(*!dustem_data).sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
122
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
123
124
125
                            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
                            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...
126
127
128
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
129
130
                    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...
131
                        
5f04fa07   Ilyes Choubani   general update
132
133
                    if not keyword_set(refresh) then begin 
                        ;stop   
afde94a3   Ilyes Choubani   general update
134
                        
b5314324   Ilyes Choubani   updating the plot...
135
                        xtit=textoidl('\lambda (\mum)')
fcb6eade   Ilyes Choubani   general update - ...
136
137
138
139
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
e0d00de0   Ilyes Choubani   removing stops
140
                        
afde94a3   Ilyes Choubani   general update
141
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
b5314324   Ilyes Choubani   updating the plot...
142
143
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
5f04fa07   Ilyes Choubani   general update
144
145
                    ;endelse
                    endif
b5314324   Ilyes Choubani   updating the plot...
146
147
                    
                
5f04fa07   Ilyes Choubani   general update
148
149
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
b5314324   Ilyes Choubani   updating the plot...
150
151
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
b5314324   Ilyes Choubani   updating the plot...
152
153
154
155
156
                        ;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...
157
                                                
b5314324   Ilyes Choubani   updating the plot...
158
159
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
160
161
162
163
164
165
166
167
168
                            
                            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...
169
                        endfor
c8368c6e   Ilyes Choubani   updating plotting...
170
                                                
b5314324   Ilyes Choubani   updating the plot...
171
                        ;PLotting of the interpolates corresponding to spectrum and filter points
c8368c6e   Ilyes Choubani   updating plotting...
172
                           
b5314324   Ilyes Choubani   updating the plot...
173
174
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
175
                            xx=((*(*!dustem_data).sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
176
                            yy=dustem_interp[idx_spec]
abebbdf3   Ilyes Choubani   General update: A...
177
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
b5314324   Ilyes Choubani   updating the plot...
178
179
                        ENDIF
                        
c8368c6e   Ilyes Choubani   updating plotting...
180
181
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
182
                            xx=((*(*!dustem_data).sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
183
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
184
185
186
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
b5314324   Ilyes Choubani   updating the plot...
187
                        
c8368c6e   Ilyes Choubani   updating plotting...
188
                        ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
189
                        cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
c8368c6e   Ilyes Choubani   updating plotting...
190
191
192
                         
                                        
                                
5f04fa07   Ilyes Choubani   general update
193
194
195
                    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...
196
197
198
199
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
200
                            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...
201
202
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
203
204
                            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'
b5314324   Ilyes Choubani   updating the plot...
205
206
207
208

                        endif
                        
                        if ct_filt ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
209
                        
b5314324   Ilyes Choubani   updating the plot...
210
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
211
212
                            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...
213
                            
b5314324   Ilyes Choubani   updating the plot...
214
215
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
216
217
                            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...
218
                            
b5314324   Ilyes Choubani   updating the plot...
219
                        endif
c8368c6e   Ilyes Choubani   updating plotting...
220
221
                        
                        
b5314324   Ilyes Choubani   updating the plot...
222
                        ;Plotting of frequency axis
96a72c8b   Ilyes Choubani   seperating xrange...
223
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(xr))*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
c8368c6e   Ilyes Choubani   updating plotting...
224
                        
5f04fa07   Ilyes Choubani   general update
225
                        xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
c8368c6e   Ilyes Choubani   updating plotting...
226
                         
b5314324   Ilyes Choubani   updating the plot...
227
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
228
                        match2,((*(*!dustem_data).sed).wav),((*(*!dustem_show).sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
229
                        idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
230
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
231
232
                        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)
2df3360b   Ilyes Choubani   Correcting error:...
233
                         
c8368c6e   Ilyes Choubani   updating plotting...
234
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
235
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
236
237
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
238
                                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...
239
240
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
241
242
                                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'
18e4331f   Ilyes Choubani   general update (f...
243
                            endif                                            
b5314324   Ilyes Choubani   updating the plot...
244
                            
18e4331f   Ilyes Choubani   general update (f...
245
                            if ct_filt_hdn then begin
b5314324   Ilyes Choubani   updating the plot...
246
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
247
                                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...
248
249
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
250
251
                                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'
18e4331f   Ilyes Choubani   general update (f...
252
253
                                
                            endif
b5314324   Ilyes Choubani   updating the plot...
254
255
256
257
258
                                                           
                        endif    
                        
                        
                    
5f04fa07   Ilyes Choubani   general update
259
260
                    ;endelse 
                    endif
b5314324   Ilyes Choubani   updating the plot...
261
262
                
                
5f04fa07   Ilyes Choubani   general update
263
264
265
266
                ;endelse 
                endif            
            ;endelse
            endif 
18e4331f   Ilyes Choubani   general update (f...
267
        ;stop    
b5314324   Ilyes Choubani   updating the plot...
268
269
        end
        
afde94a3   Ilyes Choubani   general update
270
        'EXT': begin ;BE VERY CAREFUL THE EXTINCTION STRUCTURE AS REDERED BY DUSTEM IS DIFFERENT THAN THE EMISSION ONE
b5314324   Ilyes Choubani   updating the plot...
271
        
afde94a3   Ilyes Choubani   general update
272
273
274
275
276
;             ;So far manually changing xr and yr.
;             
;             xr=[0.01,30]
;             yr=[1.00E-06,10]
            
4b745987   Ilyes Choubani   minor update
277
            IF ct_x NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
278
            
4b745987   Ilyes Choubani   minor update
279
280
281
282
                xr=xr_x 
                yr=yr_x
                
            ENDIF
afde94a3   Ilyes Choubani   general update
283
284
285
286
287
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
288
289
            idx_filt=where((*(*!dustem_data).ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).ext).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
290
291
292
293
294
295
296
            
            ;#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
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
297
                    xtit=textoidl('1/\lambda (\mum^{-1})')
67bd858a   Ilyes Choubani   Replication of th...
298
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
299
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
300
301
302
303
304
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
afde94a3   Ilyes Choubani   general update
305
                    ;/NODATA    
67bd858a   Ilyes Choubani   Replication of th...
306
                    cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8  
afde94a3   Ilyes Choubani   general update
307
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
f2caf3f1   Ilyes Choubani   Debugging some er...
308
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
309
310
311
312
313
314
315
316
317
318
319
                  
                ;endelse  
                endif
            
            endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
            if not keyword_set(nodata) then begin
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
320
                            xx=((*(*!dustem_data).ext).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
321
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
322
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
323
324
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
325
326
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_spec))[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
94c4dffa   Ilyes Choubani   update + fixes fo...
327
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
328
329
330
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN ; There are no filter points for now...
0068116a   Ilyes Choubani   General update + ...
331
                            xx=((*(*!dustem_data).ext).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
332
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
333
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_filt)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
334
335
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
336
337
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_filt))[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot 
94c4dffa   Ilyes Choubani   update + fixes fo...
338
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
339
340
341
342
343
344
345
346
                        ENDIF
                            
                        
                    endif ;else begin ;The data points in the plot that remain unchanged ; UNNECESSARY BLOCK but needede to limit erros when calls are made with missing keywords.
                        ;stop
                        
                    if not keyword_set(refresh) then begin 
                        ;stop   
f2caf3f1   Ilyes Choubani   Debugging some er...
347
                        xtit=textoidl('1/\lambda (\mum^{-1})')
67bd858a   Ilyes Choubani   Replication of th...
348
349
350
351
                        if !run_pol then begin
                            xtit = ''
                            xtickformat='(A1)'
                        endif else xtickformat='(F10.2)' ;MAYBE YOU'LL CHANGE THIS FORMAT TO EXPONENTIAL NOTATION
afde94a3   Ilyes Choubani   general update
352
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat=xtickformat,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
353
354
355
356
357
358
359
360
361
362
363
364
365
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    ;endelse
                    endif
                    
                
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;not so sure about the multiplicative factor
                        
                        ;Plotting of the spectra of the dust species
afde94a3   Ilyes Choubani   general update
366
                    
67bd858a   Ilyes Choubani   Replication of th...
367
                        FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
368
                            cgoplot,1/st.ext.wav,transpose((st.ext.(1))[i,*]+(st.ext.(2))[i,*])*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
369
                        ENDFOR
07372e26   Ilyes Choubani   Corrected huge pl...
370
                            
67bd858a   Ilyes Choubani   Replication of th...
371
372
373
374
375
376
377
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin 
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_EXT') THEN begin
afde94a3   Ilyes Choubani   general update
378
                                    cgoplot,1/st.ext.wav,((*(*!dustem_plugin).(i).spec)[*,0]),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
379
380
381
382
383
384
385
386
387
388
389
                                ENDIF
                                
                            endif
                            
                        endfor
                        
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
390
                            xx=((*(*!dustem_data).ext).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
391
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
392
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
393
394
395
396
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
397
                            xx=((*(*!dustem_data).ext).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
398
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
399
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
400
401
402
403
                        ENDIF
                        
                        
                        ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
404
                        cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
67bd858a   Ilyes Choubani   Replication of th...
405
406
407
408
409
410
411
412
413
414
                         
                                        
                                
                    endif ;else begin ;The data points in the plot that remain unchanged.
                        ;stop
                    if not keyword_set(refresh) then begin
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
415
                            cgplot,1/((*(*!dustem_data).ext).wav)(idx_spec),((*(*!dustem_data).ext).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=16,syms=0.8,ytickformat='dstmwrp_exp'                
67bd858a   Ilyes Choubani   Replication of th...
416
417
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
418
419
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).ext).wav)(idx_spec),((*(*!dustem_data).ext).values)(idx_spec)-rms,((*(*!dustem_data).ext).values)(idx_spec)+rms,color='Powder Blue'
67bd858a   Ilyes Choubani   Replication of th...
420
421
422
423
424
425

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
426
427
                            if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
67bd858a   Ilyes Choubani   Replication of th...
428
429
430
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
431
432
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
                            cgerrplot,1/((*(*!dustem_data).ext).wav)(idx_filt),((*(*!dustem_data).ext).values)(idx_filt)-rms,((*(*!dustem_data).ext).values)(idx_filt)+rms,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
433
434
435
436
437
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
afde94a3   Ilyes Choubani   general update
438
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
67bd858a   Ilyes Choubani   Replication of th...
439
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
440
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
441
442
                         
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
443
                        match2,((*(*!dustem_data).ext).wav),((*(*!dustem_show).ext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
444
                        idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
445
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
446
447
                        idx_filt_hdn = where((((*(*!dustem_show).ext).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).ext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
67bd858a   Ilyes Choubani   Replication of th...
448
449
450
451
452
                         
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
453
                                cgoplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=16,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
454
455
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
456
457
                                rms=3.*(((*(*!dustem_show).ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_spec_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
458
459
460
461
                            endif                                            
                            
                            if ct_filt_hdn then begin
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
462
                                cgoplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=16,syms=0.8                                           
67bd858a   Ilyes Choubani   Replication of th...
463
464
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
465
466
                                rms=3.*(((*(*!dustem_show).ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).ext).wav)[idx_rmv_sed])(idx_filt_hdn),(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*(*!dustem_show).ext).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    ;endelse 
                    endif
                
                
                ;endelse 
                endif            
            ;endelse
            endif
          
b5314324   Ilyes Choubani   updating the plot...
483
484
485
        
        end
        
67bd858a   Ilyes Choubani   Replication of th...
486
487
        'POLEXT': begin 
            
4b745987   Ilyes Choubani   minor update
488
489
490
491
            IF ct_x NE 0 then begin
                xr=xr_x
                yr=yr_x
            ENDIF
afde94a3   Ilyes Choubani   general update
492
493
494
495
496
497
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
498
499
            idx_filt=where((*(*!dustem_data).polext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).polext).filt_names EQ 'SPECTRUM',ct_spec)
18e4331f   Ilyes Choubani   general update (f...
500
501
502
503
504
505
506
            
            ;#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
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
507
                    xtit=textoidl('1/\lambda (\mum^{_1})')
18e4331f   Ilyes Choubani   general update (f...
508
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
509
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
18e4331f   Ilyes Choubani   general update (f...
510
511
512
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
afde94a3   Ilyes Choubani   general update
513
                    ;/NODATA
18e4331f   Ilyes Choubani   general update (f...
514
                    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  
94c4dffa   Ilyes Choubani   update + fixes fo...
515
516
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
517
518
519
520
521
522
523
524
525
526
527
                  
                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
94c4dffa   Ilyes Choubani   update + fixes fo...
528
                            
0068116a   Ilyes Choubani   General update + ...
529
                            xx=((*(*!dustem_data).polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
530
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
531
                            rms=3.*((*(*!dustem_data).polext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
532
533
534
535
                            indzero = where(yy NE 0, ct_zero)
                            
                            IF ct_zero NE 0 THEN BEGIN
                            
0068116a   Ilyes Choubani   General update + ...
536
537
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).polext).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).polext).wav)(idx_spec))[indzero],((((*(*!dustem_data).polext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
94c4dffa   Ilyes Choubani   update + fixes fo...
538
539
                            
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
540
541
542
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
543
                            xx=((*(*!dustem_data).polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
544
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
545
                            rms=3.*((*(*!dustem_data).polext).sigma)(idx_filt)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
546
547
548
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                             
0068116a   Ilyes Choubani   General update + ...
549
550
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).polext).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).polext).wav)(idx_filt))[indzero],((((*(*!dustem_data).polext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot 
94c4dffa   Ilyes Choubani   update + fixes fo...
551
552
                            
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
553
554
555
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
556
                    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...
557
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
558
                        xtit=textoidl('1/\lambda (\mum^{-1})')
18e4331f   Ilyes Choubani   general update (f...
559
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
560
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
18e4331f   Ilyes Choubani   general update (f...
561
562
563
564
565
566
567
568
569
570
571
                        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
07372e26   Ilyes Choubani   Corrected huge pl...
572
573
                            vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
                            cgoplot,1/st.polext.wav,vecto*(*!dustem_HCD)/1.0e21,color=use_cols[i],pos=position,noerase=1
18e4331f   Ilyes Choubani   general update (f...
574
575
576
577
578
579
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
580
                            If isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
581
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
afde94a3   Ilyes Choubani   general update
582
                                    cgoplot,1/st.polext.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
3c479f24   Ilyes Choubani   Allowing to fix p...
583
584
                                ENDIF 
                            endif
18e4331f   Ilyes Choubani   general update (f...
585
586
587
588
589
590
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
591
                            xx=((*(*!dustem_data).polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
592
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
593
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
594
595
596
597
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
598
                            xx=((*(*!dustem_data).polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
599
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
600
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
601
602
603
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
afde94a3   Ilyes Choubani   general update
604
                        cgoplot,1/st.polext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
5f04fa07   Ilyes Choubani   general update
605
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
18e4331f   Ilyes Choubani   general update (f...
606
607
608
609
610
611
612
613
                                        
                                
                    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)
0068116a   Ilyes Choubani   General update + ...
614
                            cgplot,1/((*(*!dustem_data).polext).wav)(idx_spec),((*(*!dustem_data).polext).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=8,syms=0.8,ytickformat='dstmwrp_exp'                
18e4331f   Ilyes Choubani   general update (f...
615
616
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
617
618
                            rms=3.*((*(*!dustem_data).polext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).polext).wav)(idx_spec),((*(*!dustem_data).polext).values)(idx_spec)-rms,((*(*!dustem_data).polext).values)(idx_spec)+rms,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
619
620
621
622
623
624

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
625
626
                            if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
18e4331f   Ilyes Choubani   general update (f...
627
628
629
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
630
631
                            rms=3.*((*(*!dustem_data).polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
                            cgerrplot,1/((*(*!dustem_data).polext).wav)(idx_filt),((*(*!dustem_data).polext).values)(idx_filt)-rms,((*(*!dustem_data).polext).values)(idx_filt)+rms,color='Dodger Blue'
18e4331f   Ilyes Choubani   general update (f...
632
633
634
635
636
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
94c4dffa   Ilyes Choubani   update + fixes fo...
637
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
18e4331f   Ilyes Choubani   general update (f...
638
                        
94c4dffa   Ilyes Choubani   update + fixes fo...
639
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
640
641
                         
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
642
                        match2,((*(*!dustem_data).polext).wav),((*(*!dustem_show).polext).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
74103816   Ilyes Choubani   small update
643
                        idx_rmv_polsed=where(fit_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide  - not renaming this and keeping the polsed notation
2df3360b   Ilyes Choubani   Correcting error:...
644
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
645
646
                        idx_filt_hdn = where((((*(*!dustem_show).polext).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).polext).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
2df3360b   Ilyes Choubani   Correcting error:...
647
                        
1355825c   Ilyes Choubani   General update
648
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
649
650
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
651
652
653
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
654
                                cgoplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
18e4331f   Ilyes Choubani   general update (f...
655
656
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
657
658
                                rms=3.*(((*(*!dustem_show).polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
659
660
                            endif                                            
                            
1355825c   Ilyes Choubani   General update
661
                            if ct_filt_hdn ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
662
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
663
                                cgoplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8                                           
18e4331f   Ilyes Choubani   general update (f...
664
665
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
666
667
                                rms=3.*(((*(*!dustem_show).polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).polext).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*(*!dustem_show).polext).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
67bd858a   Ilyes Choubani   Replication of th...
683
        
b5314324   Ilyes Choubani   updating the plot...
684
685
        end
        
67bd858a   Ilyes Choubani   Replication of th...
686
        'POLSED': begin 
1bc09467   Ilyes Choubani   fixed issue with ...
687
            
4b745987   Ilyes Choubani   minor update
688
689
690
691
692
            IF ct_m NE 0 then begin
                xr=xr_m 
                yr=yr_m
                
            ENDIF
1bc09467   Ilyes Choubani   fixed issue with ...
693
694
695
696
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
67bd858a   Ilyes Choubani   Replication of th...
697
            
0068116a   Ilyes Choubani   General update + ...
698
699
            idx_filt=where((*(*!dustem_data).polsed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).polsed).filt_names EQ 'SPECTRUM',ct_spec)
1355825c   Ilyes Choubani   General update
700
701
702
703
704
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
67bd858a   Ilyes Choubani   Replication of th...
705
706
707
708
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
709
                    cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8  
                    cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
            
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
1355825c   Ilyes Choubani   General update
726
                        
67bd858a   Ilyes Choubani   Replication of th...
727
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
728
                            xx=((*(*!dustem_data).polsed).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
729
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
730
                            rms=3.*((*(*!dustem_data).polsed).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
731
732
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
733
734
                                cgoplot,xx[indzero],(((*(*!dustem_data).polsed).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                                cgerrplot,(((*(*!dustem_data).polsed).wav)(idx_spec))[indzero],((((*(*!dustem_data).polsed).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polsed).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
94c4dffa   Ilyes Choubani   update + fixes fo...
735
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
736
                        ENDIF
1355825c   Ilyes Choubani   General update
737
                        
67bd858a   Ilyes Choubani   Replication of th...
738
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
739
                            xx=((*(*!dustem_data).polsed).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
740
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
741
                            rms=3.*((*(*!dustem_data).polsed).sigma)(idx_filt)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
742
743
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN 
0068116a   Ilyes Choubani   General update + ...
744
745
                                cgoplot,xx[indzero],(((*(*!dustem_data).polsed).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                                cgerrplot,(((*(*!dustem_data).polsed).wav)(idx_filt))[indzero],((((*(*!dustem_data).polsed).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).polsed).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot 
94c4dffa   Ilyes Choubani   update + fixes fo...
746
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
747
748
                        ENDIF
                            
1355825c   Ilyes Choubani   General update
749
                        
67bd858a   Ilyes Choubani   Replication of th...
750
                    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.
1bc09467   Ilyes Choubani   fixed issue with ...
751
                        
67bd858a   Ilyes Choubani   Replication of th...
752
753
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
754
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
755
756
757
758
759
760
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
1355825c   Ilyes Choubani   General update
761
                        
67bd858a   Ilyes Choubani   Replication of th...
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            cgoplot,st.polsed.wav,st.polsed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            If isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                ENDIF 
                            endif
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
784
                            xx=((*(*!dustem_data).polsed).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
785
786
787
788
789
790
                            yy=dustem_interp[idx_spec]
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
791
                            xx=((*(*!dustem_data).polsed).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
                            yy=dustem_interp[idx_filt]
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
                        cgoplot,st.polsed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                                        
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
807
                            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'                
67bd858a   Ilyes Choubani   Replication of th...
808
809
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
810
811
                            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'
67bd858a   Ilyes Choubani   Replication of th...
812
813
814
815
816
817

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
818
819
                            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
67bd858a   Ilyes Choubani   Replication of th...
820
821
822
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
823
824
                            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'
67bd858a   Ilyes Choubani   Replication of th...
825
826
827
828
829
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
96a72c8b   Ilyes Choubani   seperating xrange...
830
                        cgaxis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(xr))*1E-9),charsize=1.15,title=textoidl('\nu (GHz)')
67bd858a   Ilyes Choubani   Replication of th...
831
832
833
834
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
835
                        match2,((*(*!dustem_data).polsed).wav),((*(*!dustem_show).polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
74103816   Ilyes Choubani   small update
836
                        idx_rmv_polsed=where(fit_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
837
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
838
839
                        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)
67bd858a   Ilyes Choubani   Replication of th...
840
841
842
843
844
845
846
                        
                        ;stop
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
847
                                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
67bd858a   Ilyes Choubani   Replication of th...
848
849
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
850
851
                                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'
67bd858a   Ilyes Choubani   Replication of th...
852
853
854
855
                            endif                                            
                            
                            if ct_filt_hdn ne 0 then begin
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
856
                                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                                           
67bd858a   Ilyes Choubani   Replication of th...
857
858
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
859
860
                                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'
67bd858a   Ilyes Choubani   Replication of th...
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
        end
        
        'POLFRAC': begin 
96a72c8b   Ilyes Choubani   seperating xrange...
879
            
4b745987   Ilyes Choubani   minor update
880
881
882
883
884
            IF ct_m NE 0 then begin
                xr=xr_m
                yr=yr_m
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
885
886
            idx_filt=where((*(*!dustem_data).polfrac).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).polfrac).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
887
888
889
890
891
892
            
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[1.00E-04,50.00],/ylog,psym=8,syms=0.8  
07372e26   Ilyes Choubani   Corrected huge pl...
893
                    xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
894
895
896
897
                 
            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
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
898
                          
67bd858a   Ilyes Choubani   Replication of th...
899
                        FOR i=0L,Ngrains-1 DO BEGIN
1355825c   Ilyes Choubani   General update
900
                            
5f04fa07   Ilyes Choubani   general update
901
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
902
                            
5f04fa07   Ilyes Choubani   general update
903
904
905
                            if countneq ne 0 then begin 
                                vecfin = st.polsed.(i+1)*0.0
                                
07372e26   Ilyes Choubani   Corrected huge pl...
906
907
                                vecfin[testneq] = ((st.polsed.(i+1))[testneq])*fact[testneq]/extra_spec[testneq];(st.sed.em_tot)[testneq];;(st.sed.em_tot)[testneq];spec[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
                                
5f04fa07   Ilyes Choubani   general update
908
909
                                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
910
911
912
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
913
                         
1355825c   Ilyes Choubani   General update
914
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
915
                            
3c479f24   Ilyes Choubani   Allowing to fix p...
916
917
918
919
920
921
922
923
924
                            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
925
                            
1355825c   Ilyes Choubani   General update
926
927
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
928
929
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
930
931
932
933
934
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
935
                             xx=((*(*!dustem_data).polfrac).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
936
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
937
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
938
939
940
941
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
942
                             xx=((*(*!dustem_data).polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
943
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
944
945
946
947
948
                             cgoplot,xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
949
                         cgoplot,st.polsed.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs               
1355825c   Ilyes Choubani   General update
950
951
952
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
953

1355825c   Ilyes Choubani   General update
954
                        ;Spectrum points are treated before for plotting reasons. 
9cb38725   Ilyes Choubani   Fixed tests relat...
955
                        
1355825c   Ilyes Choubani   General update
956
957
958
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
959
                            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
960
961
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
962
963
                            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'
1355825c   Ilyes Choubani   General update
964
965
966
967
968
969

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
970
971
                            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
972
973
974
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
975
976
                            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'
1355825c   Ilyes Choubani   General update
977
978
979
980
981
                            
                        endif
                        
                        
                        
07372e26   Ilyes Choubani   Corrected huge pl...
982
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
983
984
985
986
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
987
                        match2,((*(*!dustem_data).polfrac).wav),((*(*!dustem_show).polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
74103816   Ilyes Choubani   small update
988
                        idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
1355825c   Ilyes Choubani   General update
989
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
990
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
991
992
                        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
993
994
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
995
996
997
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
998
                                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
999
1000
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1001
1002
                                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'
1355825c   Ilyes Choubani   General update
1003
1004
1005
1006
1007
1008
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1009
                                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
1010
1011
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1012
1013
                                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'
1355825c   Ilyes Choubani   General update
1014
1015
1016
1017
1018
1019
1020
1021
1022
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse 
b5314324   Ilyes Choubani   updating the plot...
1023
1024
1025
        
        end
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
1026
        'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
96a72c8b   Ilyes Choubani   seperating xrange...
1027
            
4b745987   Ilyes Choubani   minor update
1028
            IF ct_x NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
1029
            
4b745987   Ilyes Choubani   minor update
1030
1031
1032
1033
                xr=xr_x
                yr=yr_x
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
1034
1035
            idx_filt=where((*(*!dustem_data).fpolext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).fpolext).filt_names EQ 'SPECTRUM',ct_spec)
18e4331f   Ilyes Choubani   general update (f...
1036
            
18e4331f   Ilyes Choubani   general update (f...
1037
1038
1039
1040
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
94c4dffa   Ilyes Choubani   update + fixes fo...
1041
1042
                    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,10.00],/ylog,psym=8,syms=0.8  
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}/\tau_{EXT} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
1043
1044
1045
1046
1047
                 
            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
                        
67bd858a   Ilyes Choubani   Replication of th...
1048
                        
18e4331f   Ilyes Choubani   general update (f...
1049
                        FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1050
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1051
1052
1053
                            vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
                            
                            testneq = where(vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
1054
1055
                            
                            if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
1056
                                vecfin = vecto*0.0
5f04fa07   Ilyes Choubani   general update
1057
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1058
                                vecfin[testneq] = (vecto[testneq])*(*!dustem_HCD)/1.0e21/extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
67bd858a   Ilyes Choubani   Replication of th...
1059
                                 
94c4dffa   Ilyes Choubani   update + fixes fo...
1060
                                cgoplot,1/st.polext.wav,vecfin*100,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=[1.00E-04,10.00]
67bd858a   Ilyes Choubani   Replication of th...
1061
                            endif   
18e4331f   Ilyes Choubani   general update (f...
1062
                        ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
1063
1064
1065
                       
                        ;Plotting of the plugins. 
                         
18e4331f   Ilyes Choubani   general update (f...
1066
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1067
1068
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
1069
1070
1071
1072
                            
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                    vecfin = st.polext.ext_tot*0.0
                                    vecfin[testneq] = sqrt((((*(*!dustem_plugin).(i).spec)[*,1])^2)[testneq]+(((*(*!dustem_plugin).(i).spec)[*,2])^2)[testneq])/((*(*!dustem_plugin).(i).spec)[*,0])[testneq]        
afde94a3   Ilyes Choubani   general update
1073
                                    cgoplot,1/st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
1074
                                
3c479f24   Ilyes Choubani   Allowing to fix p...
1075
                                ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1076
1077
                            endif
                            
18e4331f   Ilyes Choubani   general update (f...
1078
                        endfor
67bd858a   Ilyes Choubani   Replication of th...
1079
                       
67bd858a   Ilyes Choubani   Replication of th...
1080
                       
18e4331f   Ilyes Choubani   general update (f...
1081
1082
1083
1084
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
1085
                             xx=((*(*!dustem_data).fpolext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1086
                             yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
1087
                             cgoplot,1/xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
1088
1089
1090
1091
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1092
                             xx=((*(*!dustem_data).fpolext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1093
                             yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
1094
                             cgoplot,1/xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
1095
1096
1097
1098
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
1099
                         cgoplot,1/st.polext.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
67bd858a   Ilyes Choubani   Replication of th...
1100
                                        
18e4331f   Ilyes Choubani   general update (f...
1101
1102
                                
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1103
                         
18e4331f   Ilyes Choubani   general update (f...
1104
1105
                        
                        ;Spectrum points are treated before for plotting reasons. 
67bd858a   Ilyes Choubani   Replication of th...
1106
                        
18e4331f   Ilyes Choubani   general update (f...
1107
1108
1109
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
1110
                            cgplot,1/((*(*!dustem_data).fpolext).wav)(idx_spec),((*(*!dustem_data).fpolext).values)(idx_spec)*100,/xlog,/ylog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[1.00E-04,10.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
18e4331f   Ilyes Choubani   general update (f...
1111
1112
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
1113
1114
                            rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_spec),(((*(*!dustem_data).fpolext).values)(idx_spec)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_spec)+rms)*100,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
1115
1116
1117
1118
1119
1120

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
1121
1122
                            if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),((*(*!dustem_data).fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[1.00E-04,10.00],/xlog,/ylog else $;,ytickformat='dstmwrp_exp'
                                cgplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),((*(*!dustem_data).fpolext).values)(idx_filt)*100,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[1.00E-04,10.00],/xlog,/ylog;,ytickformat='dstmwrp_exp'
18e4331f   Ilyes Choubani   general update (f...
1123
1124
1125
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
1126
1127
                            rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),(((*(*!dustem_data).fpolext).values)(idx_filt)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_filt)+rms)*100,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
1128
1129
1130
1131
1132
                            
                        endif
                        
                        
                        
94c4dffa   Ilyes Choubani   update + fixes fo...
1133
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}/\tau_{EXT} (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1134
1135
1136
1137
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
1138
                        match2,((*(*!dustem_data).fpolext).wav),((*(*!dustem_show).fpolext).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
74103816   Ilyes Choubani   small update
1139
                        idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide; 
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1140
                        
67bd858a   Ilyes Choubani   Replication of th...
1141
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
1142
1143
                        idx_filt_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
67bd858a   Ilyes Choubani   Replication of th...
1144
1145
1146
1147
1148
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
1149
                                cgplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_spec_hdn),(((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[1.00E-04,10.00],psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
1150
1151
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1152
1153
                                rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1154
1155
1156
1157
1158
1159
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1160
                                cgplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_filt_hdn),(((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)*100,pos=position,/xlog,/ylog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[1.00E-04,10.00],psym=8,syms=0.8                                           
67bd858a   Ilyes Choubani   Replication of th...
1161
1162
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1163
1164
                                rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse
        
        
        END
        
        
     
        'PSI_EM': begin ;will be copying code from qsed and hopefully it will work. NB: THIS IS FALSE . YOU DO NOT NEED A LOGARITHMIC AXIS
            
4b745987   Ilyes Choubani   minor update
1182
            IF ct_m NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
1183
            
4b745987   Ilyes Choubani   minor update
1184
1185
1186
1187
                xr=xr_m 
                yr=yr_m
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
1188
1189
            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)
67bd858a   Ilyes Choubani   Replication of th...
1190
1191
1192
1193
1194
1195
1196
            
            ;#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  
07372e26   Ilyes Choubani   Corrected huge pl...
1197
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1198
1199
1200
1201
1202
                 
            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
                        
67bd858a   Ilyes Choubani   Replication of th...
1203
1204
1205
1206
1207
1208
1209
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
                            if countneq ne 0 then begin
                                vecfin = st.polsed.(i+1)*0.0
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1210
                                vecfin[testneq] = ((st.polsed.(i+1))[testneq])/(st.sed.(i+1))[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'. 
67bd858a   Ilyes Choubani   Replication of th...
1211
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1212
1213
                                ;*****NB: These two lines will have to be modified if the polarization angle varies with the dust species and/or with wavelength
                                polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
f2caf3f1   Ilyes Choubani   Debugging some er...
1214
1215
1216
1217
1218
1219
1220
                                
                                ;You can replace the -0 values by 0 in order to avoid atan giving wrong values 
                                testnzero = where(specqgrain EQ -0., ct_nzero)
                                if ct_nzero ne 0 then specqgrain[testnzero] = 0
                                
                                cgoplot,st.polsed.wav,0.5*atan(specugrain, specqgrain)/!dtor,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
                                ;cgoplot,st.polsed.wav,replicate(!dustem_psi,n_elements(vecfin)),pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
0068116a   Ilyes Choubani   General update + ...
1221
                                
67bd858a   Ilyes Choubani   Replication of th...
1222
1223
                            endif 
                        ENDFOR
1bc09467   Ilyes Choubani   fixed issue with ...
1224
                                                                        
67bd858a   Ilyes Choubani   Replication of th...
1225
1226
1227
1228
1229
1230
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
d7a2d8eb   Ilyes Choubani   typo
1231
                                    cgoplot,st.polsed.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]   
67bd858a   Ilyes Choubani   Replication of th...
1232
1233
1234
                                ENDIF
                            ENDIF
                        endfor
1bc09467   Ilyes Choubani   fixed issue with ...
1235
                        
67bd858a   Ilyes Choubani   Replication of th...
1236
1237
1238
1239
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
1240
                             xx=((*(*!dustem_data).psi_em).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1241
1242
1243
                             yy=dustem_interp[idx_spec]
                             cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                         ENDIF
1bc09467   Ilyes Choubani   fixed issue with ...
1244
                         
67bd858a   Ilyes Choubani   Replication of th...
1245
1246
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1247
                             xx=((*(*!dustem_data).psi_em).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1248
1249
1250
                             yy=dustem_interp[idx_filt]
                             cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
1bc09467   Ilyes Choubani   fixed issue with ...
1251
                         
67bd858a   Ilyes Choubani   Replication of th...
1252
1253
1254
1255
                         
                         ;Plotting of the total dust emission spectrum
                         ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
                         cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
1bc09467   Ilyes Choubani   fixed issue with ...
1256
                                
67bd858a   Ilyes Choubani   Replication of th...
1257
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1258
                         
67bd858a   Ilyes Choubani   Replication of th...
1259
1260
1261
1262
1263
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
1264
                            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'                
67bd858a   Ilyes Choubani   Replication of th...
1265
1266
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
1267
1268
                            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'
67bd858a   Ilyes Choubani   Replication of th...
1269
1270
1271
1272
1273
1274

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
1275
1276
                            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'
67bd858a   Ilyes Choubani   Replication of th...
1277
1278
1279
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
1280
1281
                            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'
67bd858a   Ilyes Choubani   Replication of th...
1282
1283
1284
1285
1286
                            
                        endif
                        
                        
                        
07372e26   Ilyes Choubani   Corrected huge pl...
1287
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1288
1289
1290
1291
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
1292
                        match2,((*(*!dustem_data).psi_em).wav),((*(*!dustem_show).psi_em).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
74103816   Ilyes Choubani   small update
1293
                        idx_rmv_psi_em=where(fit_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
1294
1295
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
1296
1297
                        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)
67bd858a   Ilyes Choubani   Replication of th...
1298
1299
1300
1301
1302
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
1303
                                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
67bd858a   Ilyes Choubani   Replication of th...
1304
1305
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1306
1307
                                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'
67bd858a   Ilyes Choubani   Replication of th...
1308
1309
1310
1311
1312
1313
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1314
                                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                                           
67bd858a   Ilyes Choubani   Replication of th...
1315
1316
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1317
1318
                                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'
67bd858a   Ilyes Choubani   Replication of th...
1319
1320
1321
1322
                                 
                            endif 
                                                           
                        endif 
67bd858a   Ilyes Choubani   Replication of th...
1323
1324
                    
                    endelse 
4b745987   Ilyes Choubani   minor update
1325
               
67bd858a   Ilyes Choubani   Replication of th...
1326
            endelse 
67bd858a   Ilyes Choubani   Replication of th...
1327
1328
1329
1330
1331
           
           
        end
        
        'PSI_EXT': begin ;MODIFYING THIS NOW - You should write a plugin for the modification of polarized extinction so that !dustem_psi_ext is different than !dustem_psi. 
96a72c8b   Ilyes Choubani   seperating xrange...
1332
1333
            
            
4b745987   Ilyes Choubani   minor update
1334
1335
1336
1337
            IF ct_x NE 0 then begin
                xr=xr_x 
                yr=yr_x
            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1338
        
0068116a   Ilyes Choubani   General update + ...
1339
1340
            idx_filt=where((*(*!dustem_data).psi_ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).psi_ext).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
1341
1342
1343
1344
1345
1346
1347
            
            ;#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  
f2caf3f1   Ilyes Choubani   Debugging some er...
1348
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1349
1350
1351
1352
1353
1354
1355
1356
                 
            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
4b745987   Ilyes Choubani   minor update
1357
                        
67bd858a   Ilyes Choubani   Replication of th...
1358
                        FOR i=0L,Ngrains-1 DO BEGIN
4b745987   Ilyes Choubani   minor update
1359
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1360
1361
1362
                            vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
                            vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
                            testneq = where(vecto ne 0,countneq)
f2caf3f1   Ilyes Choubani   Debugging some er...
1363
1364
1365
1366
                            
                            ;testing whether the polext values contain negative ones
                            testpos = where(vecto LT 0, countpos)
                            IF countpos NE 0 THEN vecto[testpos] = 0
4b745987   Ilyes Choubani   minor update
1367
                              
67bd858a   Ilyes Choubani   Replication of th...
1368
                            if countneq ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
1369
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1370
                                vecfin = vecto*0.0
67bd858a   Ilyes Choubani   Replication of th...
1371
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1372
                                vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];spec[testneq] ;removed multiplication by 'fact'. 
67bd858a   Ilyes Choubani   Replication of th...
1373
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1374
1375
                                polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                 
afde94a3   Ilyes Choubani   general update
1376
                                cgoplot,1/st.polext.wav,0.5*atan(specugrain,specqgrain)/degtorad,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
67bd858a   Ilyes Choubani   Replication of th...
1377
1378
                            endif 
                        ENDFOR
f2caf3f1   Ilyes Choubani   Debugging some er...
1379
                                                                              
67bd858a   Ilyes Choubani   Replication of th...
1380
1381
1382
1383
1384
1385
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                    ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
afde94a3   Ilyes Choubani   general update
1386
                                    cgoplot_mlog,1/st.polext.wav,0.5*atan((*(*!dustem_plugin).(i).spec)[*,2],(*(*!dustem_plugin).(i).spec)[*,1])/degtorad,pos=position,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]   
67bd858a   Ilyes Choubani   Replication of th...
1387
1388
1389
1390
1391
1392
1393
1394
                                ENDIF
                            ENDIF
                        endfor
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
1395
                             xx=((*(*!dustem_data).psi_ext).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1396
                             yy=dustem_interp[idx_spec]
1bc09467   Ilyes Choubani   fixed issue with ...
1397
                             cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
1398
1399
1400
1401
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1402
                             xx=((*(*!dustem_data).psi_ext).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1403
                             yy=dustem_interp[idx_filt]
1bc09467   Ilyes Choubani   fixed issue with ...
1404
                             cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
1405
1406
                         ENDIF
                         
67bd858a   Ilyes Choubani   Replication of th...
1407
1408
                         ;Plotting of the total dust emission spectrum
                         ;cgoplot,st.sed.wav,0.5*atan(specu,specq)/degtorad,pos=position,noerase=1,/xlog,/ys,/xs
1bc09467   Ilyes Choubani   fixed issue with ...
1409
                         cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
67bd858a   Ilyes Choubani   Replication of th...
1410
1411
1412
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
67bd858a   Ilyes Choubani   Replication of th...
1413
1414
1415
1416
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
1417
                            cgplot,1/((*(*!dustem_data).psi_ext).wav)(idx_spec),((*(*!dustem_data).psi_ext).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
67bd858a   Ilyes Choubani   Replication of th...
1418
1419
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
1420
1421
                            rms=3.*((*(*!dustem_data).psi_ext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).psi_ext).wav)(idx_spec),((*(*!dustem_data).psi_ext).values)(idx_spec)-rms,((*(*!dustem_data).psi_ext).values)(idx_spec)+rms,color='Powder Blue'
67bd858a   Ilyes Choubani   Replication of th...
1422
1423
1424
1425
1426
1427

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
1428
1429
                            if ct_spec ne 0 then cgoplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[-90.00,90.00],/xlog else $;,ytickformat='dstmwrp_exp'
                                cgplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[-90.00,90.00],/xlog;,ytickformat='dstmwrp_exp'
67bd858a   Ilyes Choubani   Replication of th...
1430
1431
1432
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
1433
1434
                            rms=3.*((*(*!dustem_data).psi_ext).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
                            cgerrplot,1/((*(*!dustem_data).psi_ext).wav)(idx_filt),((*(*!dustem_data).psi_ext).values)(idx_filt)-rms,((*(*!dustem_data).psi_ext).values)(idx_filt)+rms,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
1435
1436
1437
1438
1439
                            
                        endif
                        
                        
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
1440
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1441
1442
1443
1444
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
1445
                        match2,((*(*!dustem_data).psi_ext).wav),((*(*!dustem_show).psi_ext).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
74103816   Ilyes Choubani   small update
1446
                        idx_rmv_psi_em=where(fit_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
1447
1448
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
1449
1450
                        idx_filt_hdn = where(((*(*!dustem_show).psi_ext).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn) ;keeping psi_em notation for counters...
                        idx_spec_hdn = where(((*(*!dustem_show).psi_ext).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
67bd858a   Ilyes Choubani   Replication of th...
1451
1452
1453
1454
1455
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
1456
                                cgplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_spec_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
1457
1458
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1459
1460
                                rms=3.*(((*(*!dustem_show).psi_ext).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_spec_hdn)-rms,(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_spec_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1461
1462
1463
1464
1465
1466
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1467
                                cgplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_filt_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8                                           
67bd858a   Ilyes Choubani   Replication of th...
1468
1469
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1470
1471
                                rms=3.*(((*(*!dustem_show).psi_ext).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).psi_ext).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_filt_hdn)-rms,(((*(*!dustem_show).psi_ext).values)[idx_rmv_psi_em])(idx_filt_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
                                 
                            endif 
                                                           
                        endif 
                        
                    endelse 
                
            endelse 
        
        end
        
        'QSED': begin ; THE ONE I WILL BE WORKING ON
96a72c8b   Ilyes Choubani   seperating xrange...
1484
            
4b745987   Ilyes Choubani   minor update
1485
1486
1487
1488
1489
            IF ct_m NE 0 then begin
            
                xr=xr_m
                yr=yr_m
            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1490
            
1bc09467   Ilyes Choubani   fixed issue with ...
1491
1492
1493
1494
1495
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
1496
1497
            varvar=where((*(*!dustem_data).qsed).values GT 0, testpstv)
            varvar=where((*(*!dustem_data).qsed).values LT 0, testngtv)
67bd858a   Ilyes Choubani   Replication of th...
1498
            
07372e26   Ilyes Choubani   Corrected huge pl...
1499
            
0068116a   Ilyes Choubani   General update + ...
1500
1501
            idx_filt=where((*(*!dustem_data).qsed).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*(*!dustem_data).qsed).filt_names EQ 'SPECTRUM' , ct_spec)
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1502
           
67bd858a   Ilyes Choubani   Replication of th...
1503
            ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
1504
            match2,((*(*!dustem_data).qsed).wav),((*(*!dustem_show).qsed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
1505
            idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
1506
            
67bd858a   Ilyes Choubani   Replication of th...
1507
1508
1509
1510
1511
1512
1513
1514
1515
            
            ;#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 = ''
1bc09467   Ilyes Choubani   fixed issue with ...
1516
                    cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1537
                            xx=((*(*!dustem_data).qsed).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1538
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
1539
                            rms=3.*((*(*!dustem_data).qsed).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
1540
1541
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1542
1543
                                cgoplot,xx[indzero],(((*(*!dustem_data).qsed).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                                cgerrplot,(((*(*!dustem_data).qsed).wav)(idx_spec))[indzero],((((*(*!dustem_data).qsed).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qsed).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
f2caf3f1   Ilyes Choubani   Debugging some er...
1544
                            ENDIF 
67bd858a   Ilyes Choubani   Replication of th...
1545
1546
1547
1548
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
0068116a   Ilyes Choubani   General update + ...
1549
                            xx=((*(*!dustem_data).qsed).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1550
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
1551
                            rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
1552
1553
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1554
1555
                                cgoplot,xx[indzero],(((*(*!dustem_data).qsed).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                                cgerrplot,(((*(*!dustem_data).qsed).wav)(idx_filt))[indzero],((((*(*!dustem_data).qsed).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qsed).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue' 
f2caf3f1   Ilyes Choubani   Debugging some er...
1556
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1557
1558
1559
1560
1561
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
afde94a3   Ilyes Choubani   general update
1562
                        ;stitching an array of 1000 more points (up to 1E7) after the end of the dustem wavelength array (dim=800 elements)
1bc09467   Ilyes Choubani   fixed issue with ...
1563
                        
67bd858a   Ilyes Choubani   Replication of th...
1564
1565
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1566
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot - STOPPED HERE FOR QSED
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        ;stop
                        if keyword_set(positive_only) then begin
     
                            if testpstv ne 0 then begin
                                ;stop
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    ;stop
                                    if countneq ne 0 then begin 
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
1587
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
67bd858a   Ilyes Choubani   Replication of th...
1588
                                        
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1589
1590
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                                                            
67bd858a   Ilyes Choubani   Replication of th...
1591
                                        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
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1592
                                        
67bd858a   Ilyes Choubani   Replication of th...
1593
                                    endif
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1594
                                    
67bd858a   Ilyes Choubani   Replication of th...
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                         
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1609
                                    xx=((*(*!dustem_data).qsed).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1610
                                    yy=dustem_interp[idx_spec]
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1611
                                    
67bd858a   Ilyes Choubani   Replication of th...
1612
1613
1614
1615
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1616
                                    xx=((*(*!dustem_data).qsed).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1617
                                    yy=dustem_interp[idx_filt]
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1618
                                    
67bd858a   Ilyes Choubani   Replication of th...
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                        
                        ;stop
                        if keyword_set(negative_only) then begin
                            ;stop     
                            if testngtv ne 0 then begin
                            
                                ;stop    
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
0068116a   Ilyes Choubani   General update + ...
1637
                                    
67bd858a   Ilyes Choubani   Replication of th...
1638
1639
1640
1641
1642
                                    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
07372e26   Ilyes Choubani   Corrected huge pl...
1643
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
67bd858a   Ilyes Choubani   Replication of th...
1644
1645
1646
1647
1648
                                        ;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
0068116a   Ilyes Choubani   General update + ...
1649
                                        
67bd858a   Ilyes Choubani   Replication of th...
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
                                    endif 
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
     
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                        
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1666
                                    xx=((*(*!dustem_data).qsed).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1667
                                    yy=dustem_interp[idx_spec]
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1668
                                    
67bd858a   Ilyes Choubani   Replication of th...
1669
1670
1671
1672
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1673
                                    xx=((*(*!dustem_data).qsed).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1674
                                    yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                ;Plotting of the total dust emission spectrum
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
                        ;stop
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1688
                        
67bd858a   Ilyes Choubani   Replication of th...
1689
1690
1691
1692
                        xyouts,pospltxt[0],pospltxt[1],textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            
                        ;Locating the hidden spectrum and filter data points     
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1693
                       
74103816   Ilyes Choubani   small update
1694
                        if ct_hdnpts NE 0 then begin
0068116a   Ilyes Choubani   General update + ...
1695
1696
1697
1698
                            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)
67bd858a   Ilyes Choubani   Replication of th...
1699
1700
1701
1702
1703
1704
1705
                        endif
                        
                        
                        if keyword_set(positive_only) then begin
                            ;stop
                            if testpstv ne 0 then begin
                            ;stop
74103816   Ilyes Choubani   small update
1706
1707
1708
1709
1710
                                plotsym, 0
                                
                                
                                if ct_spec ne 0 then begin
                                
0068116a   Ilyes Choubani   General update + ...
1711
1712
1713
1714
                                    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)'     
74103816   Ilyes Choubani   small update
1715
1716
1717
1718
1719
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
1720
1721
1722
1723
1724
                                    rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)';,ytickformat='(A1)'
                                    if ct_spec eq 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    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)'
74103816   Ilyes Choubani   small update
1725
1726
                                        
                                endif
67bd858a   Ilyes Choubani   Replication of th...
1727
                                
74103816   Ilyes Choubani   small update
1728
1729
                                
                                if ct_hdnpts NE 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
1730
1731
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
1732
1733
1734
                                        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.
67bd858a   Ilyes Choubani   Replication of th...
1735
                                        
74103816   Ilyes Choubani   small update
1736
1737
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)'  ;,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
1738
1739
1740
1741
1742
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
1743
1744
1745
                                        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.
67bd858a   Ilyes Choubani   Replication of th...
1746
                                        
74103816   Ilyes Choubani   small update
1747
1748
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)'  ;,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
1749
1750
1751
1752
1753
1754
                                    
                                    endif
                                    
                                endif
                                
                                
74103816   Ilyes Choubani   small update
1755
                            endif else begin
67bd858a   Ilyes Choubani   Replication of th...
1756
                                
67bd858a   Ilyes Choubani   Replication of th...
1757
                                
1bc09467   Ilyes Choubani   fixed issue with ...
1758
                            
0068116a   Ilyes Choubani   General update + ...
1759
                                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)'
1bc09467   Ilyes Choubani   fixed issue with ...
1760
                                    
67bd858a   Ilyes Choubani   Replication of th...
1761
                                
0068116a   Ilyes Choubani   General update + ...
1762
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-((*(*!dustem_data).qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
f2caf3f1   Ilyes Choubani   Debugging some er...
1763
                                   
74103816   Ilyes Choubani   small update
1764
1765
1766
1767
                                
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
1768
1769
1770
                                        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.
74103816   Ilyes Choubani   small update
1771
1772
1773
1774
1775
1776
1777
1778
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)'  ;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
1779
1780
1781
                                        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.
74103816   Ilyes Choubani   small update
1782
1783
1784
1785
1786
1787
1788
1789
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)'  ;,psym=8,syms=0.8
                                    
                                    endif
                                    
                                endif
                                
67bd858a   Ilyes Choubani   Replication of th...
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
                            endelse                           
                        
                        endif 
                        
                        
                        if keyword_set(negative_only) then begin
                            
                            if testngtv ne 0 then begin
                                 
                                 ;plotsym, 0
67bd858a   Ilyes Choubani   Replication of th...
1800
                                
67bd858a   Ilyes Choubani   Replication of th...
1801
1802
                                 if ct_spec ne 0 then begin
                                 
0068116a   Ilyes Choubani   General update + ...
1803
1804
1805
1806
                                     rms=3.*((*(*!dustem_data).qsed).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),-((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ; if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                         dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
1807
                                     ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
1808
                                     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     
67bd858a   Ilyes Choubani   Replication of th...
1809
1810
1811
1812
1813
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
1814
1815
1816
1817
1818
                                     rms=3.*((*(*!dustem_data).qsed).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                     if ct_spec eq 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
67bd858a   Ilyes Choubani   Replication of th...
1819
1820
                                     ;endelse ;,ytickformat='(A1)'
                                     
0068116a   Ilyes Choubani   General update + ...
1821
                                     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)'
67bd858a   Ilyes Choubani   Replication of th...
1822
1823
                                         
                                 endif 
74103816   Ilyes Choubani   small update
1824
1825
1826
1827
                                 
                                 if ct_hdnpts NE 0 then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
1828
1829
1830
                                         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.
74103816   Ilyes Choubani   small update
1831
1832
1833
1834
1835
1836
1837
1838
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
1839
1840
1841
                                         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.
74103816   Ilyes Choubani   small update
1842
1843
1844
1845
1846
1847
1848
1849
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr ,ytickformat='(A1)'  
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                     
                                     endif
                                
                                 endif

67bd858a   Ilyes Choubani   Replication of th...
1850
1851
                            
                            endif else begin
74103816   Ilyes Choubani   small update
1852
1853
                                
                                
0068116a   Ilyes Choubani   General update + ...
1854
                                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)'
1bc09467   Ilyes Choubani   fixed issue with ...
1855
                                    
e0d00de0   Ilyes Choubani   removing stops
1856
                                
0068116a   Ilyes Choubani   General update + ...
1857
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-((*(*!dustem_data).qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
1858
1859
1860
1861
                                
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
1862
1863
1864
                                        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.
74103816   Ilyes Choubani   small update
1865
1866
1867
1868
1869
1870
1871
1872
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
1873
1874
1875
                                        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.
74103816   Ilyes Choubani   small update
1876
1877
1878
1879
1880
1881
1882
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr ,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    endif
f2caf3f1   Ilyes Choubani   Debugging some er...
1883
                                  
67bd858a   Ilyes Choubani   Replication of th...
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
                            endelse
                            ;stop
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

        
        END
        
        'USED': begin
96a72c8b   Ilyes Choubani   seperating xrange...
1901
            
4b745987   Ilyes Choubani   minor update
1902
1903
1904
1905
1906
1907
            IF ct_m NE 0 then begin
            
                xr=xr_m
                yr=yr_m
                
            ENDIF
96a72c8b   Ilyes Choubani   seperating xrange...
1908
            
1bc09467   Ilyes Choubani   fixed issue with ...
1909
1910
1911
1912
1913
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
        
67bd858a   Ilyes Choubani   Replication of th...
1914
1915
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
0068116a   Ilyes Choubani   General update + ...
1916
1917
            varvar=where((*(*!dustem_data).used).values LT 0, testngtv)
            varvar=where((*(*!dustem_data).used).values GT 0, testpstv)
67bd858a   Ilyes Choubani   Replication of th...
1918
            ;stop
0068116a   Ilyes Choubani   General update + ...
1919
1920
            idx_filt=where((*(*!dustem_data).used).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*(*!dustem_data).used).filt_names EQ 'SPECTRUM' , ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
1921
            
67bd858a   Ilyes Choubani   Replication of th...
1922
            ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
1923
            match2,((*(*!dustem_data).used).wav),((*(*!dustem_show).used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
1924
            idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
1925
            
67bd858a   Ilyes Choubani   Replication of th...
1926
1927
1928
1929
1930
1931
1932
1933
            ;#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 = ''
1bc09467   Ilyes Choubani   fixed issue with ...
1934
                    cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1955
                            xx=((*(*!dustem_data).used).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1956
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
1957
                            rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
1958
1959
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1960
1961
                                cgoplot,xx[indzero],(((*(*!dustem_data).used).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                                cgerrplot,(((*(*!dustem_data).used).wav)(idx_spec))[indzero],((((*(*!dustem_data).used).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).used).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
f2caf3f1   Ilyes Choubani   Debugging some er...
1962
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1963
1964
1965
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1966
                            
0068116a   Ilyes Choubani   General update + ...
1967
                            xx=((*(*!dustem_data).used).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1968
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
1969
                            rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
1970
1971
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1972
1973
                                cgoplot,xx[indzero],(((*(*!dustem_data).used).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                                cgerrplot,(((*(*!dustem_data).used).wav)(idx_filt))[indzero],((((*(*!dustem_data).used).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).used).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue' 
f2caf3f1   Ilyes Choubani   Debugging some er...
1974
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1975
1976
1977
1978
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
1bc09467   Ilyes Choubani   fixed issue with ...
1979
                        
67bd858a   Ilyes Choubani   Replication of th...
1980
1981
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1982
                        cgplot,vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
                        xyouts,pospltxt-[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot - STOPPED HERE FOR used
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        if keyword_set(positive_only) then begin
     
                            if testpstv ne 0 then begin
                                ;stop
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    
                                    if countneq ne 0 then begin 
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        
07372e26   Ilyes Choubani   Corrected huge pl...
2003
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
67bd858a   Ilyes Choubani   Replication of th...
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
                                            
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
                                        dustem_plot_mlog,st.polsed.wav,specugrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                    endif 
                                    ;stop
                                ENDFOR
                                ;stop
                                for i=0L,n_plgns-1 do begin
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2018
                                            
67bd858a   Ilyes Choubani   Replication of th...
2019
2020
2021
2022
2023
2024
2025
2026
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                        
                                    ENDIF
                                    
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2027
                                    xx=((*(*!dustem_data).used).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2028
2029
2030
2031
2032
2033
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2034
                                    xx=((*(*!dustem_data).used).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                        
                        
                        if keyword_set(negative_only) then begin
     
                            if testngtv ne 0 then begin
                            
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    if countneq ne 0 then begin
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        
07372e26   Ilyes Choubani   Corrected huge pl...
2058
                                        vecfin[testneq] = ((st.polsed.(i+1))[testneq])/((st.sed.(i+1))[testneq]);extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
67bd858a   Ilyes Choubani   Replication of th...
2059
2060
                                        
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2061
                                         
67bd858a   Ilyes Choubani   Replication of th...
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
                                        dustem_plot_mlog,st.polsed.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                    endif    
                                ENDFOR
                                ;Plotting of the plugins
                                FOR i=0L,n_plgns-1 do begin
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                    ENDIF
                                ENDFOR
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2077
                                    xx=((*(*!dustem_data).used).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2078
2079
2080
2081
2082
2083
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2084
                                    xx=((*(*!dustem_data).used).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                
                                ;Plotting of the total dust emission spectrum
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.
                        ;stop
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
                        xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                        
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2107
2108
                        
                        
74103816   Ilyes Choubani   small update
2109
                        if ct_hdnpts NE 0 then begin
0068116a   Ilyes Choubani   General update + ...
2110
2111
2112
2113
                            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)
67bd858a   Ilyes Choubani   Replication of th...
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
                        endif
                        ;stop
                        
                        if keyword_set(positive_only) then begin
                            ;stop
                            if testpstv ne 0 then begin
                            ;stop
                                plotsym, 0
                                
                                 
                                if ct_spec ne 0 then begin
                                
0068116a   Ilyes Choubani   General update + ...
2126
2127
2128
2129
                                    rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
                                    ;dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),-((*(*!dustem_data).used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ;if ct_spec_hdn_pstv ne 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),((*(*!dustem_data).used).values)(idx_spec),ppositions=position,charsize=1.15,/overplot,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                        dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),((*(*!dustem_data).used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
67bd858a   Ilyes Choubani   Replication of th...
2130
                                    ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
2131
                                    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
67bd858a   Ilyes Choubani   Replication of th...
2132
2133
2134
2135
2136
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2137
2138
2139
2140
2141
                                    rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),-1.*((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ;if ct_filt_hdn_pstv ne 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),/overplot,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                    if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                    if ct_spec eq 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
67bd858a   Ilyes Choubani   Replication of th...
2142
                                    ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
2143
                                    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
67bd858a   Ilyes Choubani   Replication of th...
2144
2145
2146
                                        
                                endif
                                
74103816   Ilyes Choubani   small update
2147
                                if ct_hdnpts NE 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2148
2149
2150
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        ;stop
0068116a   Ilyes Choubani   General update + ...
2151
2152
2153
                                        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.
67bd858a   Ilyes Choubani   Replication of th...
2154
                                        
74103816   Ilyes Choubani   small update
2155
2156
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
2157
2158
2159
2160
2161
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                        ;stop
0068116a   Ilyes Choubani   General update + ...
2162
2163
2164
                                        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.
67bd858a   Ilyes Choubani   Replication of th...
2165
                                        
74103816   Ilyes Choubani   small update
2166
2167
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)' 
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
2168
2169
2170
2171
                                    
                                    endif
                                endif   
                            endif else begin
74103816   Ilyes Choubani   small update
2172
                                
0068116a   Ilyes Choubani   General update + ...
2173
                                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)'
1bc09467   Ilyes Choubani   fixed issue with ...
2174
2175
                                    
                                
0068116a   Ilyes Choubani   General update + ...
2176
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),-((*(*!dustem_data).used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
f2caf3f1   Ilyes Choubani   Debugging some er...
2177
                                
74103816   Ilyes Choubani   small update
2178
2179
2180
2181
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        ;stop
0068116a   Ilyes Choubani   General update + ...
2182
2183
2184
                                        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.
74103816   Ilyes Choubani   small update
2185
2186
2187
2188
2189
2190
2191
2192
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                        ;stop
0068116a   Ilyes Choubani   General update + ...
2193
2194
2195
                                        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.
74103816   Ilyes Choubani   small update
2196
2197
2198
2199
2200
2201
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)' 
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif
                                endif   
67bd858a   Ilyes Choubani   Replication of th...
2202
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
2203
                        
67bd858a   Ilyes Choubani   Replication of th...
2204
                        endif 
18e4331f   Ilyes Choubani   general update (f...
2205
                        
67bd858a   Ilyes Choubani   Replication of th...
2206
                        if keyword_set(negative_only) then begin
18e4331f   Ilyes Choubani   general update (f...
2207
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2208
2209
2210
2211
2212
2213
2214
                            if testngtv ne 0 then begin
                                 
                                 plotsym, 0
                                 
                                 
                                 if ct_spec ne 0 then begin
                                 
0068116a   Ilyes Choubani   General update + ...
2215
2216
2217
2218
                                     rms=3.*((*(*!dustem_data).used).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),-((*(*!dustem_data).used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),((*(*!dustem_data).used).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_spec),((*(*!dustem_data).used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2219
                                     ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
2220
                                     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)'     
67bd858a   Ilyes Choubani   Replication of th...
2221
2222
2223
2224
2225
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
2226
2227
2228
                                     rms=3.*((*(*!dustem_data).used).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),-1.*((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
74103816   Ilyes Choubani   small update
2229
                                     
0068116a   Ilyes Choubani   General update + ...
2230
2231
                                     if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                     if ct_spec eq 0 then dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),((*(*!dustem_data).used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2232
2233
                                     ;endelse ;,ytickformat='(A1)'
                                     
0068116a   Ilyes Choubani   General update + ...
2234
                                     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)'
67bd858a   Ilyes Choubani   Replication of th...
2235
2236
2237
                                         
                                 endif
                                 
74103816   Ilyes Choubani   small update
2238
                                 if ct_hdnpts NE 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2239
2240
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2241
2242
2243
                                         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.
67bd858a   Ilyes Choubani   Replication of th...
2244
                                         
74103816   Ilyes Choubani   small update
2245
2246
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
2247
2248
2249
2250
2251
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
2252
2253
2254
                                         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.
67bd858a   Ilyes Choubani   Replication of th...
2255
                                         
74103816   Ilyes Choubani   small update
2256
2257
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'  
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
2258
2259
2260
2261
                                     
                                     endif

                                 endif 
18e4331f   Ilyes Choubani   general update (f...
2262
                            
67bd858a   Ilyes Choubani   Replication of th...
2263
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2264
                            
0068116a   Ilyes Choubani   General update + ...
2265
                                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)'
1bc09467   Ilyes Choubani   fixed issue with ...
2266
2267
                                    
                                
0068116a   Ilyes Choubani   General update + ...
2268
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),-((*(*!dustem_data).used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2269
2270
2271
2272
2273
                                
                                
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2274
2275
2276
                                        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.
74103816   Ilyes Choubani   small update
2277
2278
2279
2280
2281
2282
2283
2284
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2285
2286
2287
                                        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.
74103816   Ilyes Choubani   small update
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif

                                endif     
                                 
                                 
                                 
                                 
                                 
67bd858a   Ilyes Choubani   Replication of th...
2300
2301
2302
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2303
2304
2305
2306
2307
2308
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2309
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2310
            
67bd858a   Ilyes Choubani   Replication of th...
2311
2312
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2313
2314
2315
        
        end
        
afde94a3   Ilyes Choubani   general update
2316
        'QEXT': begin   ;Correct this like you corrected extinction...
1bc09467   Ilyes Choubani   fixed issue with ...
2317
            
4b745987   Ilyes Choubani   minor update
2318
2319
2320
2321
2322
2323
2324
            IF ct_x NE 0 then begin
            
                xr=xr_x 
                yr=yr_x
                
            ENDIF
            
1bc09467   Ilyes Choubani   fixed issue with ...
2325
2326
2327
2328
2329
2330
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
            
0068116a   Ilyes Choubani   General update + ...
2331
2332
            varvar=where((*(*!dustem_data).qext).values GT 0, testpstv)
            varvar=where((*(*!dustem_data).qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2333
            
18e4331f   Ilyes Choubani   general update (f...
2334
            ;stop
0068116a   Ilyes Choubani   General update + ...
2335
2336
            idx_filt=where((*(*!dustem_data).qext).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*(*!dustem_data).qext).filt_names EQ 'SPECTRUM' , ct_spec)
18e4331f   Ilyes Choubani   general update (f...
2337
            
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2338
            
18e4331f   Ilyes Choubani   general update (f...
2339
            ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
2340
            match2,((*(*!dustem_data).qext).wav),((*(*!dustem_show).qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
2341
            idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2342
            
5f04fa07   Ilyes Choubani   general update
2343
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2344
2345
2346
2347
2348
2349
2350
            
            ;#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
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
2351
                    xtit=textoidl('1/\lambda (\mum^{-1})')
bc224f3e   Ilyes Choubani   Update of plottin...
2352
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2353
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
bc224f3e   Ilyes Choubani   Update of plottin...
2354
2355
2356
2357
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
18e4331f   Ilyes Choubani   general update (f...
2358
2359
                    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
94c4dffa   Ilyes Choubani   update + fixes fo...
2360
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
2361
2362
2363
2364
2365
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2366
                
bc224f3e   Ilyes Choubani   Update of plottin...
2367
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2368
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2369
2370
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
07372e26   Ilyes Choubani   Corrected huge pl...
2371
                        ;MAJOR LOOP OVER THE SIGN??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
c8368c6e   Ilyes Choubani   updating plotting...
2372
                
18e4331f   Ilyes Choubani   general update (f...
2373
                        IF ct_spec NE 0 THEN BEGIN
f2caf3f1   Ilyes Choubani   Debugging some er...
2374
                            
0068116a   Ilyes Choubani   General update + ...
2375
                            xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2376
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
2377
                            rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2378
2379
2380
2381
2382
2383
2384
2385
                            
                            ;testing so that data/yy is finite: 
                            ;avoiding zero points in yy since we divide by it
                            ;testing also if the data is full of zeros (ie: PSI=0 for U and PSI=90 for Q)
                            
                            indzero = where(yy NE 0, ct_zero)
                            if ct_zero ne 0 then begin  

0068116a   Ilyes Choubani   General update + ...
2386
2387
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_spec))[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
f2caf3f1   Ilyes Choubani   Debugging some er...
2388
                            endif
18e4331f   Ilyes Choubani   general update (f...
2389
2390
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2391
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2392
                            ;stop
0068116a   Ilyes Choubani   General update + ...
2393
                            xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2394
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
2395
                            rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2396
2397
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2398
2399
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_filt))[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue' 
f2caf3f1   Ilyes Choubani   Debugging some er...
2400
                            ENDIF
bc224f3e   Ilyes Choubani   Update of plottin...
2401
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2402
      
bc224f3e   Ilyes Choubani   Update of plottin...
2403
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2404
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2405
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2406
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2407
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2408
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2409
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
bc224f3e   Ilyes Choubani   Update of plottin...
2410
2411
2412
2413
2414
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
07372e26   Ilyes Choubani   Corrected huge pl...
2415
                endif else begin ; normal plot 
c8368c6e   Ilyes Choubani   updating plotting...
2416
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2417
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
4b745987   Ilyes Choubani   minor update
2418
                        
18e4331f   Ilyes Choubani   general update (f...
2419
2420
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2421
                            if testpstv ne 0 then begin
4b745987   Ilyes Choubani   minor update
2422
                                
18e4331f   Ilyes Choubani   general update (f...
2423
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2424
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2425
2426
2427
                                    vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
                                    vecte = transpose((st.ext.(1))[i,*]+(st.ext.(2))[i,*])
                                    testneq = where( vecto ne 0,countneq)
07372e26   Ilyes Choubani   Corrected huge pl...
2428
                                    
4b745987   Ilyes Choubani   minor update
2429

5f04fa07   Ilyes Choubani   general update
2430
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2431
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2432
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2433
                                        vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
5f04fa07   Ilyes Choubani   general update
2434
2435
                                        ;stop
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
07372e26   Ilyes Choubani   Corrected huge pl...
2436
2437
2438
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                        
                                        ;if countneg ne 0 and cos(!dustem_psi_ext) gt 0 then specqgrain[testneg] = 0
5f04fa07   Ilyes Choubani   general update
2439
                                        
5f04fa07   Ilyes Choubani   general update
2440
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
1bc09467   Ilyes Choubani   fixed issue with ...
2441
                                        dustem_plot_mlog,1/st.polext.wav,specqgrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
07372e26   Ilyes Choubani   Corrected huge pl...
2442
                                        
5f04fa07   Ilyes Choubani   general update
2443
                                    endif
4b745987   Ilyes Choubani   minor update
2444
2445
                                    
                                    
18e4331f   Ilyes Choubani   general update (f...
2446
2447
2448
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2449
2450
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2451
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2452
2453
                                         
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2454
                                            dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
3c479f24   Ilyes Choubani   Allowing to fix p...
2455
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2456
2457
2458
2459
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2460
                                    xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2461
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2462
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2463
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
18e4331f   Ilyes Choubani   general update (f...
2464
2465
2466
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2467
                                    xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2468
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2469
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2470
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
18e4331f   Ilyes Choubani   general update (f...
2471
2472
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2473
                                dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2474
                                
18e4331f   Ilyes Choubani   general update (f...
2475
2476
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2477
                        
18e4331f   Ilyes Choubani   general update (f...
2478
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2479
                        
5f04fa07   Ilyes Choubani   general update
2480
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2481
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2482
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2483
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2484
                            
5f04fa07   Ilyes Choubani   general update
2485
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2486
2487
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2488
2489
2490
                                    vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
                                    vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
                                    testneq = where(vecto ne 0,countneq)
5f04fa07   Ilyes Choubani   general update
2491
2492
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2493
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2494
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2495
                                        vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
5f04fa07   Ilyes Choubani   general update
2496
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2497
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
74103816   Ilyes Choubani   small update
2498
                                        
5f04fa07   Ilyes Choubani   general update
2499
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
1bc09467   Ilyes Choubani   fixed issue with ...
2500
                                        dustem_plot_mlog,1/st.polext.wav,specqgrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
5f04fa07   Ilyes Choubani   general update
2501
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2502
2503
2504
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2505
2506
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2507
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2508
2509
     
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2510
                                            dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,1],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
3c479f24   Ilyes Choubani   Allowing to fix p...
2511
2512
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2513
2514
2515
2516
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2517
                                    xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2518
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2519
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2520
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
18e4331f   Ilyes Choubani   general update (f...
2521
2522
2523
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2524
                                    xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2525
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2526
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2527
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
18e4331f   Ilyes Choubani   general update (f...
2528
2529
                                ENDIF
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2530
                                dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
2531
2532
2533
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2534
                        
18e4331f   Ilyes Choubani   general update (f...
2535
2536
2537
2538
2539
2540
                        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)'
94c4dffa   Ilyes Choubani   update + fixes fo...
2541
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2542
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2543
                            
2df3360b   Ilyes Choubani   Correcting error:...
2544
2545
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
0068116a   Ilyes Choubani   General update + ...
2546
2547
                        ;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...
2548
                        if ct_hdnpts then begin
0068116a   Ilyes Choubani   General update + ...
2549
2550
2551
2552
                            idx_filt_hdn_pstv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
                            idx_spec_hdn_pstv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
                            idx_filt_hdn_ngtv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
                            idx_spec_hdn_ngtv = where(((*(*!dustem_show).qext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).qext).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
9cb38725   Ilyes Choubani   Fixed tests relat...
2553
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2554
                        
c8368c6e   Ilyes Choubani   updating plotting...
2555
                        
18e4331f   Ilyes Choubani   general update (f...
2556
                        if keyword_set(positive_only) then begin
afde94a3   Ilyes Choubani   general update
2557
                            
2df3360b   Ilyes Choubani   Correcting error:...
2558
                            if testpstv ne 0 then begin
07372e26   Ilyes Choubani   Corrected huge pl...
2559
                        
74103816   Ilyes Choubani   small update
2560
2561
2562
2563
2564
                                plotsym, 0
                                
                                
                                if ct_spec ne 0 then begin
                                
0068116a   Ilyes Choubani   General update + ...
2565
2566
                                    rms=3.*((*(*!dustem_data).qext).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)'
74103816   Ilyes Choubani   small update
2567
                                
0068116a   Ilyes Choubani   General update + ...
2568
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2569
                                    
0068116a   Ilyes Choubani   General update + ...
2570
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,color='Powder Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
74103816   Ilyes Choubani   small update
2571
2572
2573
2574
2575
                                     
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2576
2577
2578
2579
2580
                                    rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                    if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2581
2582
2583
                                        
                                endif
                                
18e4331f   Ilyes Choubani   general update (f...
2584
                                
74103816   Ilyes Choubani   small update
2585
                                if ct_hdnpts NE 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2586
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2587
                                    if ct_spec_hdn_pstv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2588
2589
2590
                                        xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2591
                                        
74103816   Ilyes Choubani   small update
2592
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
1bc09467   Ilyes Choubani   fixed issue with ...
2593
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
9cb38725   Ilyes Choubani   Fixed tests relat...
2594
2595
2596
2597
2598
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2599
2600
2601
                                        xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2602
                                        
74103816   Ilyes Choubani   small update
2603
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
1bc09467   Ilyes Choubani   fixed issue with ...
2604
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
9cb38725   Ilyes Choubani   Fixed tests relat...
2605
2606
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2607
                                    
18e4331f   Ilyes Choubani   general update (f...
2608
2609
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2610
                                
18e4331f   Ilyes Choubani   general update (f...
2611
2612
                            endif else begin
                            
1bc09467   Ilyes Choubani   fixed issue with ...
2613
                            
0068116a   Ilyes Choubani   General update + ...
2614
                                if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),-((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2615
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2616
                                
0068116a   Ilyes Choubani   General update + ...
2617
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),-((*(*!dustem_data).qext).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
2618
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
2619

18e4331f   Ilyes Choubani   general update (f...
2620
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
2621
                        
18e4331f   Ilyes Choubani   general update (f...
2622
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2623
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2624
                        
18e4331f   Ilyes Choubani   general update (f...
2625
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
2626
                            
2df3360b   Ilyes Choubani   Correcting error:...
2627
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2628
                                 
74103816   Ilyes Choubani   small update
2629
                                 plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2630
                                 
18e4331f   Ilyes Choubani   general update (f...
2631
                                 
18e4331f   Ilyes Choubani   general update (f...
2632
2633
                                 if ct_spec ne 0 then begin
                                 
0068116a   Ilyes Choubani   General update + ...
2634
2635
2636
2637
                                     rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),-((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ; if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
2638
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
2639
                                     ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
2640
                                     dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,color='Powder Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8     
1bc09467   Ilyes Choubani   fixed issue with ...
2641
                                                                              
18e4331f   Ilyes Choubani   general update (f...
2642
2643
2644
2645
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
2646
2647
2648
2649
2650
                                     rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                     if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
9cb38725   Ilyes Choubani   Fixed tests relat...
2651
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2652
                                     
0068116a   Ilyes Choubani   General update + ...
2653
                                     dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2654
                                         
74103816   Ilyes Choubani   small update
2655
2656
2657
2658
2659
                                 endif
                                 
                                 if ct_hdnpts then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2660
2661
2662
                                         xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
2663
2664
2665
2666
2667
2668
2669
2670
                                         
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
2671
2672
2673
                                         xx = (((*(*!dustem_show).qext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*(*!dustem_show).qext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*(*!dustem_show).qext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
2674
2675
2676
2677
2678
2679
                                         
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif
                                
18e4331f   Ilyes Choubani   general update (f...
2680
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
2681
                            
c8368c6e   Ilyes Choubani   updating plotting...
2682
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2683
                            
0068116a   Ilyes Choubani   General update + ...
2684
                                if ct_spec ne 0 then dustem_plot_mlog,((*(*!dustem_data).qext).wav)(idx_spec),-((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
2685
                                    
18e4331f   Ilyes Choubani   general update (f...
2686
                                
0068116a   Ilyes Choubani   General update + ...
2687
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).qext).wav)(idx_filt),-((*(*!dustem_data).qext).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2688
                                
18e4331f   Ilyes Choubani   general update (f...
2689
                            endelse
5f04fa07   Ilyes Choubani   general update
2690
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2691
2692
2693
2694
2695
2696
2697
2698
2699
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2700
            endelse ; 
18e4331f   Ilyes Choubani   general update (f...
2701
        
67bd858a   Ilyes Choubani   Replication of th...
2702
        end
18e4331f   Ilyes Choubani   general update (f...
2703
        
67bd858a   Ilyes Choubani   Replication of th...
2704
        'UEXT': begin
4b745987   Ilyes Choubani   minor update
2705
2706
2707
2708
2709
2710
2711
            IF ct_x NE 0 then begin
            
                xr=xr_x
                yr=yr_x
                
            ENDIF
                
1bc09467   Ilyes Choubani   fixed issue with ...
2712
2713
2714
2715
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
67bd858a   Ilyes Choubani   Replication of th...
2716
        
0068116a   Ilyes Choubani   General update + ...
2717
2718
            varvar=where((*(*!dustem_data).uext).values GT 0, testpstv)
            varvar=where((*(*!dustem_data).uext).values LT 0, testngtv)
67bd858a   Ilyes Choubani   Replication of th...
2719
            
18e4331f   Ilyes Choubani   general update (f...
2720
            ;stop
0068116a   Ilyes Choubani   General update + ...
2721
2722
            idx_filt=where((*(*!dustem_data).uext).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*(*!dustem_data).uext).filt_names EQ 'SPECTRUM' , ct_spec)
f2caf3f1   Ilyes Choubani   Debugging some er...
2723
            
18e4331f   Ilyes Choubani   general update (f...
2724
2725
2726
2727
2728
            ;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)
0068116a   Ilyes Choubani   General update + ...
2729
            match2,((*(*!dustem_data).uext).wav),((*(*!dustem_show).uext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
2730
            idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
18e4331f   Ilyes Choubani   general update (f...
2731
            
67bd858a   Ilyes Choubani   Replication of th...
2732
            
18e4331f   Ilyes Choubani   general update (f...
2733
2734
2735
            ;#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
f2caf3f1   Ilyes Choubani   Debugging some er...
2736
                
18e4331f   Ilyes Choubani   general update (f...
2737
2738
                if keyword_set(norm) then begin ;normalized plot
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
2739
                    xtit=textoidl('1/\lambda (\mum^{-1})')
18e4331f   Ilyes Choubani   general update (f...
2740
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2741
                    cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,xtickformat='(A1)',color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
18e4331f   Ilyes Choubani   general update (f...
2742
2743
2744
2745
2746
2747
                    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
94c4dffa   Ilyes Choubani   update + fixes fo...
2748
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
                  
                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
f2caf3f1   Ilyes Choubani   Debugging some er...
2762
                            
0068116a   Ilyes Choubani   General update + ...
2763
                            xx=((*(*!dustem_data).uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2764
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
2765
                            rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2766
2767
2768
                            
                            indzero = where(yy NE 0, ct_zero)
                            If ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2769
2770
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).uext).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).uext).wav)(idx_spec))[indzero],((((*(*!dustem_data).uext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).uext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
f2caf3f1   Ilyes Choubani   Debugging some er...
2771
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
2772
2773
2774
2775
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
0068116a   Ilyes Choubani   General update + ...
2776
                            xx=((*(*!dustem_data).uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2777
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
2778
                            rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2779
2780
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2781
2782
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).uext).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).uext).wav)(idx_filt))[indzero],((((*(*!dustem_data).uext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).uext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue' 
f2caf3f1   Ilyes Choubani   Debugging some er...
2783
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
2784
2785
2786
2787
2788
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2789
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2790
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2791
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2792
                        cgplot,1/vectw,vectx,/xlog,/ys,xs=1,pos=position,noerase=1,color='Black',xr=xr,xtit=xtit,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0
67bd858a   Ilyes Choubani   Replication of th...
2793
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
2794
2795
2796
2797
                    
                    endelse
                    
                
67bd858a   Ilyes Choubani   Replication of th...
2798
                endif else begin ; normal plot - STOPPED HERE FOR QSED
18e4331f   Ilyes Choubani   general update (f...
2799
2800
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
53548c91   Ilyes Choubani   Display of frozen...
2801
                        
18e4331f   Ilyes Choubani   general update (f...
2802
2803
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2804
                            if testpstv ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2805
                                
18e4331f   Ilyes Choubani   general update (f...
2806
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2807
2808
2809
                                
                                    vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
                                    vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
5f04fa07   Ilyes Choubani   general update
2810
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2811
                                    testneq = where( vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
2812
                                    ;stop
5f04fa07   Ilyes Choubani   general update
2813
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2814
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
67bd858a   Ilyes Choubani   Replication of th...
2815
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2816
                                        vecfin[testneq] = (vecto[testneq])/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq]
67bd858a   Ilyes Choubani   Replication of th...
2817
2818
                                        ;stop
                                        ;polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,st.polsed.(i+1)*fact/spec,replicate(!dustem_psi,n_elements(spec)) ;temporary solution
07372e26   Ilyes Choubani   Corrected huge pl...
2819
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2820
                                        
67bd858a   Ilyes Choubani   Replication of th...
2821
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2822
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
1bc09467   Ilyes Choubani   fixed issue with ...
2823
                                        dustem_plot_mlog,1/st.polext.wav,specugrain,ppositions=position,/positive_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
67bd858a   Ilyes Choubani   Replication of th...
2824
2825
                                        ;stop
                                    endif
5f04fa07   Ilyes Choubani   general update
2826
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2827
                                ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
2828
                                
18e4331f   Ilyes Choubani   general update (f...
2829
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2830
2831
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2832
2833
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                         
3c479f24   Ilyes Choubani   Allowing to fix p...
2834
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2835
                                            dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
3c479f24   Ilyes Choubani   Allowing to fix p...
2836
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2837
                                    ENDIF
18e4331f   Ilyes Choubani   general update (f...
2838
2839
2840
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2841
                                    xx=((*(*!dustem_data).uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2842
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2843
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2844
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
18e4331f   Ilyes Choubani   general update (f...
2845
2846
2847
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2848
                                    xx=((*(*!dustem_data).uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2849
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2850
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2851
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
18e4331f   Ilyes Choubani   general update (f...
2852
2853
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2854
                                dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
18e4331f   Ilyes Choubani   general update (f...
2855
2856
2857
2858
2859
2860
                            
                            endif
                                    
                        
                        endif
                        
67bd858a   Ilyes Choubani   Replication of th...
2861
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2862
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2863
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2864
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2865
                            
f2caf3f1   Ilyes Choubani   Debugging some er...
2866
                                    
18e4331f   Ilyes Choubani   general update (f...
2867
2868
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2869
2870
2871
                                    vecto = transpose(((st.polext.(1))[i,*]+(st.polext.(2))[i,*]))
                                    vecte = transpose(((st.ext.(1))[i,*]+(st.ext.(2))[i,*]))
                                    testneq = where( vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
2872
2873
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2874
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
67bd858a   Ilyes Choubani   Replication of th...
2875
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2876
                                        vecfin[testneq] = vecto[testneq]/vecte[testneq];extra_spec[testneq];(st.sed.em_tot)[testneq];(st.sed.(i+1))[testneq];*fact;(st.sed.(i+1))[testneq] 
67bd858a   Ilyes Choubani   Replication of th...
2877
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2878
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
67bd858a   Ilyes Choubani   Replication of th...
2879
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2880
                                        ;dustem_plot_mlog,st.polsed.wav,specqgrain,ppositions=position,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog 
1bc09467   Ilyes Choubani   fixed issue with ...
2881
                                        dustem_plot_mlog,1/st.polext.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
67bd858a   Ilyes Choubani   Replication of th...
2882
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2883
2884
                                ENDFOR
                                ;Plotting of the plugins
67bd858a   Ilyes Choubani   Replication of th...
2885
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2886
2887
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2888
2889
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
     
3c479f24   Ilyes Choubani   Allowing to fix p...
2890
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2891
                                            dustem_plot_mlog,1/st.polext.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
3c479f24   Ilyes Choubani   Allowing to fix p...
2892
                                        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2893
                                        
18e4331f   Ilyes Choubani   general update (f...
2894
                                    ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2895
                                endfor
18e4331f   Ilyes Choubani   general update (f...
2896
2897
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2898
                                    xx=((*(*!dustem_data).uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2899
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2900
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2901
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
18e4331f   Ilyes Choubani   general update (f...
2902
2903
2904
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2905
                                    xx=((*(*!dustem_data).uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2906
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2907
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
1bc09467   Ilyes Choubani   fixed issue with ...
2908
                                    dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
18e4331f   Ilyes Choubani   general update (f...
2909
                                ENDIF
18e4331f   Ilyes Choubani   general update (f...
2910
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2911
                                dustem_plot_mlog,1/st.polext.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2912
                            
18e4331f   Ilyes Choubani   general update (f...
2913
2914
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2915
2916
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
2917
2918
                                                   
                      ;stop             
67bd858a   Ilyes Choubani   Replication of th...
2919
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
bc224f3e   Ilyes Choubani   Update of plottin...
2920
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2921
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
94c4dffa   Ilyes Choubani   update + fixes fo...
2922
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2923
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
67bd858a   Ilyes Choubani   Replication of th...
2924
                            
2df3360b   Ilyes Choubani   Correcting error:...
2925
2926
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
0068116a   Ilyes Choubani   General update + ...
2927
2928
                        ;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...
2929
                        if ct_hdnpts then begin
0068116a   Ilyes Choubani   General update + ...
2930
2931
2932
2933
                            idx_filt_hdn_pstv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
                            idx_spec_hdn_pstv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
                            idx_filt_hdn_ngtv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
                            idx_spec_hdn_ngtv = where(((*(*!dustem_show).uext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*(*!dustem_show).uext).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
9cb38725   Ilyes Choubani   Fixed tests relat...
2934
                        endif
67bd858a   Ilyes Choubani   Replication of th...
2935
                        
18e4331f   Ilyes Choubani   general update (f...
2936
2937
                        
                        if keyword_set(positive_only) then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2938
                            
67bd858a   Ilyes Choubani   Replication of th...
2939
2940
2941
2942
                                
                                
                                if ct_spec ne 0 then begin
                                
0068116a   Ilyes Choubani   General update + ...
2943
2944
2945
2946
                                    rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
                                    ;dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),-((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,color='Powder Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
67bd858a   Ilyes Choubani   Replication of th...
2947
2948
2949
2950
2951
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2952
2953
2954
2955
2956
                                    rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                    if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
2957
2958
                                        
                                endif
74103816   Ilyes Choubani   small update
2959
2960
2961
2962
2963
2964
2965
2966
2967
                                
                                
                                if testpstv ne 0 then begin
                                
                                    plotsym, 0
                                    
                                    if ct_hdnpts NE 0 then begin
                                    
                                        if ct_spec_hdn_pstv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2968
2969
2970
                                            xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                            yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                            rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
74103816   Ilyes Choubani   small update
2971
2972
2973
2974
2975
2976
2977
2978
                                            
                                            dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                            dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                        
                                        endif 
                                        
                                        if ct_filt_hdn_pstv ne 0 then begin
                                        
0068116a   Ilyes Choubani   General update + ...
2979
2980
2981
                                            xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                            yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                            rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
74103816   Ilyes Choubani   small update
2982
2983
2984
2985
2986
2987
2988
                                            
                                            dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                            dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                        
                                        endif
                                        
                                    endif
2df3360b   Ilyes Choubani   Correcting error:...
2989
                            endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2990
                                
0068116a   Ilyes Choubani   General update + ...
2991
                                if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2992
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2993
                                
0068116a   Ilyes Choubani   General update + ...
2994
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),-((*(*!dustem_data).uext).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
f2caf3f1   Ilyes Choubani   Debugging some er...
2995
                                   
07372e26   Ilyes Choubani   Corrected huge pl...
2996
                                
67bd858a   Ilyes Choubani   Replication of th...
2997
                            endelse                           
18e4331f   Ilyes Choubani   general update (f...
2998
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2999
                        
18e4331f   Ilyes Choubani   general update (f...
3000
3001
                        endif 
                        
67bd858a   Ilyes Choubani   Replication of th...
3002
                        
18e4331f   Ilyes Choubani   general update (f...
3003
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
3004
                            
2df3360b   Ilyes Choubani   Correcting error:...
3005
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
3006
                                 
74103816   Ilyes Choubani   small update
3007
                                 plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
3008
                                 
18e4331f   Ilyes Choubani   general update (f...
3009
                                 
67bd858a   Ilyes Choubani   Replication of th...
3010
                                 if ct_spec ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
3011
                                     
0068116a   Ilyes Choubani   General update + ...
3012
3013
3014
3015
                                     rms=3.*((*(*!dustem_data).uext).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),-((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ; if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
3016
                                     ;endelse;,ytickformat='(A1)'
0068116a   Ilyes Choubani   General update + ...
3017
                                     dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,color='Powder Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8     
67bd858a   Ilyes Choubani   Replication of th...
3018
3019
3020
3021
3022
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
3023
3024
3025
3026
3027
                                     rms=3.*((*(*!dustem_data).uext).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                     if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
3028
3029
                                     ;endelse ;,ytickformat='(A1)'
                                     
0068116a   Ilyes Choubani   General update + ...
3030
                                     dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),((*(*!dustem_data).uext).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
67bd858a   Ilyes Choubani   Replication of th...
3031
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
3032
                                 endif 
74103816   Ilyes Choubani   small update
3033
3034
3035
3036
                                 
                                 if ct_hdnpts NE 0 then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
3037
3038
3039
                                         xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
3040
3041
3042
3043
3044
3045
3046
3047
                                         
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
0068116a   Ilyes Choubani   General update + ...
3048
3049
3050
                                         xx = (((*(*!dustem_show).uext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*(*!dustem_show).uext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*(*!dustem_show).uext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
3051
3052
3053
3054
3055
3056
3057
                                         
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif
                                
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
3058
                            
2df3360b   Ilyes Choubani   Correcting error:...
3059
                            endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
3060
                                
0068116a   Ilyes Choubani   General update + ...
3061
                                if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_spec),-((*(*!dustem_data).uext).values)(idx_spec),ppositions=position,charsize=1.15,/nodata,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
3062
                                    
18e4331f   Ilyes Choubani   general update (f...
3063
                                
0068116a   Ilyes Choubani   General update + ...
3064
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,1/((*(*!dustem_data).uext).wav)(idx_filt),-((*(*!dustem_data).uext).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
07372e26   Ilyes Choubani   Corrected huge pl...
3065
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
3066
                        
2df3360b   Ilyes Choubani   Correcting error:...
3067
                            endelse
5f04fa07   Ilyes Choubani   general update
3068
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
3069
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
3070
3071
3072
3073
                        
                    
                    endelse 
                
bc224f3e   Ilyes Choubani   Update of plottin...
3074
3075
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
3076
            endelse 
b5314324   Ilyes Choubani   updating the plot...
3077
3078
        
        end
5f04fa07   Ilyes Choubani   general update
3079
3080
        
        'PARAMETERS':begin ;needs the followingd data (errors+res+formats)
e9bb0ce2   Ilyes Choubani   Correcting small ...
3081
         
5f04fa07   Ilyes Choubani   general update
3082
3083
3084
3085
3086
            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
53548c91   Ilyes Choubani   Display of frozen...
3087
    
5f04fa07   Ilyes Choubani   general update
3088
                k=0    
5f04fa07   Ilyes Choubani   general update
3089
                
53548c91   Ilyes Choubani   Display of frozen...
3090
3091
3092
3093
3094
3095
3096
                    
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
                    
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
                    
                    FOR i=0L,Nfpar-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
3097
                        
53548c91   Ilyes Choubani   Display of frozen...
3098
3099
3100
3101
3102
3103
3104
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                        ;Not sure about the wrapper data type that is mentioned in this procedure
                        IF parameter_type NE 'PLUGIN' THEN BEGIN                       
                            yypos = 0.8 - k*0.09
                            k+=1
                        ENDIF 
5f04fa07   Ilyes Choubani   general update
3105
                        
53548c91   Ilyes Choubani   Display of frozen...
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
                    ENDFOR  
                                
                     
                ENDIF
                
                
                prms_dscs = (*(*!dustem_fit).param_descs)
                prms_tps = strarr(n_elements(prms_dscs))
                
                for i=0L,n_elements(prms_dscs)-1 do begin
                    prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
                endfor
                
                testprms = where(prms_tps ne 'PLUGIN', ct_data)
                if ct_data ne 0 then begin
                
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3122
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
fcb6eade   Ilyes Choubani   general update - ...
3123
3124
                    
                    
53548c91   Ilyes Choubani   Display of frozen...
3125
3126
3127
3128
3129
                    res = dustem_interp
                    errors = dustem_spec
                    yypostmp = yypos
                    k=0
                    FOR i=0L,Npar-1 DO BEGIN   
fcb6eade   Ilyes Choubani   general update - ...
3130
                      
53548c91   Ilyes Choubani   Display of frozen...
3131
3132
3133
3134
3135
                      parameter_description = (*(*!dustem_fit).param_descs)[i]
                      parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                      testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
                          
                        IF parameter_type EQ 'FORTRAN' and  testpop then begin
fcb6eade   Ilyes Choubani   general update - ...
3136
                          
53548c91   Ilyes Choubani   Display of frozen...
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
                            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 
                            yypos = yypostmp - k*0.09 
                            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
e9bb0ce2   Ilyes Choubani   Correcting small ...
3161
                        
fcb6eade   Ilyes Choubani   general update - ...
3162
                        
53548c91   Ilyes Choubani   Display of frozen...
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
                        IF parameter_type EQ 'FORTRAN' and ~testpop then begin
                          
                            ;indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                            ;string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                              
                            
                            yypos = yypostmp - k*0.09 
                            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 - ...
3189
                        
fcb6eade   Ilyes Choubani   general update - ...
3190
                        
53548c91   Ilyes Choubani   Display of frozen...
3191
                    ENDFOR        
fcb6eade   Ilyes Choubani   general update - ...
3192
                    
53548c91   Ilyes Choubani   Display of frozen...
3193
                ENDIF                        
5f04fa07   Ilyes Choubani   general update
3194
3195
                
            endif else begin ;data in the parameter window that is unchanged 
e9bb0ce2   Ilyes Choubani   Correcting small ...
3196
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3197
3198
3199
                ;Trying to gather information on the fixed parameters
                ;Two pointers assuming one is sufficient for the following condition (unless dustem_init_fixed_parameters)
                ;WILL THIS WORK?
53548c91   Ilyes Choubani   Display of frozen...
3200
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3201
3202
3203
3204
3205
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
                    
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
                    k = 0
53548c91   Ilyes Choubani   Display of frozen...
3206
3207
3208
3209
3210
                    xxpos = 0.0
                    yypos = 0.9
                    ;xxpos = 0.0 ;might need to be modified
                    cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal  
                    xxpos=(1-thiswidth)/2
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3211
                    xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
e9bb0ce2   Ilyes Choubani   Correcting small ...
3212
3213
3214
3215
3216
                    
                    FOR i=0L,Nfpar-1 DO BEGIN
                        
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
53548c91   Ilyes Choubani   Display of frozen...
3217
3218
3219
3220
3221
3222
3223
3224
3225
                        testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
                        IF parameter_type NE 'PLUGIN' THEN BEGIN
                        
                            IF  parameter_type EQ 'FORTRAN' and  testpop then begin
                                 
                                indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                                string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                                
                            ENDIF
e9bb0ce2   Ilyes Choubani   Correcting small ...
3226
                            
53548c91   Ilyes Choubani   Display of frozen...
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
                            yypos = 0.8 - k*0.09
                            xxpos = 0.0  
                            
                            str=strtrim(string(string_name+' = ',format=frmt0),2)
                            str1=str+string(res[i],format=frmt1)
                            cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                            xxpos=(1-thiswidth)/2 
                            ;stop
                            xyouts,xxpos,yypos,str1,color=0,/normal,charsize=1.
                            k+=1
e9bb0ce2   Ilyes Choubani   Correcting small ...
3237
                        
53548c91   Ilyes Choubani   Display of frozen...
3238
                        ENDIF    
e9bb0ce2   Ilyes Choubani   Correcting small ...
3239
                         
53548c91   Ilyes Choubani   Display of frozen...
3240
                    ENDFOR  
e9bb0ce2   Ilyes Choubani   Correcting small ...
3241
3242
3243
3244
                     
                ENDIF
                
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3245
                
5f04fa07   Ilyes Choubani   general update
3246
                ;stop
0c487640   Ilyes Choubani   corrected missing...
3247
                xxpos = 0.0;might need to be modified
53548c91   Ilyes Choubani   Display of frozen...
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
                
                ;test so that this string isn't displayed when there are no free parameters: 
                
                prms_dscs = (*(*!dustem_fit).param_descs)
                prms_tps = strarr(n_elements(prms_dscs))
                
                for i=0L,n_elements(prms_dscs)-1 do begin
                    prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
                endfor
                
                testprms = where(prms_tps ne 'PLUGIN', ct_data)
                
                IF ct_data ne 0 then begin
                
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3262
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3263
3264
3265
3266
                
                    cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal

                    xxpos=(1-thiswidth)/2
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3267
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3268
3269
3270
3271
3272
                
                    ;stop
                    k=0   
                    res = dustem_interp
                    errors = dustem_spec
5f04fa07   Ilyes Choubani   general update
3273
                ;stop
53548c91   Ilyes Choubani   Display of frozen...
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
                
                    yypos-=0.1
                    yypostmp = yypos
                    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)
                      testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
                      ;stop  
                      ;STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).'  
e9bb0ce2   Ilyes Choubani   Correcting small ...
3284
                        
53548c91   Ilyes Choubani   Display of frozen...
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
                      IF  parameter_type EQ 'FORTRAN' and testpop then begin
                             
                            indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset)))
                            string_name=(((*!dustem_params). GRAINS).grain_type)[indpop]
                            
                            
                            yypos = yypostmp -  k*0.09
                            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
                      
                      ;STRUPCASE(strmid(strtrim(parameter_description,2),0,18)) eq '(*!DUSTEM_PARAMS).'
                      IF  parameter_type EQ 'FORTRAN' and ~testpop then begin
5f04fa07   Ilyes Choubani   general update
3309
                        
53548c91   Ilyes Choubani   Display of frozen...
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
                          ;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
                           
                          yypos = yypostmp - k*0.09
                          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
                    
                    ENDFOR
fcb6eade   Ilyes Choubani   general update - ...
3332
                    
fcb6eade   Ilyes Choubani   general update - ...
3333
                ENDIF
53548c91   Ilyes Choubani   Display of frozen...
3334
                    
5f04fa07   Ilyes Choubani   general update
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
                
            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) 
                
53548c91   Ilyes Choubani   Display of frozen...
3348
3349
3350
3351
3352
3353
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
                    
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
                    k=0
                    FOR i=0L,Nfpar-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
3354
                        
53548c91   Ilyes Choubani   Display of frozen...
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                        ;Not sure about the wrapper data type that is mentioned in this procedure
                        IF parameter_type EQ 'PLUGIN' THEN BEGIN                       
                            yypos = 0.8 - k*0.09
                            k+=1
                        ENDIF 
                        
                    ENDFOR  
                                
                     
                ENDIF
                
                
                prms_dscs = (*(*!dustem_fit).param_descs)
                prms_tps = strarr(n_elements(prms_dscs))
                
                for i=0L,n_elements(prms_dscs)-1 do begin
                    prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
                endfor
                
                testprms = where(prms_tps EQ 'PLUGIN', ct_data)
                
                if ct_data ne 0 then begin
                
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3380
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
                    
                    
                    k=0
                    res = dustem_interp
                    errors = dustem_spec
                    yypostmp = yypos
                    
                    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 parameter_type EQ 'PLUGIN' THEN BEGIN
                            
                            ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
                            mm = where(tag_names(*!dustem_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)
                            indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)     
                            indtg = fix(indtg)
                            prmtg = prmtg[indtg-1] 
                            yypos = yypostmp - k*0.09
                            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
5f04fa07   Ilyes Choubani   general update
3414
                            
53548c91   Ilyes Choubani   Display of frozen...
3415
3416
3417
3418
3419
3420
                        ENDIF          
                                
                    
                    ENDFOR
                
             ENDIF
5f04fa07   Ilyes Choubani   general update
3421
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3422
            endif else begin ;(FROZEN RUN = title strings + fixed plugins (TBDONE))
5f04fa07   Ilyes Choubani   general update
3423
                
53548c91   Ilyes Choubani   Display of frozen...
3424
3425
3426
                
                
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
5f04fa07   Ilyes Choubani   general update
3427
                    
53548c91   Ilyes Choubani   Display of frozen...
3428
3429
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
5f04fa07   Ilyes Choubani   general update
3430
                    
0068116a   Ilyes Choubani   General update + ...
3431
                    iii=0
74103816   Ilyes Choubani   small update
3432
3433
3434
3435
                    FOR i=0L,Nfpar-1 DO BEGIN
                        
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
0068116a   Ilyes Choubani   General update + ...
3436
                        if parameter_type EQ 'PLUGIN' then iii+=1 
74103816   Ilyes Choubani   small update
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
                        
                    ENDFOR
                    k = 0
                    if iii ne 0 then begin
                        xxpos = 0.0
                        yypos = 0.9
                        ;xxpos = 0.0 ;might need to be modified
                        cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal  
                        xxpos=(1-thiswidth)/2
                        xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
                    endif
53548c91   Ilyes Choubani   Display of frozen...
3448
3449
3450
3451
3452
3453
3454
                    FOR i=0L,Nfpar-1 DO BEGIN
                        
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
                        testpop = STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O'
                        
                        IF parameter_type EQ 'PLUGIN' THEN BEGIN
5f04fa07   Ilyes Choubani   general update
3455
                        
53548c91   Ilyes Choubani   Display of frozen...
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
                            
                            ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
                            mm = where(tag_names(*!dustem_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)
                            indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)     
                            indtg = fix(indtg)
                            prmtg = prmtg[indtg-1] 
                            
                            yypos = 0.8 - k*0.09
                            xxpos = 0.0  
                            
                            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)
                            cgtext, xxpos, yypos, str1, charsize=-1, width=thiswidth, /normal
                            xxpos=(1-thiswidth)/2 
                            ;stop
                            xyouts,xxpos,yypos,str1,color=0,/normal,charsize=1.
                            k+=1
                        
                        ENDIF    
5f04fa07   Ilyes Choubani   general update
3477
                         
53548c91   Ilyes Choubani   Display of frozen...
3478
3479
3480
3481
                    ENDFOR  
                     
                ENDIF
                
0c487640   Ilyes Choubani   corrected missing...
3482
                xxpos = 0
53548c91   Ilyes Choubani   Display of frozen...
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
                
                prms_dscs = (*(*!dustem_fit).param_descs)
                prms_tps = strarr(n_elements(prms_dscs))
                 
                for i=0L,n_elements(prms_dscs)-1 do begin
                    prms_tps[i] = dustem_parameter_description2type(prms_dscs[i])
                endfor
                
                testprms = where(prms_tps EQ 'PLUGIN', ct_data)
                
                IF ct_data ne 0 then begin
                
                
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3496
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3497
3498
3499
3500
3501
                     ;stop
                     ;xxpos = 0.0;might need to be modified
                    cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal
    
                    xxpos=(1-thiswidth)/2
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3502
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3503
3504
3505
3506
3507
3508
3509
                    
                    
                    k=0
                    res = dustem_interp
                    errors = dustem_spec
                    yypos-=0.1
                    yypostmp = yypos
5f04fa07   Ilyes Choubani   general update
3510
                        
53548c91   Ilyes Choubani   Display of frozen...
3511
3512
3513
3514
                    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)
5f04fa07   Ilyes Choubani   general update
3515
                        
5f04fa07   Ilyes Choubani   general update
3516
                        
53548c91   Ilyes Choubani   Display of frozen...
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
                        IF parameter_type EQ 'PLUGIN' THEN BEGIN
                            
                            ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword 
                            mm = where(tag_names(*!dustem_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)
                            indtg = (strmid(string_name,ii+1)) & indtg = strmid(indtg,0,/reverse_offset)     
                            indtg = fix(indtg)
                            prmtg = prmtg[indtg-1] 
                             
                            yypos = yypostmp - k*0.09
                            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
                          
                        
5f04fa07   Ilyes Choubani   general update
3543
                    
53548c91   Ilyes Choubani   Display of frozen...
3544
3545
                    ENDFOR
                ENDIF
5f04fa07   Ilyes Choubani   general update
3546
3547
3548
3549
            endelse
         
        
        
5f04fa07   Ilyes Choubani   general update
3550
3551
        end
        
b5314324   Ilyes Choubani   updating the plot...
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
    
    endcase


endif










b5314324   Ilyes Choubani   updating the plot...
3567
END