Blame view

src/idl/dustemcgwin_dataset.pro 233 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
            
b5314324   Ilyes Choubani   updating the plot...
81
82
83
84
85
86
87
88
89
90
91
            idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
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
113
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
114
                            yy=dustem_interp[idx_spec]
b5314324   Ilyes Choubani   updating the plot...
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
121
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
122
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
123
124
                            rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
18e4331f   Ilyes Choubani   general update (f...
125
                            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
175
                        IF ct_spec NE 0 THEN BEGIN
                        
                            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
182
                        
                        IF ct_filt NE 0 THEN BEGIN
                            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)
dfc68a85   Ilyes Choubani   Fixed some plotti...
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
203
204
205
206
207
208
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec)-rms,((*!dustem_data.sed).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
209
                        
b5314324   Ilyes Choubani   updating the plot...
210
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
dfc68a85   Ilyes Choubani   Fixed some plotti...
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
216
217
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
                            cgerrplot,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt)-rms,((*!dustem_data.sed).values)(idx_filt)+rms,color='Dodger Blue'
c8368c6e   Ilyes Choubani   updating plotting...
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)
abebbdf3   Ilyes Choubani   General update: A...
228
                        match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
b5314324   Ilyes Choubani   updating the plot...
229
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
230
231
232
233
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.sed).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                         
c8368c6e   Ilyes Choubani   updating plotting...
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
dfc68a85   Ilyes Choubani   Fixed some plotti...
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
241
242
243
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
                                cgerrplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_spec_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
                            endif                                            
b5314324   Ilyes Choubani   updating the plot...
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 
dfc68a85   Ilyes Choubani   Fixed some plotti...
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
250
251
252
253
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.sed).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
                                cgerrplot,(((*!dustem_show.sed).wav)[idx_rmv_sed])(idx_filt_hdn),(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*!dustem_show.sed).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
                                
                            endif
b5314324   Ilyes Choubani   updating the plot...
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
            
67bd858a   Ilyes Choubani   Replication of th...
288
289
290
291
292
293
294
295
296
            idx_filt=where((*!dustem_data.ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.ext).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                if keyword_set(norm) then begin ;normalized plot
                    
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
320
321
322
                  
                ;endelse  
                endif
            
            endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
            if not keyword_set(nodata) then begin
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.ext).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.ext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
323
324
325
326
327
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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'
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
328
329
330
331
332
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN ; There are no filter points for now...
                            xx=((*!dustem_data.ext).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
94c4dffa   Ilyes Choubani   update + fixes fo...
333
334
335
336
337
338
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2.
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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 
                            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
390
391
                                ENDIF
                                
                            endif
                            
                        endfor
                        
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.ext).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
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
397
398
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.ext).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
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)
afde94a3   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
418
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
419
                            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                         
afde94a3   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
431
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
afde94a3   Ilyes Choubani   general update
432
                            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
443
444
445
446
447
448
449
450
451
452
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        match2,((*!dustem_data.ext).wav),((*!dustem_show.ext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
                        idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.ext).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.ext).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
                         
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
afde94a3   Ilyes Choubani   general update
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
456
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
457
                                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 
afde94a3   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
465
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
466
                                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
            
67bd858a   Ilyes Choubani   Replication of th...
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
                            
67bd858a   Ilyes Choubani   Replication of th...
529
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
530
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
531
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
532
533
534
535
536
537
538
539
                            indzero = where(yy NE 0, ct_zero)
                            
                            IF ct_zero NE 0 THEN BEGIN
                            
                                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'
                            
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
540
541
542
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
543
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
544
                            yy=dustem_interp[idx_filt]
94c4dffa   Ilyes Choubani   update + fixes fo...
545
546
547
548
549
550
551
552
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2.
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                             
                                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 
                            
                            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
                        
67bd858a   Ilyes Choubani   Replication of th...
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
67bd858a   Ilyes Choubani   Replication of th...
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)
afde94a3   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
67bd858a   Ilyes Choubani   Replication of th...
617
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
618
                            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                         
afde94a3   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
67bd858a   Ilyes Choubani   Replication of th...
630
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
afde94a3   Ilyes Choubani   general update
631
                            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)
67bd858a   Ilyes Choubani   Replication of th...
642
643
                        match2,((*!dustem_data.polext).wav),((*!dustem_show.polext).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
                        idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide  - not renaming this and keeping the polsed notation
2df3360b   Ilyes Choubani   Correcting error:...
644
                        ;Locating the hidden spectrum and filter data points                                        
67bd858a   Ilyes Choubani   Replication of th...
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
afde94a3   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
67bd858a   Ilyes Choubani   Replication of th...
657
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
658
                                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 
afde94a3   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
67bd858a   Ilyes Choubani   Replication of th...
666
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
667
                                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
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
728
729
730
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
731
732
733
734
735
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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'
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
736
                        ENDIF
1355825c   Ilyes Choubani   General update
737
                        
67bd858a   Ilyes Choubani   Replication of th...
738
739
740
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
94c4dffa   Ilyes Choubani   update + fixes fo...
741
742
743
744
745
746
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2.
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN 
                                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 
                            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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
                            cgoplot,st.polsed.wav,st.polsed.(i+1)*fact,color=use_cols[i],pos=position,noerase=1
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
                            If isa((*!dustem_plugin).(0).spec) then begin
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                    cgoplot,st.polsed.wav,sqrt(((*(*!dustem_plugin).(i).spec)[*,1])^2+((*(*!dustem_plugin).(i).spec)[*,2])^2),color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
                                ENDIF 
                            endif
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
                            xx=((*!dustem_data.polsed).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
                            xx=((*!dustem_data.polsed).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
                        cgoplot,st.polsed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
                                        
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            cgplot,((*!dustem_data.polsed).wav)(idx_spec),((*!dustem_data.polsed).values)(idx_spec),/ylog,/xlog,/ys,xs=9,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,psym=8,syms=0.8,ytickformat='dstmwrp_exp'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_spec),((*!dustem_data.polsed).values)(idx_spec)-rms,((*!dustem_data.polsed).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            if ct_spec ne 0 then cgoplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.polsed).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
                            cgerrplot,((*!dustem_data.polsed).wav)(idx_filt),((*!dustem_data.polsed).values)(idx_filt)-rms,((*!dustem_data.polsed).values)(idx_filt)+rms,color='Dodger Blue'
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
                        
                        xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        match2,((*!dustem_data.polsed).wav),((*!dustem_show.polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
                        idx_rmv_polsed=where(show_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where((((*!dustem_show.polsed).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.polsed).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
                        
                        ;stop
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgoplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
                                cgerrplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black'
                            endif                                            
                            
                            if ct_filt_hdn ne 0 then begin
                            ;Plotting of hidden filter data points 
                                cgoplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8                                           
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.polsed).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
                                cgerrplot,(((*!dustem_show.polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*!dustem_show.polsed).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
        end
        
        'POLFRAC': begin 
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
67bd858a   Ilyes Choubani   Replication of th...
885
886
887
888
889
890
891
892
            idx_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',ct_spec)
            
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[1.00E-04,50.00],/ylog,psym=8,syms=0.8  
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
935
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.polfrac).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
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
942
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             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)
5f04fa07   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
962
963
964
965
966
967
968
969
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.polfrac).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.polfrac).wav)(idx_spec),(((*!dustem_data.polfrac).values)(idx_spec)-rms)*100,(((*!dustem_data.polfrac).values)(idx_spec)+rms)*100,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
5f04fa07   Ilyes Choubani   general update
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
975
976
977
978
979
980
981
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.polfrac).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            cgerrplot,((*!dustem_data.polfrac).wav)(idx_filt),(((*!dustem_data.polfrac).values)(idx_filt)-rms)*100,(((*!dustem_data.polfrac).values)(idx_filt)+rms)*100,color='Dodger Blue'
                            
                        endif
                        
                        
                        
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)
abebbdf3   Ilyes Choubani   General update: A...
987
                        match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
1355825c   Ilyes Choubani   General update
988
989
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
990
991
992
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.polfrac).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
1355825c   Ilyes Choubani   General update
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
5f04fa07   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
1001
1002
1003
1004
1005
1006
1007
1008
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                cgerrplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
5f04fa07   Ilyes Choubani   general update
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
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.polfrac).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                cgerrplot,(((*!dustem_show.polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*!dustem_show.polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse 
b5314324   Ilyes Choubani   updating the plot...
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
67bd858a   Ilyes Choubani   Replication of th...
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
                         
67bd858a   Ilyes Choubani   Replication of th...
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
67bd858a   Ilyes Choubani   Replication of th...
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)
94c4dffa   Ilyes Choubani   update + fixes fo...
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
67bd858a   Ilyes Choubani   Replication of th...
1113
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
1114
                            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                         
94c4dffa   Ilyes Choubani   update + fixes fo...
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
67bd858a   Ilyes Choubani   Replication of th...
1126
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
afde94a3   Ilyes Choubani   general update
1127
                            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
1138
1139
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
                        match2,((*!dustem_data.fpolext).wav),((*!dustem_show.fpolext).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide; 
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1140
                        
67bd858a   Ilyes Choubani   Replication of th...
1141
1142
1143
1144
1145
1146
1147
1148
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.fpolext).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.fpolext).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
94c4dffa   Ilyes Choubani   update + fixes fo...
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
1152
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.fpolext).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
1bc09467   Ilyes Choubani   fixed issue with ...
1153
                                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 
94c4dffa   Ilyes Choubani   update + fixes fo...
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
1163
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.fpolext).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
1bc09467   Ilyes Choubani   fixed issue with ...
1164
                                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
67bd858a   Ilyes Choubani   Replication of th...
1188
1189
1190
1191
1192
1193
1194
1195
1196
            idx_filt=where((*!dustem_data.psi_em).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.psi_em).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[-90.00,90.00],psym=8,syms=0.8  
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]
67bd858a   Ilyes Choubani   Replication of th...
1221
1222
                            endif 
                        ENDFOR
1bc09467   Ilyes Choubani   fixed issue with ...
1223
                                                                        
67bd858a   Ilyes Choubani   Replication of th...
1224
1225
1226
1227
1228
1229
                        ;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
1230
                                    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...
1231
1232
1233
                                ENDIF
                            ENDIF
                        endfor
1bc09467   Ilyes Choubani   fixed issue with ...
1234
                        
67bd858a   Ilyes Choubani   Replication of th...
1235
1236
1237
1238
1239
1240
1241
1242
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.psi_em).wav)[idx_spec]
                             yy=dustem_interp[idx_spec]
                             cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
                         ENDIF
1bc09467   Ilyes Choubani   fixed issue with ...
1243
                         
67bd858a   Ilyes Choubani   Replication of th...
1244
1245
1246
1247
1248
1249
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.psi_em).wav)[idx_filt]
                             yy=dustem_interp[idx_filt]
                             cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                         ENDIF
1bc09467   Ilyes Choubani   fixed issue with ...
1250
                         
67bd858a   Ilyes Choubani   Replication of th...
1251
1252
1253
1254
                         
                         ;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 ...
1255
                                
67bd858a   Ilyes Choubani   Replication of th...
1256
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1257
                         
67bd858a   Ilyes Choubani   Replication of th...
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
                            cgplot,((*!dustem_data.psi_em).wav)(idx_spec),((*!dustem_data.psi_em).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.psi_em).sigma)(idx_spec)/2.
                            cgerrplot,((*!dustem_data.psi_em).wav)(idx_spec),((*!dustem_data.psi_em).values)(idx_spec)-rms,((*!dustem_data.psi_em).values)(idx_spec)+rms,color='Powder Blue'

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
                            if ct_spec ne 0 then cgoplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xr=xr,yr=[-90.00,90.00],/xlog else $;,ytickformat='dstmwrp_exp'
                                cgplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,pos=position,/ys,xs=1,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=[-90.00,90.00],/xlog;,ytickformat='dstmwrp_exp'
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.psi_em).sigma)(idx_filt)/2.;/dustem_psi_em(idx_filt)
                            cgerrplot,((*!dustem_data.psi_em).wav)(idx_filt),((*!dustem_data.psi_em).values)(idx_filt)-rms,((*!dustem_data.psi_em).values)(idx_filt)+rms,color='Dodger Blue'
                            
                        endif
                        
                        
                        
07372e26   Ilyes Choubani   Corrected huge pl...
1286
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
                        match2,((*!dustem_data.psi_em).wav),((*!dustem_show.psi_em).wav),show_psi_empts,fit_psi_empts ;only show_psi_empts is needed
                        idx_rmv_psi_em=where(show_psi_empts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
                        ;Locating the hidden spectrum and filter data points                                        
                        idx_filt_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*!dustem_show.psi_em).filt_names)(idx_rmv_psi_em) EQ 'SPECTRUM',ct_spec_hdn)
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
                                cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_spec_hdn)/2.
                                cgerrplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_spec_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn)-rms,(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_spec_hdn)+rms,color='Black'
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
                                cgplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn),pos=position,/xlog,/ys,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=[-90.00,90.00],psym=8,syms=0.8                                           
                                ;stop
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.psi_em).sigma)[idx_rmv_psi_em])(idx_filt_hdn)/2.
                                cgerrplot,(((*!dustem_show.psi_em).wav)[idx_rmv_psi_em])(idx_filt_hdn),(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn)-rms,(((*!dustem_show.psi_em).values)[idx_rmv_psi_em])(idx_filt_hdn)+rms,color='Black'
                                 
                            endif 
                                                           
                        endif 
67bd858a   Ilyes Choubani   Replication of th...
1322
1323
                    
                    endelse 
4b745987   Ilyes Choubani   minor update
1324
               
67bd858a   Ilyes Choubani   Replication of th...
1325
            endelse 
67bd858a   Ilyes Choubani   Replication of th...
1326
1327
1328
1329
1330
           
           
        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...
1331
1332
            
            
4b745987   Ilyes Choubani   minor update
1333
1334
1335
1336
            IF ct_x NE 0 then begin
                xr=xr_x 
                yr=yr_x
            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
        
            idx_filt=where((*!dustem_data.psi_ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*!dustem_data.psi_ext).filt_names EQ 'SPECTRUM',ct_spec)
            
            ;#1) get the plotting keywords (pertaining to each data set) @here when the _extra structure is ready
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
                    cgplot,wavs,wavs*0.,/nodata,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=[-90.00,90.00],psym=8,syms=0.8  
f2caf3f1   Ilyes Choubani   Debugging some er...
1347
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1348
1349
1350
1351
1352
1353
1354
1355
                 
            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
1356
                        
67bd858a   Ilyes Choubani   Replication of th...
1357
                        FOR i=0L,Ngrains-1 DO BEGIN
4b745987   Ilyes Choubani   minor update
1358
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1359
1360
1361
                            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...
1362
1363
1364
1365
                            
                            ;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
1366
                              
67bd858a   Ilyes Choubani   Replication of th...
1367
                            if countneq ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
1368
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1369
                                vecfin = vecto*0.0
67bd858a   Ilyes Choubani   Replication of th...
1370
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1371
                                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...
1372
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1373
1374
                                polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                 
afde94a3   Ilyes Choubani   general update
1375
                                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...
1376
1377
                            endif 
                        ENDFOR
f2caf3f1   Ilyes Choubani   Debugging some er...
1378
                                                                              
67bd858a   Ilyes Choubani   Replication of th...
1379
1380
1381
1382
1383
1384
                        ;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
1385
                                    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...
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
                                ENDIF
                            ENDIF
                        endfor
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
                             xx=((*!dustem_data.psi_ext).wav)[idx_spec]
                             yy=dustem_interp[idx_spec]
1bc09467   Ilyes Choubani   fixed issue with ...
1396
                             cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
1397
1398
1399
1400
1401
1402
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.psi_ext).wav)[idx_filt]
                             yy=dustem_interp[idx_filt]
1bc09467   Ilyes Choubani   fixed issue with ...
1403
                             cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
1404
1405
                         ENDIF
                         
67bd858a   Ilyes Choubani   Replication of th...
1406
1407
                         ;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 ...
1408
                         cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
67bd858a   Ilyes Choubani   Replication of th...
1409
1410
1411
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
67bd858a   Ilyes Choubani   Replication of th...
1412
1413
1414
1415
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
07372e26   Ilyes Choubani   Corrected huge pl...
1416
                            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...
1417
1418
1419
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.psi_ext).sigma)(idx_spec)/2.
1bc09467   Ilyes Choubani   fixed issue with ...
1420
                            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...
1421
1422
1423
1424
1425
1426

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

                                 if ct_spec ne 0 then begin
                                 
                                     rms=3.*((*!dustem_data.qsed).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ; if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                         dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;endelse;,ytickformat='(A1)'
                                     dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),((*!dustem_data.qsed).values)(idx_spec),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,psym=16,syms=0.8     
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.qsed).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                         dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;endelse ;,ytickformat='(A1)'
                                     
                                     dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                         
                                 endif 
                            
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
1818
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1819
                                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 ...
1820
                                    
e0d00de0   Ilyes Choubani   removing stops
1821
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1822
                                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)'
f2caf3f1   Ilyes Choubani   Debugging some er...
1823
                                  
67bd858a   Ilyes Choubani   Replication of th...
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
                            endelse
                            ;stop
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

        
        END
        
        'USED': begin
96a72c8b   Ilyes Choubani   seperating xrange...
1841
            
4b745987   Ilyes Choubani   minor update
1842
1843
1844
1845
1846
1847
            IF ct_m NE 0 then begin
            
                xr=xr_m
                yr=yr_m
                
            ENDIF
96a72c8b   Ilyes Choubani   seperating xrange...
1848
            
1bc09467   Ilyes Choubani   fixed issue with ...
1849
1850
1851
1852
1853
            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...
1854
1855
1856
1857
1858
1859
1860
            ;SIGN-RELATED PARAMETERS/LOOPS HERE?
            ;negative & positive values regardless of data type (SPECTRUM or FILTER data points)
            varvar=where((*!dustem_data.used).values LT 0, testngtv)
            varvar=where((*!dustem_data.used).values GT 0, testpstv)
            ;stop
            idx_filt=where((*!dustem_data.used).filt_names NE 'SPECTRUM', ct_filt)
            idx_spec=where((*!dustem_data.used).filt_names EQ 'SPECTRUM' , ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
1861
            
67bd858a   Ilyes Choubani   Replication of th...
1862
1863
1864
1865
            ;Locating all the hidden data points (spectrum+filter)
            match2,((*!dustem_data.used).wav),((*!dustem_show.used).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
67bd858a   Ilyes Choubani   Replication of th...
1866
1867
1868
1869
1870
1871
1872
1873
            ;#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 ...
1874
                    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...
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
                    cgplot,wavs,wavs,/nodata,/ylog,/xlog,/ys,xs=1,pos=position,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,xtit='',yr=yr,psym=8,syms=0.8  
                    ;cgaxis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10
                    xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                  
                endelse  
                
            
            endif else begin ;when the data is present 
                
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        ;MAJOR LOOP OVER THE SING??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
                
                        IF ct_spec NE 0 THEN BEGIN
                            xx=((*!dustem_data.used).wav)[idx_spec]
                            yy=dustem_interp[idx_spec]
                            rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
1898
1899
1900
1901
1902
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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'
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1903
1904
1905
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1906
                            
67bd858a   Ilyes Choubani   Replication of th...
1907
1908
1909
                            xx=((*!dustem_data.used).wav)[idx_filt]
                            yy=dustem_interp[idx_filt]
                            rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
1910
1911
1912
1913
1914
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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' 
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1915
1916
1917
1918
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
1bc09467   Ilyes Choubani   fixed issue with ...
1919
                        
67bd858a   Ilyes Choubani   Replication of th...
1920
1921
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1922
                        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...
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
                        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...
1943
                                        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...
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
                                            
                                        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...
1958
                                            
67bd858a   Ilyes Choubani   Replication of th...
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/positive_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                        
                                    ENDIF
                                    
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/positive_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/positive_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                        
                        
                        if keyword_set(negative_only) then begin
     
                            if testngtv ne 0 then begin
                            
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
                                    testneq = where(st.polsed.(i+1) ne 0,countneq)
                                    if countneq ne 0 then begin
                                        vecfin = st.polsed.(i+1)*0.0 ;em_tot can be used here right? 
                                        
07372e26   Ilyes Choubani   Corrected huge pl...
1998
                                        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...
1999
2000
                                        
                                        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...
2001
                                         
67bd858a   Ilyes Choubani   Replication of th...
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
                                        dustem_plot_mlog,st.polsed.wav,specugrain,ppositions=position,/negative_only,/overplot,noerase=1,color=use_cols[i],xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                    endif    
                                ENDFOR
                                ;Plotting of the plugins
                                FOR i=0L,n_plgns-1 do begin
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN begin
                                            ;dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i))[*,1],ppositions=position, /overplot, noerase=1, color=clrs_plgns[i], linestyle=2,xr=xr,/xlog
                                            dustem_plot_mlog,st.polsed.wav,(*(*!dustem_plugin).(i).spec)[*,2],ppositions=position,/negative_only,/overplot,noerase=1, color=clrs_plgns[i], linestyle=2 ,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr      
                                        ENDIF
                                    ENDIF
                                ENDFOR
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_spec]
                                    yy=dustem_interp[idx_spec]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position,/overplot, noerase=1, color='red',psym=7,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='Indian Red',psym=7,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr 
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
                                    xx=((*!dustem_data.used).wav)[idx_filt]
                                    yy=dustem_interp[idx_filt]
                                    ;dustem_plot_mlog,xx,yy,ppositions=position, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog
                                    dustem_plot_mlog,xx,yy,ppositions=position,/negative_only, /overplot, noerase=1, color='red',psym=6,syms=2,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr
                                ENDIF
                                
                                ;Plotting of the total dust emission spectrum
                                dustem_plot_mlog,st.polsed.wav,dustem_spec,ppositions=position,/negative_only,/overplot,noerase=1,xr=xr,/xlog,/ylog,ytickformat='(A1)',yr=yr                                    
                            
                            endif
                                    
                        
                        endif
                                                   
                      ;stop             
                    endif else begin ;The data points in the plot that remain unchanged.
                        ;stop
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
                        xyouts,pospltxt[0],pospltxt[1],textoidl('U_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0  
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                        
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2047
2048
                        
                        
67bd858a   Ilyes Choubani   Replication of th...
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
                        if ct_hdnpts then begin
                            idx_filt_hdn_pstv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) gt 0,ct_filt_hdn_pstv)
                            idx_spec_hdn_pstv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) gt 0,ct_spec_hdn_pstv)
                            idx_filt_hdn_ngtv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) NE 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) lt 0,ct_filt_hdn_ngtv)
                            idx_spec_hdn_ngtv = where(((*!dustem_show.used).filt_names)(idx_rmv_sed) EQ 'SPECTRUM' and ((*!dustem_show.used).values)(idx_rmv_sed) lt 0,ct_spec_hdn_ngtv)
                        endif
                        ;stop
                        
                        if keyword_set(positive_only) then begin
                            ;stop
                            if testpstv ne 0 then begin
                            ;stop
                                plotsym, 0
                                
                                 
                                if ct_spec ne 0 then begin
                                
                                    rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
                                    ;dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ;if ct_spec_hdn_pstv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,/overplot,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                        dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
                                    ;endelse;,ytickformat='(A1)'
                                    dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'  ;,charsize=1.15,psym=16,syms=0.8
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
                                    rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-1.*((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    ;if ct_filt_hdn_pstv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),/overplot,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                    dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr
                                    ;endelse;,ytickformat='(A1)'
                                    dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',xtickformat='(A1)',xs=1,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)';,charsize=1.15,psym=16,syms=0.8
                                        
                                endif
                                
                                if ct_hdnpts then begin
                                
                                    if ct_spec_hdn_pstv ne 0 then begin
                                        ;stop
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                        ;stop
                                        xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                    
                                    endif
                                endif   
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2111
                            
07372e26   Ilyes Choubani   Corrected huge pl...
2112
                                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 ...
2113
2114
                                    
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2115
                                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...
2116
                                
67bd858a   Ilyes Choubani   Replication of th...
2117
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
2118
                        
67bd858a   Ilyes Choubani   Replication of th...
2119
                        endif 
18e4331f   Ilyes Choubani   general update (f...
2120
                        
67bd858a   Ilyes Choubani   Replication of th...
2121
                        if keyword_set(negative_only) then begin
18e4331f   Ilyes Choubani   general update (f...
2122
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
                            if testngtv ne 0 then begin
                                 
                                 plotsym, 0
                                 
                                 
                                 if ct_spec ne 0 then begin
                                 
                                     rms=3.*((*!dustem_data.used).sigma)(idx_spec)/2.
                                     ;dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),-((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_spec_hdn_ngtv ne 0 then dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,/overplot,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;endelse;,ytickformat='(A1)'
                                     dustem_plot_mlog,((*!dustem_data.used).wav)(idx_spec),((*!dustem_data.used).values)(idx_spec),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.used).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),-1.*((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
                                     dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;endelse ;,ytickformat='(A1)'
                                     
                                     dustem_plot_mlog,((*!dustem_data.used).wav)(idx_filt),((*!dustem_data.used).values)(idx_filt),ppositions=position,color='Dodger Blue',/negative_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                         
                                 endif
                                 
                                 if ct_hdnpts then begin
                                 
                                     if ct_spec_hdn_ngtv ne 0 then begin
                                         xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
                                         xx = (((*!dustem_show.used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
                                         
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog;,psym=8,syms=0.8
                                     
                                     endif

                                 endif 
18e4331f   Ilyes Choubani   general update (f...
2175
                            
67bd858a   Ilyes Choubani   Replication of th...
2176
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2177
                            
07372e26   Ilyes Choubani   Corrected huge pl...
2178
                                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 ...
2179
2180
                                    
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2181
                                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)'
1bc09467   Ilyes Choubani   fixed issue with ...
2182
                            
f2caf3f1   Ilyes Choubani   Debugging some er...
2183
       
67bd858a   Ilyes Choubani   Replication of th...
2184
2185
2186
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2187
2188
2189
2190
2191
2192
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2193
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2194
            
67bd858a   Ilyes Choubani   Replication of th...
2195
2196
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2197
2198
2199
        
        end
        
afde94a3   Ilyes Choubani   general update
2200
        'QEXT': begin   ;Correct this like you corrected extinction...
1bc09467   Ilyes Choubani   fixed issue with ...
2201
            
4b745987   Ilyes Choubani   minor update
2202
2203
2204
2205
2206
2207
2208
            IF ct_x NE 0 then begin
            
                xr=xr_x 
                yr=yr_x
                
            ENDIF
            
1bc09467   Ilyes Choubani   fixed issue with ...
2209
2210
2211
2212
2213
2214
            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...
2215
2216
            varvar=where((*!dustem_data.qext).values GT 0, testpstv)
            varvar=where((*!dustem_data.qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2217
            
18e4331f   Ilyes Choubani   general update (f...
2218
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2219
2220
            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...
2221
            
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2222
            
18e4331f   Ilyes Choubani   general update (f...
2223
            ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
2224
            match2,((*!dustem_data.qext).wav),((*!dustem_show.qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2225
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2226
            
5f04fa07   Ilyes Choubani   general update
2227
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2228
2229
2230
2231
2232
2233
2234
            
            ;#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...
2235
                    xtit=textoidl('1/\lambda (\mum^{-1})')
bc224f3e   Ilyes Choubani   Update of plottin...
2236
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2237
                    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...
2238
2239
2240
2241
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
18e4331f   Ilyes Choubani   general update (f...
2242
2243
                    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...
2244
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
2245
2246
2247
2248
2249
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2250
                
bc224f3e   Ilyes Choubani   Update of plottin...
2251
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2252
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2253
2254
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
07372e26   Ilyes Choubani   Corrected huge pl...
2255
                        ;MAJOR LOOP OVER THE SIGN??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
c8368c6e   Ilyes Choubani   updating plotting...
2256
                
18e4331f   Ilyes Choubani   general update (f...
2257
                        IF ct_spec NE 0 THEN BEGIN
f2caf3f1   Ilyes Choubani   Debugging some er...
2258
                            
67bd858a   Ilyes Choubani   Replication of th...
2259
                            xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2260
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2261
                            rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
                            
                            ;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  

                                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'
                            endif
18e4331f   Ilyes Choubani   general update (f...
2273
2274
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2275
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2276
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2277
                            xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2278
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2279
                            rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2280
2281
2282
2283
2284
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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' 
                            ENDIF
bc224f3e   Ilyes Choubani   Update of plottin...
2285
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2286
      
bc224f3e   Ilyes Choubani   Update of plottin...
2287
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2288
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2289
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2290
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2291
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2292
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2293
                        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...
2294
2295
2296
2297
2298
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
07372e26   Ilyes Choubani   Corrected huge pl...
2299
                endif else begin ; normal plot 
c8368c6e   Ilyes Choubani   updating plotting...
2300
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2301
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
4b745987   Ilyes Choubani   minor update
2302
                        
18e4331f   Ilyes Choubani   general update (f...
2303
2304
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2305
                            if testpstv ne 0 then begin
4b745987   Ilyes Choubani   minor update
2306
                                
18e4331f   Ilyes Choubani   general update (f...
2307
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2308
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2309
2310
2311
                                    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...
2312
                                    
4b745987   Ilyes Choubani   minor update
2313

5f04fa07   Ilyes Choubani   general update
2314
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2315
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2316
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2317
                                        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
2318
2319
                                        ;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...
2320
2321
2322
                                        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
2323
                                        
5f04fa07   Ilyes Choubani   general update
2324
                                        ;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 ...
2325
                                        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...
2326
                                        
5f04fa07   Ilyes Choubani   general update
2327
                                    endif
4b745987   Ilyes Choubani   minor update
2328
2329
                                    
                                    
18e4331f   Ilyes Choubani   general update (f...
2330
2331
2332
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2333
2334
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2335
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2336
2337
                                         
                                            ;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 ...
2338
                                            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...
2339
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2340
2341
2342
2343
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2344
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2345
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2346
                                    ;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 ...
2347
                                    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...
2348
2349
2350
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2351
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2352
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2353
                                    ;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 ...
2354
                                    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...
2355
2356
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2357
                                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...
2358
                                
18e4331f   Ilyes Choubani   general update (f...
2359
2360
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2361
                        
18e4331f   Ilyes Choubani   general update (f...
2362
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2363
                        
5f04fa07   Ilyes Choubani   general update
2364
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2365
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2366
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2367
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2368
                            
5f04fa07   Ilyes Choubani   general update
2369
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2370
2371
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2372
2373
2374
                                    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
2375
2376
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2377
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2378
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2379
                                        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
2380
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2381
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
4b745987   Ilyes Choubani   minor update
2382
                                        stop
5f04fa07   Ilyes Choubani   general update
2383
                                        ;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 ...
2384
                                        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
2385
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2386
2387
2388
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2389
2390
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2391
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2392
2393
     
                                            ;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 ...
2394
                                            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...
2395
2396
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2397
2398
2399
2400
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2401
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2402
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2403
                                    ;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 ...
2404
                                    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...
2405
2406
2407
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2408
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2409
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2410
                                    ;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 ...
2411
                                    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...
2412
2413
                                ENDIF
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2414
                                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...
2415
2416
2417
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2418
                        
18e4331f   Ilyes Choubani   general update (f...
2419
2420
2421
2422
2423
2424
                        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...
2425
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2426
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2427
                            
2df3360b   Ilyes Choubani   Correcting error:...
2428
2429
2430
2431
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
                        ;idx_filt_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        ;idx_spec_hdn = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
9cb38725   Ilyes Choubani   Fixed tests relat...
2432
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2433
2434
2435
2436
                            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...
2437
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2438
                        
c8368c6e   Ilyes Choubani   updating plotting...
2439
                        
18e4331f   Ilyes Choubani   general update (f...
2440
                        if keyword_set(positive_only) then begin
afde94a3   Ilyes Choubani   general update
2441
                            
2df3360b   Ilyes Choubani   Correcting error:...
2442
                            if testpstv ne 0 then begin
07372e26   Ilyes Choubani   Corrected huge pl...
2443
                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2444
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2445
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2446
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2447
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2448
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2449
2450
2451
                                        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...
2452
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2453
2454
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,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...
2455
2456
2457
2458
2459
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2460
2461
2462
                                        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...
2463
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2464
2465
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,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...
2466
2467
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2468
                                    
18e4331f   Ilyes Choubani   general update (f...
2469
2470
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2471
2472
                                
                                
18e4331f   Ilyes Choubani   general update (f...
2473
2474
                                if ct_spec ne 0 then begin
                                
67bd858a   Ilyes Choubani   Replication of th...
2475
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2476
                                    ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
afde94a3   Ilyes Choubani   general update
2477
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2478
                                    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)'
1bc09467   Ilyes Choubani   fixed issue with ...
2479
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2480
                                    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)'     
1bc09467   Ilyes Choubani   fixed issue with ...
2481
                                     
18e4331f   Ilyes Choubani   general update (f...
2482
2483
2484
2485
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2486
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2487
                                   ; 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)'
1bc09467   Ilyes Choubani   fixed issue with ...
2488
2489
                                    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)'
18e4331f   Ilyes Choubani   general update (f...
2490
2491
                                        
                                endif
0c487640   Ilyes Choubani   corrected missing...
2492
                                
18e4331f   Ilyes Choubani   general update (f...
2493
2494
                            endif else begin
                            
1bc09467   Ilyes Choubani   fixed issue with ...
2495
2496
                            
                                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...
2497
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2498
2499
2500
                                
                                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)'
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
2501

18e4331f   Ilyes Choubani   general update (f...
2502
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
2503
                        
18e4331f   Ilyes Choubani   general update (f...
2504
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2505
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2506
                        
18e4331f   Ilyes Choubani   general update (f...
2507
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
2508
                            
2df3360b   Ilyes Choubani   Correcting error:...
2509
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2510
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2511
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2512
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2513
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2514
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2515
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2516
2517
2518
                                         xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2519
                                         
07372e26   Ilyes Choubani   Corrected huge pl...
2520
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
1bc09467   Ilyes Choubani   fixed issue with ...
2521
                                         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
18e4331f   Ilyes Choubani   general update (f...
2522
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2523
2524
2525
2526
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2527
2528
2529
                                         xx = (((*!dustem_show.qext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.qext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.qext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2530
                                         
1bc09467   Ilyes Choubani   fixed issue with ...
2531
2532
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,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
9cb38725   Ilyes Choubani   Fixed tests relat...
2533
2534
2535
                                     
                                     endif
                                
18e4331f   Ilyes Choubani   general update (f...
2536
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
2537

18e4331f   Ilyes Choubani   general update (f...
2538
2539
                                 if ct_spec ne 0 then begin
                                 
67bd858a   Ilyes Choubani   Replication of th...
2540
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2541
                                     ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2542
                                    ; 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
07372e26   Ilyes Choubani   Corrected huge pl...
2543
                                     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 ...
2544
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
2545
                                     ;endelse;,ytickformat='(A1)'
07372e26   Ilyes Choubani   Corrected huge pl...
2546
                                     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 ...
2547
                                                                              
18e4331f   Ilyes Choubani   general update (f...
2548
2549
2550
2551
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2552
                                     rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2553
                                    ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2554
                                     ;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
07372e26   Ilyes Choubani   Corrected huge pl...
2555
                                     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)'
9cb38725   Ilyes Choubani   Fixed tests relat...
2556
                                     ;endelse ;,ytickformat='(A1)'
18e4331f   Ilyes Choubani   general update (f...
2557
                                     
1bc09467   Ilyes Choubani   fixed issue with ...
2558
                                     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...
2559
2560
                                         
                                 endif 
c8368c6e   Ilyes Choubani   updating plotting...
2561
                            
c8368c6e   Ilyes Choubani   updating plotting...
2562
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2563
2564
2565
                            
                                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)'
                                    
18e4331f   Ilyes Choubani   general update (f...
2566
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2567
                                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...
2568
                                
18e4331f   Ilyes Choubani   general update (f...
2569
                            endelse
5f04fa07   Ilyes Choubani   general update
2570
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2571
2572
2573
2574
2575
2576
2577
2578
2579
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2580
            endelse ; 
18e4331f   Ilyes Choubani   general update (f...
2581
        
67bd858a   Ilyes Choubani   Replication of th...
2582
        end
18e4331f   Ilyes Choubani   general update (f...
2583
        
67bd858a   Ilyes Choubani   Replication of th...
2584
        'UEXT': begin
4b745987   Ilyes Choubani   minor update
2585
2586
2587
2588
2589
2590
2591
            IF ct_x NE 0 then begin
            
                xr=xr_x
                yr=yr_x
                
            ENDIF
                
1bc09467   Ilyes Choubani   fixed issue with ...
2592
2593
2594
2595
            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...
2596
2597
2598
2599
        
            varvar=where((*!dustem_data.uext).values GT 0, testpstv)
            varvar=where((*!dustem_data.uext).values LT 0, testngtv)
            
18e4331f   Ilyes Choubani   general update (f...
2600
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2601
2602
            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...
2603
            
18e4331f   Ilyes Choubani   general update (f...
2604
2605
2606
2607
2608
            ;Plotting of frequency axis
            ;cgaxis, xaxis=1, xlog=1, xs=1, xminor=10;, xticklen=0.05, xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),charsize=1.15,title=textoidl('\nu (GHz)') 
            
            ;stop
            ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
2609
            match2,((*!dustem_data.uext).wav),((*!dustem_show.uext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2610
2611
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
            
67bd858a   Ilyes Choubani   Replication of th...
2612
            
18e4331f   Ilyes Choubani   general update (f...
2613
2614
2615
            ;#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...
2616
                
18e4331f   Ilyes Choubani   general update (f...
2617
2618
                if keyword_set(norm) then begin ;normalized plot
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
2619
                    xtit=textoidl('1/\lambda (\mum^{-1})')
18e4331f   Ilyes Choubani   general update (f...
2620
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2621
                    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...
2622
2623
2624
2625
2626
2627
                    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...
2628
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
                  
                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...
2642
                            
67bd858a   Ilyes Choubani   Replication of th...
2643
                            xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2644
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2645
                            rms=3.*((*!dustem_data.uext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2646
2647
2648
2649
2650
2651
                            
                            indzero = where(yy NE 0, ct_zero)
                            If ct_zero NE 0 THEN BEGIN
                                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'
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
2652
2653
2654
2655
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2656
                            xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2657
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2658
                            rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2659
2660
2661
2662
2663
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
                                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' 
                            ENDIF
18e4331f   Ilyes Choubani   general update (f...
2664
2665
2666
2667
2668
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2669
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2670
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2671
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2672
                        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...
2673
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
18e4331f   Ilyes Choubani   general update (f...
2674
2675
2676
2677
                    
                    endelse
                    
                
67bd858a   Ilyes Choubani   Replication of th...
2678
                endif else begin ; normal plot - STOPPED HERE FOR QSED
18e4331f   Ilyes Choubani   general update (f...
2679
2680
                              
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
53548c91   Ilyes Choubani   Display of frozen...
2681
                        
18e4331f   Ilyes Choubani   general update (f...
2682
2683
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2684
                            if testpstv ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2685
                                
18e4331f   Ilyes Choubani   general update (f...
2686
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2687
2688
2689
                                
                                    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
2690
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2691
                                    testneq = where( vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
2692
                                    ;stop
5f04fa07   Ilyes Choubani   general update
2693
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2694
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
67bd858a   Ilyes Choubani   Replication of th...
2695
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2696
                                        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...
2697
2698
                                        ;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...
2699
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2700
                                        
67bd858a   Ilyes Choubani   Replication of th...
2701
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2702
                                        ;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 ...
2703
                                        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...
2704
2705
                                        ;stop
                                    endif
5f04fa07   Ilyes Choubani   general update
2706
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2707
                                ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
2708
                                
18e4331f   Ilyes Choubani   general update (f...
2709
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2710
2711
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2712
2713
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
                                         
3c479f24   Ilyes Choubani   Allowing to fix p...
2714
                                            ;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 ...
2715
                                            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...
2716
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2717
                                    ENDIF
18e4331f   Ilyes Choubani   general update (f...
2718
2719
2720
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2721
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2722
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2723
                                    ;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 ...
2724
                                    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...
2725
2726
2727
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2728
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2729
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2730
                                    ;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 ...
2731
                                    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...
2732
2733
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2734
                                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...
2735
2736
2737
2738
2739
2740
                            
                            endif
                                    
                        
                        endif
                        
67bd858a   Ilyes Choubani   Replication of th...
2741
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2742
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2743
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2744
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2745
                            
f2caf3f1   Ilyes Choubani   Debugging some er...
2746
                                    
18e4331f   Ilyes Choubani   general update (f...
2747
2748
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2749
2750
2751
                                    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...
2752
2753
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2754
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
67bd858a   Ilyes Choubani   Replication of th...
2755
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2756
                                        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...
2757
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2758
                                        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...
2759
                                        ;stop
5f04fa07   Ilyes Choubani   general update
2760
                                        ;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 ...
2761
                                        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...
2762
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2763
2764
                                ENDFOR
                                ;Plotting of the plugins
67bd858a   Ilyes Choubani   Replication of th...
2765
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2766
2767
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2768
2769
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
     
3c479f24   Ilyes Choubani   Allowing to fix p...
2770
                                            ;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 ...
2771
                                            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...
2772
                                        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2773
                                        
18e4331f   Ilyes Choubani   general update (f...
2774
                                    ENDIF
67bd858a   Ilyes Choubani   Replication of th...
2775
                                endfor
18e4331f   Ilyes Choubani   general update (f...
2776
2777
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2778
                                    xx=((*!dustem_data.uext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2779
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2780
                                    ;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 ...
2781
                                    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...
2782
2783
2784
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2785
                                    xx=((*!dustem_data.uext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2786
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2787
                                    ;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 ...
2788
                                    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...
2789
                                ENDIF
18e4331f   Ilyes Choubani   general update (f...
2790
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2791
                                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...
2792
                            
18e4331f   Ilyes Choubani   general update (f...
2793
2794
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2795
2796
                        
                        endif
18e4331f   Ilyes Choubani   general update (f...
2797
2798
                                                   
                      ;stop             
67bd858a   Ilyes Choubani   Replication of th...
2799
                    endif else begin ;The data points in the plot that remain unchanged.; DO NOT USE AN ELSE HERE. 
bc224f3e   Ilyes Choubani   Update of plottin...
2800
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2801
                        ;cgaxis, xaxis=1,xlog=1, xs=1,charsize=1.5,xtickformat='(A1)'
94c4dffa   Ilyes Choubani   update + fixes fo...
2802
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{UEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2803
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
67bd858a   Ilyes Choubani   Replication of th...
2804
                            
2df3360b   Ilyes Choubani   Correcting error:...
2805
2806
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
67bd858a   Ilyes Choubani   Replication of th...
2807
2808
                        ;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...
2809
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2810
2811
2812
2813
                            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...
2814
                        endif
67bd858a   Ilyes Choubani   Replication of th...
2815
                        
18e4331f   Ilyes Choubani   general update (f...
2816
2817
                        
                        if keyword_set(positive_only) then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2818
                            
2df3360b   Ilyes Choubani   Correcting error:...
2819
                            if testpstv ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2820
                            
67bd858a   Ilyes Choubani   Replication of th...
2821
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2822
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2823
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2824
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2825
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2826
2827
2828
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2829
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2830
2831
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                        dustem_plot_mlog,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
18e4331f   Ilyes Choubani   general update (f...
2832
                                    
9cb38725   Ilyes Choubani   Fixed tests relat...
2833
2834
2835
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2836
2837
2838
2839
                                    
                                        xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_pstv)
                                        rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_pstv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2840
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2841
2842
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                        dustem_plot_mlog,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...
2843
2844
                                    
                                    endif
67bd858a   Ilyes Choubani   Replication of th...
2845
2846
2847
2848
2849
2850
2851
2852
2853
                                    
                                endif
                                
                                
                                
                                if ct_spec ne 0 then begin
                                
                                    rms=3.*((*!dustem_data.uext).sigma)(idx_spec)/2.
                                    ;dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_spec),-((*!dustem_data.qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
e9bb0ce2   Ilyes Choubani   Correcting small ...
2854
2855
                                    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...
2856
2857
2858
2859
2860
2861
2862
                                 
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
                                    rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
2863
2864
                                    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...
2865
2866
                                        
                                endif
2df3360b   Ilyes Choubani   Correcting error:...
2867
                            endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2868
                                
e9bb0ce2   Ilyes Choubani   Correcting small ...
2869
                                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...
2870
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2871
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2872
                                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...
2873
                                   
07372e26   Ilyes Choubani   Corrected huge pl...
2874
                                
67bd858a   Ilyes Choubani   Replication of th...
2875
                            endelse                           
18e4331f   Ilyes Choubani   general update (f...
2876
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2877
                        
18e4331f   Ilyes Choubani   general update (f...
2878
2879
                        endif 
                        
67bd858a   Ilyes Choubani   Replication of th...
2880
                        
18e4331f   Ilyes Choubani   general update (f...
2881
                        if keyword_set(negative_only) then begin
67bd858a   Ilyes Choubani   Replication of th...
2882
                            
2df3360b   Ilyes Choubani   Correcting error:...
2883
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2884
                                 
67bd858a   Ilyes Choubani   Replication of th...
2885
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2886
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2887
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2888
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2889
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2890
2891
2892
                                         xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2893
                                         
1bc09467   Ilyes Choubani   fixed issue with ...
2894
2895
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
                                         dustem_plot_mlog,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
18e4331f   Ilyes Choubani   general update (f...
2896
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2897
                                     endif 
18e4331f   Ilyes Choubani   general update (f...
2898
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2899
2900
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2901
2902
2903
                                         xx = (((*!dustem_show.uext).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         yy = (((*!dustem_show.uext).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                         rms=3.*(((*!dustem_show.uext).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
9cb38725   Ilyes Choubani   Fixed tests relat...
2904
                                         
1bc09467   Ilyes Choubani   fixed issue with ...
2905
2906
                                         dustem_plot_mlog,1/xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
                                         dustem_plot_mlog,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
9cb38725   Ilyes Choubani   Fixed tests relat...
2907
2908
                                     
                                     endif
67bd858a   Ilyes Choubani   Replication of th...
2909
2910
                                
                                 endif
18e4331f   Ilyes Choubani   general update (f...
2911

67bd858a   Ilyes Choubani   Replication of th...
2912
                                 if ct_spec ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2913
                                     
67bd858a   Ilyes Choubani   Replication of th...
2914
2915
2916
                                     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
e9bb0ce2   Ilyes Choubani   Correcting small ...
2917
                                     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...
2918
                                     ;endelse;,ytickformat='(A1)'
e9bb0ce2   Ilyes Choubani   Correcting small ...
2919
                                     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...
2920
2921
2922
2923
2924
2925
2926
2927
                                  
                                 endif
                                 
                                 if ct_filt ne 0 then begin
                                     
                                     rms=3.*((*!dustem_data.uext).sigma)(idx_filt)/2.
                                    ; dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),-1.*((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                     ;if ct_filt_hdn_ngtv ne 0 then  dustem_plot_mlog,((*!dustem_data.qsed).wav)(idx_filt),((*!dustem_data.qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',/overplot,psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2928
                                         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...
2929
2930
                                     ;endelse ;,ytickformat='(A1)'
                                     
1bc09467   Ilyes Choubani   fixed issue with ...
2931
                                     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...
2932
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
2933
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2934
                            
2df3360b   Ilyes Choubani   Correcting error:...
2935
                            endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2936
                                
e9bb0ce2   Ilyes Choubani   Correcting small ...
2937
                                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 ...
2938
                                    
18e4331f   Ilyes Choubani   general update (f...
2939
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2940
2941
                                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)'
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
2942
                        
2df3360b   Ilyes Choubani   Correcting error:...
2943
                            endelse
5f04fa07   Ilyes Choubani   general update
2944
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2945
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2946
2947
2948
2949
                        
                    
                    endelse 
                
bc224f3e   Ilyes Choubani   Update of plottin...
2950
2951
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2952
            endelse 
b5314324   Ilyes Choubani   updating the plot...
2953
2954
        
        end
5f04fa07   Ilyes Choubani   general update
2955
2956
        
        'PARAMETERS':begin ;needs the followingd data (errors+res+formats)
e9bb0ce2   Ilyes Choubani   Correcting small ...
2957
         
5f04fa07   Ilyes Choubani   general update
2958
2959
2960
2961
2962
            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...
2963
    
5f04fa07   Ilyes Choubani   general update
2964
                k=0    
5f04fa07   Ilyes Choubani   general update
2965
                
53548c91   Ilyes Choubani   Display of frozen...
2966
2967
2968
2969
2970
2971
2972
                    
                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
2973
                        
53548c91   Ilyes Choubani   Display of frozen...
2974
2975
2976
2977
2978
2979
2980
                        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
2981
                        
53548c91   Ilyes Choubani   Display of frozen...
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
                    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...
2998
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
fcb6eade   Ilyes Choubani   general update - ...
2999
3000
                    
                    
53548c91   Ilyes Choubani   Display of frozen...
3001
3002
3003
3004
3005
                    res = dustem_interp
                    errors = dustem_spec
                    yypostmp = yypos
                    k=0
                    FOR i=0L,Npar-1 DO BEGIN   
fcb6eade   Ilyes Choubani   general update - ...
3006
                      
53548c91   Ilyes Choubani   Display of frozen...
3007
3008
3009
3010
3011
                      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 - ...
3012
                          
53548c91   Ilyes Choubani   Display of frozen...
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
                            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 ...
3037
                        
fcb6eade   Ilyes Choubani   general update - ...
3038
                        
53548c91   Ilyes Choubani   Display of frozen...
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
                        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 - ...
3065
                        
fcb6eade   Ilyes Choubani   general update - ...
3066
                        
53548c91   Ilyes Choubani   Display of frozen...
3067
                    ENDFOR        
fcb6eade   Ilyes Choubani   general update - ...
3068
                    
53548c91   Ilyes Choubani   Display of frozen...
3069
                ENDIF                        
5f04fa07   Ilyes Choubani   general update
3070
3071
                
            endif else begin ;data in the parameter window that is unchanged 
e9bb0ce2   Ilyes Choubani   Correcting small ...
3072
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3073
3074
3075
                ;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...
3076
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3077
3078
3079
3080
3081
                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...
3082
3083
3084
3085
3086
                    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...
3087
                    xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
e9bb0ce2   Ilyes Choubani   Correcting small ...
3088
3089
3090
3091
3092
                    
                    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...
3093
3094
3095
3096
3097
3098
3099
3100
3101
                        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 ...
3102
                            
53548c91   Ilyes Choubani   Display of frozen...
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
                            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 ...
3113
                        
53548c91   Ilyes Choubani   Display of frozen...
3114
                        ENDIF    
e9bb0ce2   Ilyes Choubani   Correcting small ...
3115
                         
53548c91   Ilyes Choubani   Display of frozen...
3116
                    ENDFOR  
e9bb0ce2   Ilyes Choubani   Correcting small ...
3117
3118
3119
3120
                     
                ENDIF
                
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3121
                
5f04fa07   Ilyes Choubani   general update
3122
                ;stop
0c487640   Ilyes Choubani   corrected missing...
3123
                xxpos = 0.0;might need to be modified
53548c91   Ilyes Choubani   Display of frozen...
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
                
                ;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...
3138
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3139
3140
3141
3142
                
                    cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal

                    xxpos=(1-thiswidth)/2
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3143
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3144
3145
3146
3147
3148
                
                    ;stop
                    k=0   
                    res = dustem_interp
                    errors = dustem_spec
5f04fa07   Ilyes Choubani   general update
3149
                ;stop
53548c91   Ilyes Choubani   Display of frozen...
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
                
                    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 ...
3160
                        
53548c91   Ilyes Choubani   Display of frozen...
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
                      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
3185
                        
53548c91   Ilyes Choubani   Display of frozen...
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
                          ;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 - ...
3208
                    
fcb6eade   Ilyes Choubani   general update - ...
3209
                ENDIF
53548c91   Ilyes Choubani   Display of frozen...
3210
                    
5f04fa07   Ilyes Choubani   general update
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
                
            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...
3224
3225
3226
3227
3228
3229
                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
3230
                        
53548c91   Ilyes Choubani   Display of frozen...
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
                        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...
3256
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
                    
                    
                    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
3290
                            
53548c91   Ilyes Choubani   Display of frozen...
3291
3292
3293
3294
3295
3296
                        ENDIF          
                                
                    
                    ENDFOR
                
             ENDIF
5f04fa07   Ilyes Choubani   general update
3297
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3298
            endif else begin ;(FROZEN RUN = title strings + fixed plugins (TBDONE))
5f04fa07   Ilyes Choubani   general update
3299
                
53548c91   Ilyes Choubani   Display of frozen...
3300
3301
3302
                
                
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
5f04fa07   Ilyes Choubani   general update
3303
                    
53548c91   Ilyes Choubani   Display of frozen...
3304
3305
3306
3307
3308
3309
3310
3311
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
                    k = 0
                    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...
3312
                    xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
5f04fa07   Ilyes Choubani   general update
3313
                    
53548c91   Ilyes Choubani   Display of frozen...
3314
3315
3316
3317
3318
3319
3320
                    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
3321
                        
53548c91   Ilyes Choubani   Display of frozen...
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
                            
                            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
3343
                         
53548c91   Ilyes Choubani   Display of frozen...
3344
3345
3346
3347
                    ENDFOR  
                     
                ENDIF
                
0c487640   Ilyes Choubani   corrected missing...
3348
                xxpos = 0
53548c91   Ilyes Choubani   Display of frozen...
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
                
                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...
3362
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3363
3364
3365
3366
3367
                     ;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...
3368
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3369
3370
3371
3372
3373
3374
3375
                    
                    
                    k=0
                    res = dustem_interp
                    errors = dustem_spec
                    yypos-=0.1
                    yypostmp = yypos
5f04fa07   Ilyes Choubani   general update
3376
                        
53548c91   Ilyes Choubani   Display of frozen...
3377
3378
3379
3380
                    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
3381
                        
5f04fa07   Ilyes Choubani   general update
3382
                        
53548c91   Ilyes Choubani   Display of frozen...
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
                        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
3409
                    
53548c91   Ilyes Choubani   Display of frozen...
3410
3411
                    ENDFOR
                ENDIF
5f04fa07   Ilyes Choubani   general update
3412
3413
3414
3415
            endelse
         
        
        
5f04fa07   Ilyes Choubani   general update
3416
3417
        end
        
b5314324   Ilyes Choubani   updating the plot...
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
    
    endcase


endif










b5314324   Ilyes Choubani   updating the plot...
3433
END