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

                        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
419
420
                            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...
421
422
423
424
                            
                            
                            ;Plotting of the filter error points
                            rms=3.*((*!dustem_data.ext).sigma)(idx_filt)/2.;/dustem_sed(idx_filt)
afde94a3   Ilyes Choubani   general update
425
                            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...
426
427
428
429
430
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
afde94a3   Ilyes Choubani   general update
431
                        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...
432
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
433
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
434
435
436
437
438
439
440
441
442
443
444
445
                         
                        ;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
446
                                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...
447
448
449
                                
                                ;Plotting of hidden spectrum error points
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
450
                                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...
451
452
453
454
                            endif                                            
                            
                            if ct_filt_hdn then begin
                            ;Plotting of hidden filter data points 
afde94a3   Ilyes Choubani   general update
455
                                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...
456
457
458
                                
                                ;Plotting of hidden filter error point
                                rms=3.*(((*!dustem_show.ext).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
459
                                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...
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    ;endelse 
                    endif
                
                
                ;endelse 
                endif            
            ;endelse
            endif
          
b5314324   Ilyes Choubani   updating the plot...
476
477
478
        
        end
        
67bd858a   Ilyes Choubani   Replication of th...
479
480
        'POLEXT': begin 
            
96a72c8b   Ilyes Choubani   seperating xrange...
481
            IF ct_x NE 0 then xr=xr_x & yr=yr_x
afde94a3   Ilyes Choubani   general update
482
483
484
485
486
487
            
            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...
488
489
            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...
490
491
492
493
494
495
496
            
            ;#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...
497
                    xtit=textoidl('1/\lambda (\mum^{_1})')
18e4331f   Ilyes Choubani   general update (f...
498
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
499
                    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...
500
501
502
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
afde94a3   Ilyes Choubani   general update
503
                    ;/NODATA
18e4331f   Ilyes Choubani   general update (f...
504
                    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...
505
506
                    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...
507
508
509
510
511
512
513
514
515
516
517
                  
                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...
518
                            
67bd858a   Ilyes Choubani   Replication of th...
519
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
520
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
521
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
522
523
524
525
526
527
528
529
                            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...
530
531
532
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
533
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
534
                            yy=dustem_interp[idx_filt]
94c4dffa   Ilyes Choubani   update + fixes fo...
535
536
537
538
539
540
541
542
                            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...
543
544
545
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
546
                    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...
547
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
548
                        xtit=textoidl('1/\lambda (\mum^{-1})')
18e4331f   Ilyes Choubani   general update (f...
549
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
550
                        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...
551
552
553
554
555
556
557
558
559
560
561
                        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...
562
563
                            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...
564
565
566
567
568
569
                        ENDFOR
                        
                        ;stop
                                                
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
570
                            If isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
571
                                IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
afde94a3   Ilyes Choubani   general update
572
                                    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...
573
574
                                ENDIF 
                            endif
18e4331f   Ilyes Choubani   general update (f...
575
576
577
578
579
580
                        endfor
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
67bd858a   Ilyes Choubani   Replication of th...
581
                            xx=((*!dustem_data.polext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
582
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
583
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
584
585
586
587
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
588
                            xx=((*!dustem_data.polext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
589
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
590
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
591
592
593
                        ENDIF
                        
                        ;Plotting of the total dust emission spectru
afde94a3   Ilyes Choubani   general update
594
                        cgoplot,1/st.polext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
5f04fa07   Ilyes Choubani   general update
595
                        ;cgoplot,st.polsed.wav,st.polsed.em_tot*fact,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
18e4331f   Ilyes Choubani   general update (f...
596
597
598
599
600
601
602
603
                                        
                                
                    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
604
                            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...
605
606
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
607
                            rms=3.*((*!dustem_data.polext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
608
                            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...
609
610
611
612
613
614

                        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
615
616
                            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...
617
618
619
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
620
                            rms=3.*((*!dustem_data.polext).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
afde94a3   Ilyes Choubani   general update
621
                            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...
622
623
624
625
626
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
94c4dffa   Ilyes Choubani   update + fixes fo...
627
                        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...
628
                        
94c4dffa   Ilyes Choubani   update + fixes fo...
629
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{PEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
18e4331f   Ilyes Choubani   general update (f...
630
631
                         
                        ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
632
633
                        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:...
634
                        ;Locating the hidden spectrum and filter data points                                        
67bd858a   Ilyes Choubani   Replication of th...
635
636
                        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:...
637
                        
1355825c   Ilyes Choubani   General update
638
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
639
640
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
641
642
643
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
afde94a3   Ilyes Choubani   general update
644
                                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...
645
646
                                
                                ;Plotting of hidden spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
647
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
afde94a3   Ilyes Choubani   general update
648
                                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...
649
650
                            endif                                            
                            
1355825c   Ilyes Choubani   General update
651
                            if ct_filt_hdn ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
652
                            ;Plotting of hidden filter data points 
afde94a3   Ilyes Choubani   general update
653
                                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...
654
655
                                
                                ;Plotting of hidden filter error point
67bd858a   Ilyes Choubani   Replication of th...
656
                                rms=3.*(((*!dustem_show.polext).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
afde94a3   Ilyes Choubani   general update
657
                                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...
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
67bd858a   Ilyes Choubani   Replication of th...
673
        
b5314324   Ilyes Choubani   updating the plot...
674
675
        end
        
67bd858a   Ilyes Choubani   Replication of th...
676
        'POLSED': begin 
1bc09467   Ilyes Choubani   fixed issue with ...
677
            
96a72c8b   Ilyes Choubani   seperating xrange...
678
            IF ct_m NE 0 then xr=xr_m & yr=yr_m
1bc09467   Ilyes Choubani   fixed issue with ...
679
680
681
682
683
            
            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...
684
685
686
            
            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
687
688
689
690
691
            
            ;#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...
692
693
694
695
                if keyword_set(norm) then begin ;normalized plot
                    
                    xtit=textoidl('\lambda (\mum)')
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
696
                    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...
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
                    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
713
                        
67bd858a   Ilyes Choubani   Replication of th...
714
715
716
717
                        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...
718
719
720
721
722
                            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...
723
                        ENDIF
1355825c   Ilyes Choubani   General update
724
                        
67bd858a   Ilyes Choubani   Replication of th...
725
726
727
                        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...
728
729
730
731
732
733
                            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...
734
735
                        ENDIF
                            
1355825c   Ilyes Choubani   General update
736
                        
67bd858a   Ilyes Choubani   Replication of th...
737
                    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 ...
738
                        
67bd858a   Ilyes Choubani   Replication of th...
739
740
                        xtit=textoidl('\lambda (\mum)')
                        if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
741
                        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...
742
743
744
745
746
747
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
                endif else begin ; normal plot
1355825c   Ilyes Choubani   General update
748
                        
67bd858a   Ilyes Choubani   Replication of th...
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
                    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...
817
                        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...
818
819
820
821
822
823
824
825
826
827
828
829
830
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
                        
                        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...
866
867
            
            IF ct_m NE 0 then xr=xr_m & yr=yr_m
67bd858a   Ilyes Choubani   Replication of th...
868
869
870
871
872
873
874
875
876
        
            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...
877
                    xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
878
879
880
881
                 
            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...
882
                          
67bd858a   Ilyes Choubani   Replication of th...
883
                        FOR i=0L,Ngrains-1 DO BEGIN
1355825c   Ilyes Choubani   General update
884
                            
5f04fa07   Ilyes Choubani   general update
885
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
886
                            
5f04fa07   Ilyes Choubani   general update
887
888
889
                            if countneq ne 0 then begin 
                                vecfin = st.polsed.(i+1)*0.0
                                
07372e26   Ilyes Choubani   Corrected huge pl...
890
891
                                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
892
893
                                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
894
895
896
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
897
                         
1355825c   Ilyes Choubani   General update
898
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
899
                            
3c479f24   Ilyes Choubani   Allowing to fix p...
900
901
902
903
904
905
906
907
908
                            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
909
                            
1355825c   Ilyes Choubani   General update
910
911
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
912
913
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
914
915
916
917
918
919
                        
                         ;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
920
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
921
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
922
923
924
925
926
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
                             xx=((*!dustem_data.polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
927
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
928
929
930
931
932
                             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
933
                         cgoplot,st.polsed.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs               
1355825c   Ilyes Choubani   General update
934
935
936
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
937

1355825c   Ilyes Choubani   General update
938
                        ;Spectrum points are treated before for plotting reasons. 
9cb38725   Ilyes Choubani   Fixed tests relat...
939
                        
1355825c   Ilyes Choubani   General update
940
941
942
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
5f04fa07   Ilyes Choubani   general update
943
                            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
944
945
946
947
948
949
950
951
952
953
                            
                            ;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
954
955
                            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
956
957
958
959
960
961
962
963
964
965
                            
                            
                            ;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...
966
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
967
968
969
970
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
abebbdf3   Ilyes Choubani   General update: A...
971
                        match2,((*!dustem_data.polfrac).wav),((*!dustem_show.polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
1355825c   Ilyes Choubani   General update
972
973
                        idx_rmv_polfrac=where(show_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
974
975
976
                        ;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
977
978
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
979
980
981
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
5f04fa07   Ilyes Choubani   general update
982
                                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
983
984
985
986
987
988
989
990
991
992
                                
                                ;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
993
                                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
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
                                ;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...
1007
1008
1009
        
        end
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
1010
        'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
96a72c8b   Ilyes Choubani   seperating xrange...
1011
1012
1013
            
            IF ct_x NE 0 then xr=xr_x & yr=yr_x
            
67bd858a   Ilyes Choubani   Replication of th...
1014
1015
            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...
1016
            
18e4331f   Ilyes Choubani   general update (f...
1017
1018
1019
1020
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
94c4dffa   Ilyes Choubani   update + fixes fo...
1021
1022
                    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...
1023
1024
1025
1026
1027
                 
            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...
1028
                        
18e4331f   Ilyes Choubani   general update (f...
1029
                        FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1030
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1031
1032
1033
                            vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
                            
                            testneq = where(vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
1034
1035
                            
                            if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
1036
                                vecfin = vecto*0.0
5f04fa07   Ilyes Choubani   general update
1037
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1038
                                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...
1039
                                 
94c4dffa   Ilyes Choubani   update + fixes fo...
1040
                                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...
1041
                            endif   
18e4331f   Ilyes Choubani   general update (f...
1042
                        ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
1043
1044
1045
                       
                        ;Plotting of the plugins. 
                         
18e4331f   Ilyes Choubani   general update (f...
1046
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1047
1048
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
1049
1050
1051
1052
                            
                                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
1053
                                    cgoplot,1/st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
1054
                                
3c479f24   Ilyes Choubani   Allowing to fix p...
1055
                                ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1056
1057
                            endif
                            
18e4331f   Ilyes Choubani   general update (f...
1058
                        endfor
67bd858a   Ilyes Choubani   Replication of th...
1059
                       
67bd858a   Ilyes Choubani   Replication of th...
1060
                       
18e4331f   Ilyes Choubani   general update (f...
1061
1062
1063
1064
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
67bd858a   Ilyes Choubani   Replication of th...
1065
                             xx=((*!dustem_data.fpolext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1066
                             yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
1067
                             cgoplot,1/xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
1068
1069
1070
1071
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
1072
                             xx=((*!dustem_data.fpolext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1073
                             yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
1074
                             cgoplot,1/xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
1075
1076
1077
1078
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
1079
                         cgoplot,1/st.polext.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
67bd858a   Ilyes Choubani   Replication of th...
1080
                                        
18e4331f   Ilyes Choubani   general update (f...
1081
1082
                                
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1083
                         
18e4331f   Ilyes Choubani   general update (f...
1084
1085
                        
                        ;Spectrum points are treated before for plotting reasons. 
67bd858a   Ilyes Choubani   Replication of th...
1086
                        
18e4331f   Ilyes Choubani   general update (f...
1087
1088
1089
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
94c4dffa   Ilyes Choubani   update + fixes fo...
1090
                            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...
1091
1092
                            
                            ;Plotting of the spectrum error points
67bd858a   Ilyes Choubani   Replication of th...
1093
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_spec)/2.
afde94a3   Ilyes Choubani   general update
1094
                            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...
1095
1096
1097
1098
1099
1100

                        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...
1101
1102
                            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...
1103
1104
1105
                            
                            
                            ;Plotting of the filter error points
67bd858a   Ilyes Choubani   Replication of th...
1106
                            rms=3.*((*!dustem_data.fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
afde94a3   Ilyes Choubani   general update
1107
                            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...
1108
1109
1110
1111
1112
                            
                        endif
                        
                        
                        
94c4dffa   Ilyes Choubani   update + fixes fo...
1113
                        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...
1114
1115
1116
1117
1118
1119
                         
                        ;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...
1120
                        
67bd858a   Ilyes Choubani   Replication of th...
1121
1122
1123
1124
1125
1126
1127
1128
                        ;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...
1129
                                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...
1130
1131
1132
                                
                                ;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 ...
1133
                                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...
1134
1135
1136
1137
1138
1139
                            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...
1140
                                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...
1141
1142
1143
                                ;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 ...
1144
                                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...
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
                                 
                            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
            
96a72c8b   Ilyes Choubani   seperating xrange...
1162
1163
            IF ct_m NE 0 then xr=xr_m & yr=yr_m
            
67bd858a   Ilyes Choubani   Replication of th...
1164
1165
1166
1167
1168
1169
1170
1171
1172
            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...
1173
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1174
1175
1176
1177
1178
                 
            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...
1179
1180
1181
1182
1183
1184
1185
                        
                        ;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...
1186
                                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...
1187
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1188
1189
                                ;*****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...
1190
1191
1192
1193
1194
1195
1196
                                
                                ;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...
1197
1198
                            endif 
                        ENDFOR
1bc09467   Ilyes Choubani   fixed issue with ...
1199
                                                                        
67bd858a   Ilyes Choubani   Replication of th...
1200
1201
1202
1203
1204
1205
                        ;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
1206
                                    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...
1207
1208
1209
                                ENDIF
                            ENDIF
                        endfor
1bc09467   Ilyes Choubani   fixed issue with ...
1210
                        
67bd858a   Ilyes Choubani   Replication of th...
1211
1212
1213
1214
1215
1216
1217
1218
                         ;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 ...
1219
                         
67bd858a   Ilyes Choubani   Replication of th...
1220
1221
1222
1223
1224
1225
                         
                         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 ...
1226
                         
67bd858a   Ilyes Choubani   Replication of th...
1227
1228
1229
1230
                         
                         ;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 ...
1231
                                
67bd858a   Ilyes Choubani   Replication of th...
1232
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1233
                         
67bd858a   Ilyes Choubani   Replication of th...
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
                        
                        ;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...
1262
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
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 
                        
                        
                           
                        ;stop
                        
                        
                        
                        
                        
                        
                    
                    endelse 
                
                
                
                ;endelse 
            
            endelse 
        ;stop
           
           
        end
        
        'PSI_EXT': begin ;MODIFYING THIS NOW - You should write a plugin for the modification of polarized extinction so that !dustem_psi_ext is different than !dustem_psi. 
96a72c8b   Ilyes Choubani   seperating xrange...
1322
1323
1324
            
            
            IF ct_x NE 0 then xr=xr_x & yr=yr_x
67bd858a   Ilyes Choubani   Replication of th...
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
        
            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...
1335
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1336
1337
1338
1339
1340
1341
1342
1343
1344
                 
            endif else begin ;when the data is present ; normal plot     
                        
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
                        ;##################TAKEN FROM SED
                        
                        ;Plotting of the spectra of the dust species
                        FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
1345
1346
1347
                            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...
1348
1349
1350
1351
1352
                            
                            ;testing whether the polext values contain negative ones
                            testpos = where(vecto LT 0, countpos)
                            IF countpos NE 0 THEN vecto[testpos] = 0
                          
67bd858a   Ilyes Choubani   Replication of th...
1353
                            if countneq ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
1354
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1355
                                vecfin = vecto*0.0
67bd858a   Ilyes Choubani   Replication of th...
1356
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1357
                                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...
1358
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
1359
1360
                                polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
                                 
afde94a3   Ilyes Choubani   general update
1361
                                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...
1362
1363
                            endif 
                        ENDFOR
f2caf3f1   Ilyes Choubani   Debugging some er...
1364
                                                                              
67bd858a   Ilyes Choubani   Replication of th...
1365
1366
1367
1368
1369
1370
                        ;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
1371
                                    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...
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
                                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 ...
1382
                             cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
1383
1384
1385
1386
1387
1388
                         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 ...
1389
                             cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
1390
1391
                         ENDIF
                         
67bd858a   Ilyes Choubani   Replication of th...
1392
1393
                         ;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 ...
1394
                         cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs               
67bd858a   Ilyes Choubani   Replication of th...
1395
1396
1397
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
67bd858a   Ilyes Choubani   Replication of th...
1398
1399
1400
1401
                        ;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...
1402
                            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...
1403
1404
1405
                            
                            ;Plotting of the spectrum error points
                            rms=3.*((*!dustem_data.psi_ext).sigma)(idx_spec)/2.
1bc09467   Ilyes Choubani   fixed issue with ...
1406
                            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...
1407
1408
1409
1410
1411
1412

                        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 ...
1413
1414
                            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...
1415
1416
1417
1418
                            
                            
                            ;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 ...
1419
                            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...
1420
1421
1422
1423
1424
                            
                        endif
                        
                        
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
1425
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi_{EXT} (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
                         
                        ;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 ...
1441
                                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...
1442
1443
1444
                                
                                ;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 ...
1445
                                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...
1446
1447
1448
1449
1450
1451
                            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 ...
1452
                                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...
1453
1454
1455
                                ;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 ...
1456
                                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...
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
                                 
                            endif 
                                                           
                        endif 
                        
                    endelse 
                
            endelse 
        
        end
        
        'QSED': begin ; THE ONE I WILL BE WORKING ON
96a72c8b   Ilyes Choubani   seperating xrange...
1469
1470
            
            IF ct_m NE 0 then xr=xr_m & yr=yr_m
67bd858a   Ilyes Choubani   Replication of th...
1471
            
1bc09467   Ilyes Choubani   fixed issue with ...
1472
1473
1474
1475
1476
            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...
1477
1478
1479
            varvar=where((*!dustem_data.qsed).values GT 0, testpstv)
            varvar=where((*!dustem_data.qsed).values LT 0, testngtv)
            
07372e26   Ilyes Choubani   Corrected huge pl...
1480
            
67bd858a   Ilyes Choubani   Replication of th...
1481
1482
            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...
1483
           
67bd858a   Ilyes Choubani   Replication of th...
1484
1485
1486
1487
            ;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...
1488
1489
1490
1491
1492
1493
1494
1495
1496
            
            ;#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 ...
1497
                    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...
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
                    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...
1521
1522
1523
1524
1525
                            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...
1526
1527
1528
1529
1530
1531
                        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...
1532
1533
1534
1535
1536
1537
                            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...
1538
1539
1540
1541
1542
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
                        ;stop
afde94a3   Ilyes Choubani   general update
1543
                        ;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 ...
1544
                        
67bd858a   Ilyes Choubani   Replication of th...
1545
1546
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1547
                        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...
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
                        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...
1568
                                        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...
1569
                                        
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1570
1571
                                        polar_ippsi2iqu,st.sed.(i+1)*fact,specqgrain,specugrain,vecfin,replicate(!dustem_psi,n_elements(vecfin)) ;temporary solution
                                                                            
67bd858a   Ilyes Choubani   Replication of th...
1572
                                        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...
1573
                                        
67bd858a   Ilyes Choubani   Replication of th...
1574
                                    endif
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1575
                                    
67bd858a   Ilyes Choubani   Replication of th...
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
                                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...
1592
                                    
67bd858a   Ilyes Choubani   Replication of th...
1593
1594
1595
1596
1597
1598
                                    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...
1599
                                    
67bd858a   Ilyes Choubani   Replication of th...
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
                                    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...
1623
                                        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...
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
                                        ;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...
1647
                                    
67bd858a   Ilyes Choubani   Replication of th...
1648
1649
1650
1651
1652
1653
                                    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...
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
                                    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...
1667
                        
67bd858a   Ilyes Choubani   Replication of th...
1668
1669
1670
1671
                        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...
1672
                       
67bd858a   Ilyes Choubani   Replication of th...
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
                        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 ...
1732
1733
                            
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1734
                                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 ...
1735
                                    
67bd858a   Ilyes Choubani   Replication of th...
1736
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1737
                                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...
1738
                                   
67bd858a   Ilyes Choubani   Replication of th...
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
                            
                            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 ...
1800
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1801
                                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 ...
1802
                                    
e0d00de0   Ilyes Choubani   removing stops
1803
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1804
                                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...
1805
                                  
67bd858a   Ilyes Choubani   Replication of th...
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
                            endelse
                            ;stop
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

        
        END
        
        'USED': begin
96a72c8b   Ilyes Choubani   seperating xrange...
1823
1824
1825
            
            IF ct_m NE 0 then xr=xr_m & yr=yr_m
            
1bc09467   Ilyes Choubani   fixed issue with ...
1826
1827
1828
1829
1830
            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...
1831
1832
1833
1834
1835
1836
1837
            ;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...
1838
            
67bd858a   Ilyes Choubani   Replication of th...
1839
1840
1841
1842
            ;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...
1843
1844
1845
1846
1847
1848
1849
1850
            ;#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 ...
1851
                    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...
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
                    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...
1875
1876
1877
1878
1879
                            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...
1880
1881
1882
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1883
                            
67bd858a   Ilyes Choubani   Replication of th...
1884
1885
1886
                            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...
1887
1888
1889
1890
1891
                            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...
1892
1893
1894
1895
                        ENDIF
      
                        
                    endif else begin ;The data points in the plot that remain unchanged
1bc09467   Ilyes Choubani   fixed issue with ...
1896
                        
67bd858a   Ilyes Choubani   Replication of th...
1897
1898
                        xtit=textoidl('\lambda (\mum)')
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
1899
                        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...
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
                        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...
1920
                                        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...
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
                                            
                                        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...
1935
                                            
67bd858a   Ilyes Choubani   Replication of th...
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
                                            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...
1975
                                        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...
1976
1977
                                        
                                        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...
1978
                                         
67bd858a   Ilyes Choubani   Replication of th...
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
                                        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...
2024
2025
                        
                        
67bd858a   Ilyes Choubani   Replication of th...
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
                        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 ...
2088
                            
07372e26   Ilyes Choubani   Corrected huge pl...
2089
                                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 ...
2090
2091
                                    
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2092
                                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...
2093
                                
67bd858a   Ilyes Choubani   Replication of th...
2094
                            endelse                          
18e4331f   Ilyes Choubani   general update (f...
2095
                        
67bd858a   Ilyes Choubani   Replication of th...
2096
                        endif 
18e4331f   Ilyes Choubani   general update (f...
2097
                        
67bd858a   Ilyes Choubani   Replication of th...
2098
                        if keyword_set(negative_only) then begin
18e4331f   Ilyes Choubani   general update (f...
2099
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
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
                            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...
2152
                            
67bd858a   Ilyes Choubani   Replication of th...
2153
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2154
                            
07372e26   Ilyes Choubani   Corrected huge pl...
2155
                                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 ...
2156
2157
                                    
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2158
                                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 ...
2159
                            
f2caf3f1   Ilyes Choubani   Debugging some er...
2160
       
67bd858a   Ilyes Choubani   Replication of th...
2161
2162
2163
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2164
2165
2166
2167
2168
2169
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2170
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2171
            
67bd858a   Ilyes Choubani   Replication of th...
2172
2173
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2174
2175
2176
        
        end
        
afde94a3   Ilyes Choubani   general update
2177
        'QEXT': begin   ;Correct this like you corrected extinction...
1bc09467   Ilyes Choubani   fixed issue with ...
2178
            
96a72c8b   Ilyes Choubani   seperating xrange...
2179
            IF ct_x NE 0 then xr=xr_x & yr=yr_x
1bc09467   Ilyes Choubani   fixed issue with ...
2180
2181
2182
2183
2184
2185
            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...
2186
2187
            varvar=where((*!dustem_data.qext).values GT 0, testpstv)
            varvar=where((*!dustem_data.qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2188
            
18e4331f   Ilyes Choubani   general update (f...
2189
            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2190
2191
            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...
2192
            
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2193
            
18e4331f   Ilyes Choubani   general update (f...
2194
            ;Locating all the hidden data points (spectrum+filter)
67bd858a   Ilyes Choubani   Replication of th...
2195
            match2,((*!dustem_data.qext).wav),((*!dustem_show.qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
18e4331f   Ilyes Choubani   general update (f...
2196
            idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2197
            
5f04fa07   Ilyes Choubani   general update
2198
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2199
2200
2201
2202
2203
2204
2205
            
            ;#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...
2206
                    xtit=textoidl('1/\lambda (\mum^{-1})')
bc224f3e   Ilyes Choubani   Update of plottin...
2207
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2208
                    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...
2209
2210
2211
2212
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
18e4331f   Ilyes Choubani   general update (f...
2213
2214
                    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...
2215
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
2216
2217
2218
2219
2220
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2221
                
bc224f3e   Ilyes Choubani   Update of plottin...
2222
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2223
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2224
2225
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
07372e26   Ilyes Choubani   Corrected huge pl...
2226
                        ;MAJOR LOOP OVER THE SIGN??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
c8368c6e   Ilyes Choubani   updating plotting...
2227
                
18e4331f   Ilyes Choubani   general update (f...
2228
                        IF ct_spec NE 0 THEN BEGIN
f2caf3f1   Ilyes Choubani   Debugging some er...
2229
                            
67bd858a   Ilyes Choubani   Replication of th...
2230
                            xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2231
                            yy=dustem_interp[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
2232
                            rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
                            
                            ;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...
2244
2245
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2246
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2247
                            ;stop
67bd858a   Ilyes Choubani   Replication of th...
2248
                            xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2249
                            yy=dustem_interp[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
2250
                            rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2251
2252
2253
2254
2255
                            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...
2256
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2257
      
bc224f3e   Ilyes Choubani   Update of plottin...
2258
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2259
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2260
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2261
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2262
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2263
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2264
                        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...
2265
2266
2267
2268
2269
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
07372e26   Ilyes Choubani   Corrected huge pl...
2270
                endif else begin ; normal plot 
c8368c6e   Ilyes Choubani   updating plotting...
2271
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2272
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
5f04fa07   Ilyes Choubani   general update
2273
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2274
2275
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2276
                            if testpstv ne 0 then begin
5f04fa07   Ilyes Choubani   general update
2277
                                ;stop
18e4331f   Ilyes Choubani   general update (f...
2278
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2279
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2280
2281
2282
                                    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...
2283
                                    
5f04fa07   Ilyes Choubani   general update
2284
2285
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2286
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2287
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2288
                                        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
2289
2290
                                        ;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...
2291
2292
2293
                                        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
2294
                                        
5f04fa07   Ilyes Choubani   general update
2295
                                        ;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 ...
2296
                                        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...
2297
                                        
5f04fa07   Ilyes Choubani   general update
2298
2299
                                    endif
                                    ;stop
18e4331f   Ilyes Choubani   general update (f...
2300
2301
2302
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2303
2304
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2305
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2306
2307
                                         
                                            ;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 ...
2308
                                            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...
2309
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2310
2311
2312
2313
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2314
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2315
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2316
                                    ;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 ...
2317
                                    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...
2318
2319
2320
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2321
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2322
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2323
                                    ;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 ...
2324
                                    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...
2325
2326
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2327
                                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...
2328
                                
18e4331f   Ilyes Choubani   general update (f...
2329
2330
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2331
                        
18e4331f   Ilyes Choubani   general update (f...
2332
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2333
                        
5f04fa07   Ilyes Choubani   general update
2334
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2335
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2336
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2337
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2338
                            
5f04fa07   Ilyes Choubani   general update
2339
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2340
2341
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2342
2343
2344
                                    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
2345
2346
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2347
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2348
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2349
                                        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
2350
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2351
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
5f04fa07   Ilyes Choubani   general update
2352
2353
                                        ;stop
                                        ;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 ...
2354
                                        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
2355
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2356
2357
2358
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2359
2360
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2361
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2362
2363
     
                                            ;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 ...
2364
                                            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...
2365
2366
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2367
2368
2369
2370
                                    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...
2371
                                    xx=((*!dustem_data.qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2372
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2373
                                    ;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 ...
2374
                                    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...
2375
2376
2377
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2378
                                    xx=((*!dustem_data.qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2379
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2380
                                    ;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 ...
2381
                                    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...
2382
2383
                                ENDIF
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2384
                                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...
2385
2386
2387
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2388
                        
18e4331f   Ilyes Choubani   general update (f...
2389
2390
2391
2392
2393
2394
                        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...
2395
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2396
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2397
                            
2df3360b   Ilyes Choubani   Correcting error:...
2398
2399
2400
2401
                        ;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...
2402
                        if ct_hdnpts then begin
67bd858a   Ilyes Choubani   Replication of th...
2403
2404
2405
2406
                            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...
2407
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2408
                        
c8368c6e   Ilyes Choubani   updating plotting...
2409
                        
18e4331f   Ilyes Choubani   general update (f...
2410
                        if keyword_set(positive_only) then begin
afde94a3   Ilyes Choubani   general update
2411
                            
2df3360b   Ilyes Choubani   Correcting error:...
2412
                            if testpstv ne 0 then begin
07372e26   Ilyes Choubani   Corrected huge pl...
2413
                        
9cb38725   Ilyes Choubani   Fixed tests relat...
2414
                                ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2415
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2416
                                if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2417
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2418
                                    if ct_spec_hdn_pstv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2419
2420
2421
                                        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...
2422
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2423
2424
                                        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...
2425
2426
2427
2428
2429
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2430
2431
2432
                                        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...
2433
                                        
1bc09467   Ilyes Choubani   fixed issue with ...
2434
2435
                                        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...
2436
2437
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2438
                                    
18e4331f   Ilyes Choubani   general update (f...
2439
2440
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2441
2442
                                
                                
18e4331f   Ilyes Choubani   general update (f...
2443
2444
                                if ct_spec ne 0 then begin
                                
67bd858a   Ilyes Choubani   Replication of th...
2445
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_spec)/2.
18e4331f   Ilyes Choubani   general update (f...
2446
                                    ;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
2447
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2448
                                    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 ...
2449
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2450
                                    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 ...
2451
                                     
18e4331f   Ilyes Choubani   general update (f...
2452
2453
2454
2455
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
67bd858a   Ilyes Choubani   Replication of th...
2456
                                    rms=3.*((*!dustem_data.qext).sigma)(idx_filt)/2.
18e4331f   Ilyes Choubani   general update (f...
2457
                                   ; 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 ...
2458
2459
                                    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...
2460
2461
                                        
                                endif
0c487640   Ilyes Choubani   corrected missing...
2462
                                
18e4331f   Ilyes Choubani   general update (f...
2463
2464
                            endif else begin
                            
1bc09467   Ilyes Choubani   fixed issue with ...
2465
2466
                            
                                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...
2467
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2468
2469
2470
                                
                                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...
2471

18e4331f   Ilyes Choubani   general update (f...
2472
                            endelse                           
bc224f3e   Ilyes Choubani   Update of plottin...
2473
                        
18e4331f   Ilyes Choubani   general update (f...
2474
                        endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2475
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2476
                        
18e4331f   Ilyes Choubani   general update (f...
2477
                        if keyword_set(negative_only) then begin
bc224f3e   Ilyes Choubani   Update of plottin...
2478
                            
2df3360b   Ilyes Choubani   Correcting error:...
2479
                            if testngtv ne 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2480
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2481
                                 ;plotsym, 0
18e4331f   Ilyes Choubani   general update (f...
2482
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2483
                                 if ct_hdnpts then begin
18e4331f   Ilyes Choubani   general update (f...
2484
                                 
9cb38725   Ilyes Choubani   Fixed tests relat...
2485
                                     if ct_spec_hdn_ngtv ne 0 then begin
67bd858a   Ilyes Choubani   Replication of th...
2486
2487
2488
                                         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...
2489
                                         
07372e26   Ilyes Choubani   Corrected huge pl...
2490
                                         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 ...
2491
                                         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...
2492
                                     
9cb38725   Ilyes Choubani   Fixed tests relat...
2493
2494
2495
2496
                                     endif 
                                     
                                     if ct_filt_hdn_ngtv ne 0 then begin
                                     
67bd858a   Ilyes Choubani   Replication of th...
2497
2498
2499
                                         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...
2500
                                         
1bc09467   Ilyes Choubani   fixed issue with ...
2501
2502
                                         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...
2503
2504
2505
                                     
                                     endif
                                
18e4331f   Ilyes Choubani   general update (f...
2506
                                 endif
bc224f3e   Ilyes Choubani   Update of plottin...
2507

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

67bd858a   Ilyes Choubani   Replication of th...
2876
                                 if ct_spec ne 0 then begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2877
                                     
67bd858a   Ilyes Choubani   Replication of th...
2878
2879
2880
                                     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 ...
2881
                                     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...
2882
                                     ;endelse;,ytickformat='(A1)'
e9bb0ce2   Ilyes Choubani   Correcting small ...
2883
                                     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...
2884
2885
2886
2887
2888
2889
2890
2891
                                  
                                 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 ...
2892
                                         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...
2893
2894
                                     ;endelse ;,ytickformat='(A1)'
                                     
1bc09467   Ilyes Choubani   fixed issue with ...
2895
                                     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...
2896
                                         
9cb38725   Ilyes Choubani   Fixed tests relat...
2897
                                 endif 
bc224f3e   Ilyes Choubani   Update of plottin...
2898
                            
2df3360b   Ilyes Choubani   Correcting error:...
2899
                            endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
2900
                                
e9bb0ce2   Ilyes Choubani   Correcting small ...
2901
                                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 ...
2902
                                    
18e4331f   Ilyes Choubani   general update (f...
2903
                                
07372e26   Ilyes Choubani   Corrected huge pl...
2904
2905
                                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...
2906
                        
2df3360b   Ilyes Choubani   Correcting error:...
2907
                            endelse
5f04fa07   Ilyes Choubani   general update
2908
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
2909
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2910
2911
2912
2913
                        
                    
                    endelse 
                
bc224f3e   Ilyes Choubani   Update of plottin...
2914
2915
                endelse 
            
67bd858a   Ilyes Choubani   Replication of th...
2916
            endelse 
b5314324   Ilyes Choubani   updating the plot...
2917
2918
        
        end
5f04fa07   Ilyes Choubani   general update
2919
2920
        
        'PARAMETERS':begin ;needs the followingd data (errors+res+formats)
e9bb0ce2   Ilyes Choubani   Correcting small ...
2921
         
5f04fa07   Ilyes Choubani   general update
2922
2923
2924
2925
2926
            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...
2927
    
5f04fa07   Ilyes Choubani   general update
2928
                k=0    
5f04fa07   Ilyes Choubani   general update
2929
                
53548c91   Ilyes Choubani   Display of frozen...
2930
2931
2932
2933
2934
2935
2936
                    
                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
2937
                        
53548c91   Ilyes Choubani   Display of frozen...
2938
2939
2940
2941
2942
2943
2944
                        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
2945
                        
53548c91   Ilyes Choubani   Display of frozen...
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
                    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...
2962
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
fcb6eade   Ilyes Choubani   general update - ...
2963
2964
                    
                    
53548c91   Ilyes Choubani   Display of frozen...
2965
2966
2967
2968
2969
                    res = dustem_interp
                    errors = dustem_spec
                    yypostmp = yypos
                    k=0
                    FOR i=0L,Npar-1 DO BEGIN   
fcb6eade   Ilyes Choubani   general update - ...
2970
                      
53548c91   Ilyes Choubani   Display of frozen...
2971
2972
2973
2974
2975
                      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 - ...
2976
                          
53548c91   Ilyes Choubani   Display of frozen...
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
                            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 ...
3001
                        
fcb6eade   Ilyes Choubani   general update - ...
3002
                        
53548c91   Ilyes Choubani   Display of frozen...
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
                        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 - ...
3029
                        
fcb6eade   Ilyes Choubani   general update - ...
3030
                        
53548c91   Ilyes Choubani   Display of frozen...
3031
                    ENDFOR        
fcb6eade   Ilyes Choubani   general update - ...
3032
                    
53548c91   Ilyes Choubani   Display of frozen...
3033
                ENDIF                        
5f04fa07   Ilyes Choubani   general update
3034
3035
                
            endif else begin ;data in the parameter window that is unchanged 
e9bb0ce2   Ilyes Choubani   Correcting small ...
3036
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3037
3038
3039
                ;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...
3040
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3041
3042
3043
3044
3045
                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...
3046
3047
3048
3049
3050
                    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...
3051
                    xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
e9bb0ce2   Ilyes Choubani   Correcting small ...
3052
3053
3054
3055
3056
                    
                    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...
3057
3058
3059
3060
3061
3062
3063
3064
3065
                        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 ...
3066
                            
53548c91   Ilyes Choubani   Display of frozen...
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
                            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 ...
3077
                        
53548c91   Ilyes Choubani   Display of frozen...
3078
                        ENDIF    
e9bb0ce2   Ilyes Choubani   Correcting small ...
3079
                         
53548c91   Ilyes Choubani   Display of frozen...
3080
                    ENDFOR  
e9bb0ce2   Ilyes Choubani   Correcting small ...
3081
3082
3083
3084
                     
                ENDIF
                
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3085
                
5f04fa07   Ilyes Choubani   general update
3086
                ;stop
0c487640   Ilyes Choubani   corrected missing...
3087
                xxpos = 0.0;might need to be modified
53548c91   Ilyes Choubani   Display of frozen...
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
                
                ;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...
3102
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3103
3104
3105
3106
                
                    cgtext, xxpos, yypos, '-FREE-', charsize=-1,width=thiswidth, /normal

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


endif










b5314324   Ilyes Choubani   updating the plot...
3397
END