Blame view

src/idl/dustemcgwin_dataset.pro 250 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

4da8e20e   Ilyes Choubani   other procs that ...
27
28
29



4da8e20e   Ilyes Choubani   other procs that ...
30
31
32
33
34
;THIS BLOCK WILL HAVE TO BE MODIFIED CONSIDERABLY
;SO FAR ALL DATASETS HAVE ONE XR AND ONE YR
;WHEN USING EMISSION AND EXTINCTION BOTH XR_M AND XR_X HAVE TO BE SET


96a72c8b   Ilyes Choubani   seperating xrange...
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
57

4da8e20e   Ilyes Choubani   other procs that ...
58

5f04fa07   Ilyes Choubani   general update
59
60
61
frmt0='(A46)'
frmt1='(1E11.4)'
frmt2='(10F10.2)'
b5314324   Ilyes Choubani   updating the plot...
62
63


5f04fa07   Ilyes Choubani   general update
64
;############################################################################################
b5314324   Ilyes Choubani   updating the plot...
65

b5314324   Ilyes Choubani   updating the plot...
66

abebbdf3   Ilyes Choubani   General update: A...
67
68
;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...
69
70
71
;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...
72

abebbdf3   Ilyes Choubani   General update: A...
73

b5314324   Ilyes Choubani   updating the plot...
74
75
76
77
78
79
if keyword_set(dataset) then begin
;!run_pol is implied for QSED/USED/POLSED etc...
    Case strupcase(dataset) of 
    
        'SED': begin
            
4b745987   Ilyes Choubani   minor update
80
81
82
83
            IF ct_m NE 0 then begin
                xr=xr_m
                yr=yr_m 
            endif
afde94a3   Ilyes Choubani   general update
84
85
86
87
88
89
            
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
90
91
            idx_filt=where((*(*!dustem_data).sed).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).sed).filt_names EQ 'SPECTRUM',ct_spec)
b5314324   Ilyes Choubani   updating the plot...
92
93
94
95
96
97
98
99
100
            
            ;#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
101
                    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...
102
103
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
5f04fa07   Ilyes Choubani   general update
104
105
106
                endif ;else begin ;normal plot
                
                if not keyword_set(norm) then begin
8a2cb251   Jean-Philippe Bernard   modifcations to c...
107
                    ;/NODATA
8e55ab4d   Jean-Philippe Bernard   removed frequency...
108
109
110
111
                    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
                    IF !dustemwrap_which_language NE 'fawlty' THEN BEGIN
                        axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
                    ENDIF
5f04fa07   Ilyes Choubani   general update
112
                    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...
113
                  
5f04fa07   Ilyes Choubani   general update
114
115
                ;endelse  
                endif
b5314324   Ilyes Choubani   updating the plot...
116
            
5f04fa07   Ilyes Choubani   general update
117
118
            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...
119
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
120
                    
b5314324   Ilyes Choubani   updating the plot...
121
122
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
b5314324   Ilyes Choubani   updating the plot...
123
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
124
                            xx=((*(*!dustem_data).sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
125
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
126
127
128
                            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...
129
                        ENDIF
b5314324   Ilyes Choubani   updating the plot...
130
                        
c8368c6e   Ilyes Choubani   updating plotting...
131
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
132
                            xx=((*(*!dustem_data).sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
133
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
134
135
136
                            rms=3.*((*(*!dustem_data).sed).sigma)(idx_filt)/2. 
                            cgoplot,xx,((*(*!dustem_data).sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                            cgerrplot,((*(*!dustem_data).sed).wav)(idx_filt),(((*(*!dustem_data).sed).values)[idx_filt]-rms)/yy,(((*(*!dustem_data).sed).values)[idx_filt]+rms)/yy,color='Dodger Blue';,/overplot 
c8368c6e   Ilyes Choubani   updating plotting...
137
138
139
                        ENDIF
                            
                        
5f04fa07   Ilyes Choubani   general update
140
141
                    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...
142
                        
5f04fa07   Ilyes Choubani   general update
143
144
                    if not keyword_set(refresh) then begin 
                        ;stop   
afde94a3   Ilyes Choubani   general update
145
                        
b5314324   Ilyes Choubani   updating the plot...
146
                        xtit=textoidl('\lambda (\mum)')
fcb6eade   Ilyes Choubani   general update - ...
147
148
149
150
                        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
151
                        
afde94a3   Ilyes Choubani   general update
152
                        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...
153
154
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
5f04fa07   Ilyes Choubani   general update
155
156
                    ;endelse
                    endif
b5314324   Ilyes Choubani   updating the plot...
157
158
                    
                
5f04fa07   Ilyes Choubani   general update
159
160
                endif ;else begin ; normal plot
                if not keyword_set(norm) then begin        
b5314324   Ilyes Choubani   updating the plot...
161
162
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
                        
b5314324   Ilyes Choubani   updating the plot...
163
164
165
166
167
                        ;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...
168
                                                
b5314324   Ilyes Choubani   updating the plot...
169
170
                        ;Plotting of the plugins.
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
171
172
173
174
175
176
177
178
179
                            
                            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...
180
                        endfor
c8368c6e   Ilyes Choubani   updating plotting...
181
                                                
b5314324   Ilyes Choubani   updating the plot...
182
                        ;PLotting of the interpolates corresponding to spectrum and filter points
c8368c6e   Ilyes Choubani   updating plotting...
183
                           
b5314324   Ilyes Choubani   updating the plot...
184
185
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
186
                            xx=((*(*!dustem_data).sed).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
187
                            yy=dustem_interp[idx_spec]
abebbdf3   Ilyes Choubani   General update: A...
188
                            cgoplot,xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
b5314324   Ilyes Choubani   updating the plot...
189
190
                        ENDIF
                        
c8368c6e   Ilyes Choubani   updating plotting...
191
192
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
193
                            xx=((*(*!dustem_data).sed).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
194
                            yy=dustem_interp[idx_filt]
c8368c6e   Ilyes Choubani   updating plotting...
195
196
197
                            cgoplot,xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
                        ENDIF
                        
b5314324   Ilyes Choubani   updating the plot...
198
                        
c8368c6e   Ilyes Choubani   updating plotting...
199
                        ;Plotting of the total dust emission spectrum
5f04fa07   Ilyes Choubani   general update
200
                        cgoplot,st.sed.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
c8368c6e   Ilyes Choubani   updating plotting...
201
202
203
                         
                                        
                                
5f04fa07   Ilyes Choubani   general update
204
205
206
                    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...
207
208
209
210
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
211
                            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...
212
213
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
214
215
                            rms=3.*((*(*!dustem_data).sed).sigma)(idx_spec)/2.
                            cgerrplot,((*(*!dustem_data).sed).wav)(idx_spec),((*(*!dustem_data).sed).values)(idx_spec)-rms,((*(*!dustem_data).sed).values)(idx_spec)+rms,color='Powder Blue'
b5314324   Ilyes Choubani   updating the plot...
216
217
218
219

                        endif
                        
                        if ct_filt ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
220
                        
b5314324   Ilyes Choubani   updating the plot...
221
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
222
223
                            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...
224
                            
b5314324   Ilyes Choubani   updating the plot...
225
226
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
227
228
                            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...
229
                            
b5314324   Ilyes Choubani   updating the plot...
230
                        endif
c8368c6e   Ilyes Choubani   updating plotting...
231
                        
b5314324   Ilyes Choubani   updating the plot...
232
                        ;Plotting of frequency axis
8a2cb251   Jean-Philippe Bernard   modifcations to c...
233
234
235
236
237
238
239
240
241
242
243
244
245
                        ;save_x=!x & save_y=!y & save_z=!z & save_p=!p & save_d=!d
                        ;save_scaling=1
                        ;use_xrange=((!const.c*1E6/(xr))*1E-9)
                        ;order=sort(use_xrange)
                        ;use_xrange=use_xrange[order]
                        ;print,use_xrange
                        ;stop
                        IF !dustemwrap_which_language NE 'fawlty' THEN BEGIN
                            axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=use_xrange,charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
                        ENDIF
                        ;axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=use_xrange,charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0,save=save_scaling,/ynozero
                        ;!x=save_x & !y=save_y & !z=save_z & !p=save_p & !d=save_d

5f04fa07   Ilyes Choubani   general update
246
                        xyouts,pospltxt[0],pospltxt[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
c8368c6e   Ilyes Choubani   updating plotting...
247
                         
b5314324   Ilyes Choubani   updating the plot...
248
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
249
                        match2,((*(*!dustem_data).sed).wav),((*(*!dustem_show).sed).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
250
                        idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
2df3360b   Ilyes Choubani   Correcting error:...
251
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
252
253
                        idx_filt_hdn = where((((*(*!dustem_show).sed).filt_names))(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn)
2df3360b   Ilyes Choubani   Correcting error:...
254
                         
c8368c6e   Ilyes Choubani   updating plotting...
255
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
256
                            ;stop
18e4331f   Ilyes Choubani   general update (f...
257
258
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
259
                                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...
260
261
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
262
263
                                rms=3.*(((*(*!dustem_show).sed).sigma)[idx_rmv_sed])(idx_spec_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).sed).wav)[idx_rmv_sed])(idx_spec_hdn),(((*(*!dustem_show).sed).values)[idx_rmv_sed])(idx_spec_hdn)-rms,(((*(*!dustem_show).sed).values)[idx_rmv_sed])(idx_spec_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
264
                            endif                                            
b5314324   Ilyes Choubani   updating the plot...
265
                            
18e4331f   Ilyes Choubani   general update (f...
266
                            if ct_filt_hdn then begin
b5314324   Ilyes Choubani   updating the plot...
267
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
268
                                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...
269
270
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
271
272
                                rms=3.*(((*(*!dustem_show).sed).sigma)[idx_rmv_sed])(idx_filt_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).sed).wav)[idx_rmv_sed])(idx_filt_hdn),(((*(*!dustem_show).sed).values)[idx_rmv_sed])(idx_filt_hdn)-rms,(((*(*!dustem_show).sed).values)[idx_rmv_sed])(idx_filt_hdn)+rms,color='Black'
18e4331f   Ilyes Choubani   general update (f...
273
274
                                
                            endif
b5314324   Ilyes Choubani   updating the plot...
275
276
277
278
279
                                                           
                        endif    
                        
                        
                    
5f04fa07   Ilyes Choubani   general update
280
281
                    ;endelse 
                    endif
b5314324   Ilyes Choubani   updating the plot...
282
283
                
                
5f04fa07   Ilyes Choubani   general update
284
285
286
287
                ;endelse 
                endif            
            ;endelse
            endif 
18e4331f   Ilyes Choubani   general update (f...
288
        ;stop    
b5314324   Ilyes Choubani   updating the plot...
289
290
        end
        
afde94a3   Ilyes Choubani   general update
291
        'EXT': begin ;BE VERY CAREFUL THE EXTINCTION STRUCTURE AS REDERED BY DUSTEM IS DIFFERENT THAN THE EMISSION ONE
b5314324   Ilyes Choubani   updating the plot...
292
        
afde94a3   Ilyes Choubani   general update
293
294
295
296
297
;             ;So far manually changing xr and yr.
;             
;             xr=[0.01,30]
;             yr=[1.00E-06,10]
            
4b745987   Ilyes Choubani   minor update
298
            IF ct_x NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
299
            
4b745987   Ilyes Choubani   minor update
300
301
302
303
                xr=xr_x 
                yr=yr_x
                
            ENDIF
afde94a3   Ilyes Choubani   general update
304
305
306
307
308
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
0068116a   Ilyes Choubani   General update + ...
309
310
            idx_filt=where((*(*!dustem_data).ext).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).ext).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
311
312
313
314
315
316
317
            
            ;#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...
318
                    xtit=textoidl('1/\lambda (\mum^{-1})')
67bd858a   Ilyes Choubani   Replication of th...
319
                    if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
320
                    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...
321
322
323
324
325
                    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
326
                    ;/NODATA    
8e55ab4d   Jean-Philippe Bernard   removed frequency...
327
328
329
330
                    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
                    IF !dustemwrap_which_language NE 'fawlty' THEN BEGIN
                        axis, xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6*xr)*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10,color='black'
                    ENDIF
f2caf3f1   Ilyes Choubani   Debugging some er...
331
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{EXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
332
333
334
335
336
337
338
339
340
341
342
                  
                ;endelse  
                endif
            
            endif ;else begin ;when the data is present - to be replaced by if to test as a solution to the refreshing problem
            if not keyword_set(nodata) then begin
                if keyword_set(norm) then begin 
                    
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
                        IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
343
                            xx=((*(*!dustem_data).ext).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
344
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
345
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
346
347
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
348
349
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_spec])[indzero]/yy[indzero],color='Powder Blue',psym=16,syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_spec))[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
94c4dffa   Ilyes Choubani   update + fixes fo...
350
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
351
352
353
                        ENDIF
                        
                        IF ct_filt NE 0 THEN BEGIN ; There are no filter points for now...
0068116a   Ilyes Choubani   General update + ...
354
                            xx=((*(*!dustem_data).ext).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
355
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
356
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_filt)/2.
94c4dffa   Ilyes Choubani   update + fixes fo...
357
358
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
359
360
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).ext).values)[idx_filt])[indzero]/yy[indzero],psym=16,color='Dodger Blue',syms=0.8,noerase=1,pos=position
                                cgerrplot,(1/((*(*!dustem_data).ext).wav)(idx_filt))[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).ext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue';,/overplot 
94c4dffa   Ilyes Choubani   update + fixes fo...
361
                            ENDIF
67bd858a   Ilyes Choubani   Replication of th...
362
363
364
365
366
367
368
369
                        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...
370
                        xtit=textoidl('1/\lambda (\mum^{-1})')
67bd858a   Ilyes Choubani   Replication of th...
371
372
373
374
                        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
375
                        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...
376
377
378
379
380
381
382
383
384
385
386
387
388
                        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
389
                    
67bd858a   Ilyes Choubani   Replication of th...
390
                        FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
391
                            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...
392
                        ENDFOR
07372e26   Ilyes Choubani   Corrected huge pl...
393
                            
67bd858a   Ilyes Choubani   Replication of th...
394
395
396
397
398
399
400
                                                
                        ;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
401
                                    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...
402
403
404
405
406
407
408
409
410
411
412
                                ENDIF
                                
                            endif
                            
                        endfor
                        
                                                
                        ;PLotting of the interpolates corresponding to spectrum and filter points
                           
                        IF ct_spec NE 0 THEN BEGIN
                        
0068116a   Ilyes Choubani   General update + ...
413
                            xx=((*(*!dustem_data).ext).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
414
                            yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
415
                            cgoplot,1/xx,yy,color='Indian Red',pos=position,psym=7,syms=1,noerase=1   
67bd858a   Ilyes Choubani   Replication of th...
416
417
418
419
                        ENDIF
                        
                        
                        IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
420
                            xx=((*(*!dustem_data).ext).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
421
                            yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
422
                            cgoplot,1/xx,yy,color='red',pos=position,psym=6,syms=2,noerase=1
67bd858a   Ilyes Choubani   Replication of th...
423
424
425
426
                        ENDIF
                        
                        
                        ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
427
                        cgoplot,1/st.ext.wav,dustem_spec,pos=position,noerase=1,/xlog,/ys,/xs,/ylog
67bd858a   Ilyes Choubani   Replication of th...
428
429
430
431
432
433
434
435
436
437
                         
                                        
                                
                    endif ;else begin ;The data points in the plot that remain unchanged.
                        ;stop
                    if not keyword_set(refresh) then begin
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
438
                            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...
439
440
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
441
442
                            rms=3.*((*(*!dustem_data).ext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).ext).wav)(idx_spec),((*(*!dustem_data).ext).values)(idx_spec)-rms,((*(*!dustem_data).ext).values)(idx_spec)+rms,color='Powder Blue'
67bd858a   Ilyes Choubani   Replication of th...
443
444
445
446
447
448

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

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

                        endif
                        
                        if ct_filt ne 0 then begin
                            plotsym,0,/fill
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
847
848
                            if ct_spec ne 0 then cgoplot,((*(*!dustem_data).polsed).wav)(idx_filt),((*(*!dustem_data).polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog else $
                                cgplot,((*(*!dustem_data).polsed).wav)(idx_filt),((*(*!dustem_data).polsed).values)(idx_filt),charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,pos=position,/ys,xs=9,noerase=1,xtickformat='(A1)',xtit=' ',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog
67bd858a   Ilyes Choubani   Replication of th...
849
850
851
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
852
853
                            rms=3.*((*(*!dustem_data).polsed).sigma)(idx_filt)/2.;/dustem_polsed(idx_filt)
                            cgerrplot,((*(*!dustem_data).polsed).wav)(idx_filt),((*(*!dustem_data).polsed).values)(idx_filt)-rms,((*(*!dustem_data).polsed).values)(idx_filt)+rms,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
854
855
856
857
858
                            
                        endif
                        
                        
                        ;Plotting of frequency axis
8e55ab4d   Jean-Philippe Bernard   removed frequency...
859
860
861
                        IF !dustemwrap_which_language NE 'fawlty' THEN BEGIN
                            axis, xaxis=1, xlog=1, xs=1, xminor=10, xticklen=0.05, xrange=((!const.c*1E6/(xr))*1E-9),charsize=1.15,xtitle=textoidl('\nu (GHz)'),color=0
                        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
862
863
864
                        xyouts,pospltxt[0],pospltxt[1],textoidl('P_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.3;,charthick=2.0
                         
                        ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
865
                        match2,((*(*!dustem_data).polsed).wav),((*(*!dustem_show).polsed).wav),show_polsedpts,fit_polsedpts ;only show_polsedpts is needed
74103816   Ilyes Choubani   small update
866
                        idx_rmv_polsed=where(fit_polsedpts eq -1, ct_hdnpts) ; indices of the points to hide
67bd858a   Ilyes Choubani   Replication of th...
867
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
868
869
                        idx_filt_hdn = where((((*(*!dustem_show).polsed).filt_names))(idx_rmv_polsed) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).polsed).filt_names)(idx_rmv_polsed) EQ 'SPECTRUM',ct_spec_hdn)
67bd858a   Ilyes Choubani   Replication of th...
870
871
872
873
874
875
876
                        
                        ;stop
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
877
                                cgoplot,(((*(*!dustem_show).polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_spec_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8
67bd858a   Ilyes Choubani   Replication of th...
878
879
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
880
881
                                rms=3.*(((*(*!dustem_show).polsed).sigma)[idx_rmv_polsed])(idx_spec_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).polsed).wav)[idx_rmv_polsed])(idx_spec_hdn),(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_spec_hdn)-rms,(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_spec_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
882
883
884
885
                            endif                                            
                            
                            if ct_filt_hdn ne 0 then begin
                            ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
886
                                cgoplot,(((*(*!dustem_show).polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_filt_hdn),pos=position,/ylog,/xlog,/ys,xs=9,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,psym=8,syms=0.8                                           
67bd858a   Ilyes Choubani   Replication of th...
887
888
                                
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
889
890
                                rms=3.*(((*(*!dustem_show).polsed).sigma)[idx_rmv_polsed])(idx_filt_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).polsed).wav)[idx_rmv_polsed])(idx_filt_hdn),(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_filt_hdn)-rms,(((*(*!dustem_show).polsed).values)[idx_rmv_polsed])(idx_filt_hdn)+rms,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
                                
                            endif
                                                           
                        endif    
                        
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse
        
        end
        
        'POLFRAC': begin 
96a72c8b   Ilyes Choubani   seperating xrange...
909
            
4b745987   Ilyes Choubani   minor update
910
911
912
913
914
            IF ct_m NE 0 then begin
                xr=xr_m
                yr=yr_m
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
915
916
            idx_filt=where((*(*!dustem_data).polfrac).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).polfrac).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
917
918
919
920
921
922
            
            
            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...
923
                    xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
924
925
926
927
                 
            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...
928
                          
67bd858a   Ilyes Choubani   Replication of th...
929
                        FOR i=0L,Ngrains-1 DO BEGIN
1355825c   Ilyes Choubani   General update
930
                            
5f04fa07   Ilyes Choubani   general update
931
                            testneq = where(st.polsed.(i+1) ne 0,countneq)
1355825c   Ilyes Choubani   General update
932
                            
5f04fa07   Ilyes Choubani   general update
933
934
935
                            if countneq ne 0 then begin 
                                vecfin = st.polsed.(i+1)*0.0
                                
07372e26   Ilyes Choubani   Corrected huge pl...
936
937
                                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
938
939
                                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
940
941
942
                        ENDFOR
                       
                        ;Plotting of the plugins. 
5f04fa07   Ilyes Choubani   general update
943
                         
1355825c   Ilyes Choubani   General update
944
                        for i=0L,n_plgns-1 do begin
5f04fa07   Ilyes Choubani   general update
945
                            
3c479f24   Ilyes Choubani   Allowing to fix p...
946
947
948
949
950
951
952
953
954
                            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
955
                            
1355825c   Ilyes Choubani   General update
956
957
                        endfor
                       
5f04fa07   Ilyes Choubani   general update
958
959
                       ;STOPPED HERE. CHECK QSED NOW. MOVING ON NOW. 
                       
1355825c   Ilyes Choubani   General update
960
961
962
963
964
                        
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
965
                             xx=((*(*!dustem_data).polfrac).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
966
                             yy=dustem_interp[idx_spec]
fcb6eade   Ilyes Choubani   general update - ...
967
                             cgoplot,xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
1355825c   Ilyes Choubani   General update
968
969
970
971
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
972
                             xx=((*(*!dustem_data).polfrac).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
973
                             yy=dustem_interp[idx_filt]
1355825c   Ilyes Choubani   General update
974
975
976
977
978
                             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
979
                         cgoplot,st.polsed.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs               
1355825c   Ilyes Choubani   General update
980
981
982
                                
                    endif else begin ;The data points in the plot that remain unchanged.
                        
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
983

1355825c   Ilyes Choubani   General update
984
                        ;Spectrum points are treated before for plotting reasons. 
9cb38725   Ilyes Choubani   Fixed tests relat...
985
                        
1355825c   Ilyes Choubani   General update
986
987
988
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
989
                            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
990
991
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
992
993
                            rms=3.*((*(*!dustem_data).polfrac).sigma)(idx_spec)/2.
                            cgerrplot,((*(*!dustem_data).polfrac).wav)(idx_spec),(((*(*!dustem_data).polfrac).values)(idx_spec)-rms)*100,(((*(*!dustem_data).polfrac).values)(idx_spec)+rms)*100,color='Powder Blue'
1355825c   Ilyes Choubani   General update
994
995
996
997
998
999

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
1000
1001
                            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
1002
1003
1004
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
1005
1006
                            rms=3.*((*(*!dustem_data).polfrac).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            cgerrplot,((*(*!dustem_data).polfrac).wav)(idx_filt),(((*(*!dustem_data).polfrac).values)(idx_filt)-rms)*100,(((*(*!dustem_data).polfrac).values)(idx_filt)+rms)*100,color='Dodger Blue'
1355825c   Ilyes Choubani   General update
1007
1008
1009
1010
1011
                            
                        endif
                        
                        
                        
07372e26   Ilyes Choubani   Corrected huge pl...
1012
                        xyouts,pospltxt[0],pospltxt[1],textoidl('p (%)'),color=0,/normal,charsize=1.3;,charthick=2.0
1355825c   Ilyes Choubani   General update
1013
1014
1015
1016
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
1017
                        match2,((*(*!dustem_data).polfrac).wav),((*(*!dustem_show).polfrac).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
74103816   Ilyes Choubani   small update
1018
                        idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide
1355825c   Ilyes Choubani   General update
1019
                        ;stop
2df3360b   Ilyes Choubani   Correcting error:...
1020
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
1021
1022
                        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
1023
1024
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
1355825c   Ilyes Choubani   General update
1025
1026
1027
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
1028
                                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
1029
1030
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1031
1032
                                rms=3.*(((*(*!dustem_show).polfrac).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
1355825c   Ilyes Choubani   General update
1033
1034
1035
1036
1037
1038
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1039
                                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
1040
1041
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1042
1043
                                rms=3.*(((*(*!dustem_show).polfrac).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                cgerrplot,(((*(*!dustem_show).polfrac).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*(*!dustem_show).polfrac).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
1355825c   Ilyes Choubani   General update
1044
1045
1046
1047
1048
1049
1050
1051
1052
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse 
b5314324   Ilyes Choubani   updating the plot...
1053
1054
1055
        
        end
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
1056
        'FPOLEXT': BEGIN ; For completeness (not sure of the physical usefulness of this qauntity )
96a72c8b   Ilyes Choubani   seperating xrange...
1057
            
4b745987   Ilyes Choubani   minor update
1058
            IF ct_x NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
1059
            
4b745987   Ilyes Choubani   minor update
1060
1061
1062
1063
                xr=xr_x
                yr=yr_x
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
1064
1065
            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...
1066
            
18e4331f   Ilyes Choubani   general update (f...
1067
1068
1069
1070
            
            if keyword_set(nodata) then begin ;when the data is not present
            
                    xtit = ''
94c4dffa   Ilyes Choubani   update + fixes fo...
1071
1072
                    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...
1073
1074
1075
1076
1077
                 
            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...
1078
                        
18e4331f   Ilyes Choubani   general update (f...
1079
                        FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
1080
                            
07372e26   Ilyes Choubani   Corrected huge pl...
1081
1082
1083
                            vecto = transpose((st.polext.(1))[i,*]+(st.polext.(2))[i,*])
                            
                            testneq = where(vecto ne 0,countneq)
67bd858a   Ilyes Choubani   Replication of th...
1084
1085
                            
                            if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
1086
                                vecfin = vecto*0.0
5f04fa07   Ilyes Choubani   general update
1087
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1088
                                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...
1089
                                 
94c4dffa   Ilyes Choubani   update + fixes fo...
1090
                                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...
1091
                            endif   
18e4331f   Ilyes Choubani   general update (f...
1092
                        ENDFOR
67bd858a   Ilyes Choubani   Replication of th...
1093
1094
1095
                       
                        ;Plotting of the plugins. 
                         
18e4331f   Ilyes Choubani   general update (f...
1096
                        for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
1097
1098
                            
                            if isa((*!dustem_plugin).(0).spec) then begin
67bd858a   Ilyes Choubani   Replication of th...
1099
1100
1101
1102
                            
                                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
1103
                                    cgoplot,1/st.polext.wav,vecfin*100,color=clrs_plgns[i],pos=position,noerase=1,linestyle=2               
67bd858a   Ilyes Choubani   Replication of th...
1104
                                
3c479f24   Ilyes Choubani   Allowing to fix p...
1105
                                ENDIF
67bd858a   Ilyes Choubani   Replication of th...
1106
1107
                            endif
                            
18e4331f   Ilyes Choubani   general update (f...
1108
                        endfor
67bd858a   Ilyes Choubani   Replication of th...
1109
                       
67bd858a   Ilyes Choubani   Replication of th...
1110
                       
18e4331f   Ilyes Choubani   general update (f...
1111
1112
1113
1114
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
1115
                             xx=((*(*!dustem_data).fpolext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
1116
                             yy=dustem_interp[idx_spec]
afde94a3   Ilyes Choubani   general update
1117
                             cgoplot,1/xx,yy*100,color='Indian Red',pos=position,psym=7,syms=2,noerase=1   
18e4331f   Ilyes Choubani   general update (f...
1118
1119
1120
1121
                         ENDIF
                         
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1122
                             xx=((*(*!dustem_data).fpolext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
1123
                             yy=dustem_interp[idx_filt]
afde94a3   Ilyes Choubani   general update
1124
                             cgoplot,1/xx,yy*100,color='red',pos=position,psym=6,syms=2,noerase=1
18e4331f   Ilyes Choubani   general update (f...
1125
1126
1127
1128
                         ENDIF
                         
                         
                         ;Plotting of the total dust emission spectrum
afde94a3   Ilyes Choubani   general update
1129
                         cgoplot,1/st.polext.wav,dustem_spec*100,pos=position,noerase=1,/xlog,/ys,/xs
67bd858a   Ilyes Choubani   Replication of th...
1130
                                        
18e4331f   Ilyes Choubani   general update (f...
1131
1132
                                
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1133
                         
18e4331f   Ilyes Choubani   general update (f...
1134
1135
                        
                        ;Spectrum points are treated before for plotting reasons. 
67bd858a   Ilyes Choubani   Replication of th...
1136
                        
18e4331f   Ilyes Choubani   general update (f...
1137
1138
1139
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
1140
                            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...
1141
1142
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
1143
1144
                            rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_spec)/2.
                            cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_spec),(((*(*!dustem_data).fpolext).values)(idx_spec)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_spec)+rms)*100,color='Powder Blue'
18e4331f   Ilyes Choubani   general update (f...
1145
1146
1147
1148
1149
1150

                        endif
                        
                        if ct_filt ne 0 then begin
                        
                            ;Plotting of filter data points (to be fitted) + testing for prior plotting                         
0068116a   Ilyes Choubani   General update + ...
1151
1152
                            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...
1153
1154
1155
                            
                            
                            ;Plotting of the filter error points
0068116a   Ilyes Choubani   General update + ...
1156
1157
                            rms=3.*((*(*!dustem_data).fpolext).sigma)(idx_filt)/2.;/dustem_polfrac(idx_filt)
                            cgerrplot,1/((*(*!dustem_data).fpolext).wav)(idx_filt),(((*(*!dustem_data).fpolext).values)(idx_filt)-rms)*100,(((*(*!dustem_data).fpolext).values)(idx_filt)+rms)*100,color='Dodger Blue'
67bd858a   Ilyes Choubani   Replication of th...
1158
1159
1160
1161
1162
                            
                        endif
                        
                        
                        
94c4dffa   Ilyes Choubani   update + fixes fo...
1163
                        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...
1164
1165
1166
1167
                         
                        ;Locating all the hidden data points (spectrum+filter)
                        
                        ;The filtering has been done prior (in the primary routine)
0068116a   Ilyes Choubani   General update + ...
1168
                        match2,((*(*!dustem_data).fpolext).wav),((*(*!dustem_show).fpolext).wav),show_polfracpts,fit_polfracpts ;only show_polfracpts is needed
74103816   Ilyes Choubani   small update
1169
                        idx_rmv_polfrac=where(fit_polfracpts eq -1, ct_hdnpts) ; indices of the points to hide; 
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1170
                        
67bd858a   Ilyes Choubani   Replication of th...
1171
                        ;Locating the hidden spectrum and filter data points                                        
0068116a   Ilyes Choubani   General update + ...
1172
1173
                        idx_filt_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) NE 'SPECTRUM',ct_filt_hdn)
                        idx_spec_hdn = where(((*(*!dustem_show).fpolext).filt_names)(idx_rmv_polfrac) EQ 'SPECTRUM',ct_spec_hdn)
67bd858a   Ilyes Choubani   Replication of th...
1174
1175
1176
1177
1178
                        if ct_hdnpts ne 0 then begin ;Hidden data points are present 
                            ;stop
                            
                            if ct_spec_hdn ne 0 then begin
                                ;Plotting of hidden spectrum data points
0068116a   Ilyes Choubani   General update + ...
1179
                                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...
1180
1181
                                
                                ;Plotting of hidden spectrum error points
0068116a   Ilyes Choubani   General update + ...
1182
1183
                                rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_spec_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_spec_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_spec_hdn)+rms)*100,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1184
1185
1186
1187
1188
1189
                            endif                                           
                            
                            if ct_filt_hdn ne 0 then begin
                                ;stop
                                plotsym,0, /fill
                                ;Plotting of hidden filter data points 
0068116a   Ilyes Choubani   General update + ...
1190
                                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...
1191
1192
                                ;stop
                                ;Plotting of hidden filter error point
0068116a   Ilyes Choubani   General update + ...
1193
1194
                                rms=3.*(((*(*!dustem_show).fpolext).sigma)[idx_rmv_polfrac])(idx_filt_hdn)/2.
                                cgerrplot,1/(((*(*!dustem_show).fpolext).wav)[idx_rmv_polfrac])(idx_filt_hdn),((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)-rms)*100,((((*(*!dustem_show).fpolext).values)[idx_rmv_polfrac])(idx_filt_hdn)+rms)*100,color='Black'
67bd858a   Ilyes Choubani   Replication of th...
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
                                 
                            endif 
                                                           
                        endif 
                        
                    
                    endelse 
                
            endelse
        
        
        END
        
        
     
        'PSI_EM': begin ;will be copying code from qsed and hopefully it will work. NB: THIS IS FALSE . YOU DO NOT NEED A LOGARITHMIC AXIS
            
4b745987   Ilyes Choubani   minor update
1212
            IF ct_m NE 0 then begin
96a72c8b   Ilyes Choubani   seperating xrange...
1213
            
4b745987   Ilyes Choubani   minor update
1214
1215
1216
1217
                xr=xr_m 
                yr=yr_m
                
            ENDIF
0068116a   Ilyes Choubani   General update + ...
1218
1219
            idx_filt=where((*(*!dustem_data).psi_em).filt_names NE 'SPECTRUM',ct_filt)
            idx_spec=where((*(*!dustem_data).psi_em).filt_names EQ 'SPECTRUM',ct_spec)
67bd858a   Ilyes Choubani   Replication of th...
1220
1221
1222
1223
1224
1225
1226
            
            ;#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...
1227
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\Psi (deg)'),color=0,/normal,charsize=1.3;,charthick=2.0
67bd858a   Ilyes Choubani   Replication of th...
1228
1229
1230
1231
1232
                 
            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...
1233
1234
1235
1236
1237
1238
1239
                        
                        ;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...
1240
                                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...
1241
                                
07372e26   Ilyes Choubani   Corrected huge pl...
1242
1243
                                ;*****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...
1244
1245
1246
1247
1248
1249
1250
                                
                                ;You can replace the -0 values by 0 in order to avoid atan giving wrong values 
                                testnzero = where(specqgrain EQ -0., ct_nzero)
                                if ct_nzero ne 0 then specqgrain[testnzero] = 0
                                
                                cgoplot,st.polsed.wav,0.5*atan(specugrain, specqgrain)/!dtor,pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
                                ;cgoplot,st.polsed.wav,replicate(!dustem_psi,n_elements(vecfin)),pos=position,noerase=1,color=use_cols[i],xr=xr,/xlog,ytickformat='(A1)',yr=[-90.00,90.00]
0068116a   Ilyes Choubani   General update + ...
1251
                                
67bd858a   Ilyes Choubani   Replication of th...
1252
1253
                            endif 
                        ENDFOR
1bc09467   Ilyes Choubani   fixed issue with ...
1254
                                                                        
67bd858a   Ilyes Choubani   Replication of th...
1255
1256
1257
1258
1259
1260
                        ;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
1261
                                    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...
1262
1263
1264
                                ENDIF
                            ENDIF
                        endfor
1bc09467   Ilyes Choubani   fixed issue with ...
1265
                        
67bd858a   Ilyes Choubani   Replication of th...
1266
1267
1268
1269
                         ;PLotting of the interpolates corresponding to spectrum and filter points
                        
                         IF ct_spec NE 0 THEN BEGIN
                         
0068116a   Ilyes Choubani   General update + ...
1270
                             xx=((*(*!dustem_data).psi_em).wav)[idx_spec]
67bd858a   Ilyes Choubani   Replication of th...
1271
1272
1273
                             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 ...
1274
                         
67bd858a   Ilyes Choubani   Replication of th...
1275
1276
                         
                         IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
1277
                             xx=((*(*!dustem_data).psi_em).wav)[idx_filt]
67bd858a   Ilyes Choubani   Replication of th...
1278
1279
1280
                             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 ...
1281
                         
67bd858a   Ilyes Choubani   Replication of th...
1282
1283
1284
1285
                         
                         ;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 ...
1286
                                
67bd858a   Ilyes Choubani   Replication of th...
1287
                    endif else begin ;The data points in the plot that remain unchanged.
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
1288
                         
67bd858a   Ilyes Choubani   Replication of th...
1289
1290
1291
1292
1293
                        
                        ;Spectrum points are treated before for plotting reasons. 
                        if ct_spec ne 0 then begin 
                            
                            ;Plotting of spectrum data points (to be fitted)
0068116a   Ilyes Choubani   General update + ...
1294
                            cgplot,((*(*!dustem_data).psi_em).wav)(idx_spec),((*(*!dustem_data).psi_em).values)(idx_spec),/xlog,/ys,xs=1,pos=position,noerase=1,xtit=' ',charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=[-90.00,90.00],psym=16,syms=0.8;,ytickformat='dstmwrp_exp'                
67bd858a   Ilyes Choubani   Replication of th...
1295
1296
                            
                            ;Plotting of the spectrum error points
0068116a   Ilyes Choubani   General update + ...
1297
1298
                            rms=3.*((*(*!dustem_data).psi_em).sigma)(idx_spec)/2.
                            cgerrplot,((*(*!dustem_data).psi_em).wav)(idx_spec),((*(*!dustem_data).psi_em).values)(idx_spec)-rms,((*(*!dustem_data).psi_em).values)(idx_spec)+rms,color='Powder Blue'
67bd858a   Ilyes Choubani   Replication of th...
1299
1300
1301
1302
1303
1304

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

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

67bd858a   Ilyes Choubani   Replication of th...
1880
1881
                            
                            endif else begin
74103816   Ilyes Choubani   small update
1882
1883
                                
                                
0068116a   Ilyes Choubani   General update + ...
1884
                                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 ...
1885
                                    
e0d00de0   Ilyes Choubani   removing stops
1886
                                
0068116a   Ilyes Choubani   General update + ...
1887
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-((*(*!dustem_data).qsed).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
1888
1889
1890
1891
                                
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
1892
1893
1894
                                        xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
1895
1896
1897
1898
1899
1900
1901
1902
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
1903
1904
1905
                                        xx = (((*(*!dustem_show).qsed).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*(*!dustem_show).qsed).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*(*!dustem_show).qsed).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
1906
1907
1908
1909
1910
1911
1912
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,/overplot,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr ,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif
                                    
                                    endif
f2caf3f1   Ilyes Choubani   Debugging some er...
1913
                                  
67bd858a   Ilyes Choubani   Replication of th...
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
                            endelse
                            ;stop
                        endif
                        
                    
                    endelse 
                
                
                
                endelse 
            
            endelse ;

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

                                 endif 
18e4331f   Ilyes Choubani   general update (f...
2292
                            
67bd858a   Ilyes Choubani   Replication of th...
2293
                            endif else begin
1bc09467   Ilyes Choubani   fixed issue with ...
2294
                            
0068116a   Ilyes Choubani   General update + ...
2295
                                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 ...
2296
2297
                                    
                                
0068116a   Ilyes Choubani   General update + ...
2298
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,((*(*!dustem_data).used).wav)(idx_filt),-((*(*!dustem_data).used).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2299
2300
2301
2302
2303
                                
                                
                                if ct_hdnpts NE 0 then begin
                                
                                    if ct_spec_hdn_ngtv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2304
2305
2306
                                        xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_spec_hdn_ngtv)
                                        rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_spec_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
2307
2308
2309
2310
2311
2312
2313
2314
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,noerase=1,color='Black',/overplot,rms=rms,yr=yr,xtickformat='(A1)',xr=xr,xs=1,/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_ngtv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2315
2316
2317
                                        xx = (((*(*!dustem_show).used).wav)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        yy = (((*(*!dustem_show).used).values)[idx_rmv_sed])(idx_filt_hdn_ngtv)
                                        rms=3.*(((*(*!dustem_show).used).sigma)[idx_rmv_sed])(idx_filt_hdn_ngtv)/2.
74103816   Ilyes Choubani   small update
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
                                        
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,charsize=1.15,xtickformat='(A1)',/overplot,xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr,ytickformat='(A1)'  
                                        dustem_plot_mlog,xx,yy,ppositions=position,/negative_only,xs=1,noerase=1,color='Black',/overplot,rms=rms,xr=xr,yr=yr,xtickformat='(A1)',/xlog,/ylog,ytickformat='(A1)';,psym=8,syms=0.8
                                    
                                    endif

                                endif     
                                 
                                 
                                 
                                 
                                 
67bd858a   Ilyes Choubani   Replication of th...
2330
2331
2332
                            endelse
                            ;stop
                        endif
18e4331f   Ilyes Choubani   general update (f...
2333
2334
2335
2336
2337
2338
                        
                    
                    endelse 
                
                
                
67bd858a   Ilyes Choubani   Replication of th...
2339
                endelse 
18e4331f   Ilyes Choubani   general update (f...
2340
            
67bd858a   Ilyes Choubani   Replication of th...
2341
2342
            endelse ;

b5314324   Ilyes Choubani   updating the plot...
2343
2344
2345
        
        end
        
afde94a3   Ilyes Choubani   general update
2346
        'QEXT': begin   ;Correct this like you corrected extinction...
1bc09467   Ilyes Choubani   fixed issue with ...
2347
            
4b745987   Ilyes Choubani   minor update
2348
2349
2350
2351
2352
2353
2354
            IF ct_x NE 0 then begin
            
                xr=xr_x 
                yr=yr_x
                
            ENDIF
            
1bc09467   Ilyes Choubani   fixed issue with ...
2355
2356
2357
2358
2359
2360
            vectw=DINDGEN(1001)*(alog10(1E7) - alog10(1E5))/(1000 - 1L) + alog10(1E5)
            vectw=10^vectw[1:*]
            vectw=[wavs,vectw]
            vectx=vectw*0+1
            
            
0068116a   Ilyes Choubani   General update + ...
2361
2362
            varvar=where((*(*!dustem_data).qext).values GT 0, testpstv)
            varvar=where((*(*!dustem_data).qext).values LT 0, testngtv)
2df3360b   Ilyes Choubani   Correcting error:...
2363
            
18e4331f   Ilyes Choubani   general update (f...
2364
            ;stop
0068116a   Ilyes Choubani   General update + ...
2365
2366
            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...
2367
            
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
2368
            
18e4331f   Ilyes Choubani   general update (f...
2369
            ;Locating all the hidden data points (spectrum+filter)
0068116a   Ilyes Choubani   General update + ...
2370
            match2,((*(*!dustem_data).qext).wav),((*(*!dustem_show).qext).wav),show_sedpts,fit_sedpts ;only show_sedpts is needed
74103816   Ilyes Choubani   small update
2371
            idx_rmv_sed=where(fit_sedpts eq -1, ct_hdnpts) ; indices of the points to hide
c8368c6e   Ilyes Choubani   updating plotting...
2372
            
5f04fa07   Ilyes Choubani   general update
2373
            ;stop
bc224f3e   Ilyes Choubani   Update of plottin...
2374
2375
2376
2377
2378
2379
2380
            
            ;#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...
2381
                    xtit=textoidl('1/\lambda (\mum^{-1})')
bc224f3e   Ilyes Choubani   Update of plottin...
2382
                    if !run_pol then xtit = ''
1bc09467   Ilyes Choubani   fixed issue with ...
2383
                    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...
2384
2385
2386
2387
                    xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1                        
                
                endif else begin ;normal plot
                    
18e4331f   Ilyes Choubani   general update (f...
2388
2389
                    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...
2390
                    xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0
bc224f3e   Ilyes Choubani   Update of plottin...
2391
2392
2393
2394
2395
                  
                endelse  
                
            
            endif else begin ;when the data is present 
18e4331f   Ilyes Choubani   general update (f...
2396
                
bc224f3e   Ilyes Choubani   Update of plottin...
2397
                if keyword_set(norm) then begin 
c8368c6e   Ilyes Choubani   updating plotting...
2398
                    
bc224f3e   Ilyes Choubani   Update of plottin...
2399
2400
                    if keyword_set(refresh) then begin ;The data points in the plot that are being refreshed 
                        
07372e26   Ilyes Choubani   Corrected huge pl...
2401
                        ;MAJOR LOOP OVER THE SIGN??? - YES BECAUSE YOU NEED TO KNOW WHICH ONE IS THE 
c8368c6e   Ilyes Choubani   updating plotting...
2402
                
18e4331f   Ilyes Choubani   general update (f...
2403
                        IF ct_spec NE 0 THEN BEGIN
f2caf3f1   Ilyes Choubani   Debugging some er...
2404
                            
0068116a   Ilyes Choubani   General update + ...
2405
                            xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2406
                            yy=dustem_interp[idx_spec]
0068116a   Ilyes Choubani   General update + ...
2407
                            rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
f2caf3f1   Ilyes Choubani   Debugging some er...
2408
2409
2410
2411
2412
2413
2414
2415
                            
                            ;testing so that data/yy is finite: 
                            ;avoiding zero points in yy since we divide by it
                            ;testing also if the data is full of zeros (ie: PSI=0 for U and PSI=90 for Q)
                            
                            indzero = where(yy NE 0, ct_zero)
                            if ct_zero ne 0 then begin  

0068116a   Ilyes Choubani   General update + ...
2416
2417
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_spec))[indzero]/yy[indzero],pos=position,psym=16,color='Powder Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_spec))[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_spec])[indzero]+rms[indzero])/yy[indzero],color='Powder Blue'
f2caf3f1   Ilyes Choubani   Debugging some er...
2418
                            endif
18e4331f   Ilyes Choubani   general update (f...
2419
2420
                        ENDIF
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2421
                        IF ct_filt NE 0 THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
2422
                            ;stop
0068116a   Ilyes Choubani   General update + ...
2423
                            xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2424
                            yy=dustem_interp[idx_filt]
0068116a   Ilyes Choubani   General update + ...
2425
                            rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2. 
f2caf3f1   Ilyes Choubani   Debugging some er...
2426
2427
                            indzero = where(yy NE 0, ct_zero)
                            IF ct_zero NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2428
2429
                                cgoplot,(1/xx)[indzero],(((*(*!dustem_data).qext).values)(idx_filt))[indzero]/yy[indzero],pos=position,psym=16,color='Dodger Blue',syms=0.8,noerase=1 
                                cgerrplot,(1/((*(*!dustem_data).qext).wav)(idx_filt))[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]-rms[indzero])/yy[indzero],((((*(*!dustem_data).qext).values)[idx_filt])[indzero]+rms[indzero])/yy[indzero],color='Dodger Blue' 
f2caf3f1   Ilyes Choubani   Debugging some er...
2430
                            ENDIF
bc224f3e   Ilyes Choubani   Update of plottin...
2431
                        ENDIF
c8368c6e   Ilyes Choubani   updating plotting...
2432
      
bc224f3e   Ilyes Choubani   Update of plottin...
2433
                        
bc224f3e   Ilyes Choubani   Update of plottin...
2434
                    endif else begin ;The data points in the plot that remain unchanged
18e4331f   Ilyes Choubani   general update (f...
2435
                        ;stop
1bc09467   Ilyes Choubani   fixed issue with ...
2436
                        
f2caf3f1   Ilyes Choubani   Debugging some er...
2437
                        xtit=textoidl('1/\lambda (\mum^{-1})')
1355825c   Ilyes Choubani   General update
2438
                        ;if !run_pol then xtit = ''
afde94a3   Ilyes Choubani   general update
2439
                        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...
2440
2441
2442
2443
2444
                        xyouts,pospltxt[0],pospltxt[1],textoidl('norm'),color=0,/normal,charsize=1.1
                    
                    endelse
                    
                
07372e26   Ilyes Choubani   Corrected huge pl...
2445
                endif else begin ; normal plot 
c8368c6e   Ilyes Choubani   updating plotting...
2446
                              
bc224f3e   Ilyes Choubani   Update of plottin...
2447
                    if keyword_set(refresh) then begin ;The data points in the plot are being refreshed
4b745987   Ilyes Choubani   minor update
2448
                        
18e4331f   Ilyes Choubani   general update (f...
2449
2450
                        if keyword_set(positive_only) then begin
     
2df3360b   Ilyes Choubani   Correcting error:...
2451
                            if testpstv ne 0 then begin
4b745987   Ilyes Choubani   minor update
2452
                                
18e4331f   Ilyes Choubani   general update (f...
2453
                                FOR i=0L,Ngrains-1 DO BEGIN
5f04fa07   Ilyes Choubani   general update
2454
                                    
07372e26   Ilyes Choubani   Corrected huge pl...
2455
2456
2457
                                    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...
2458
                                    
4b745987   Ilyes Choubani   minor update
2459

5f04fa07   Ilyes Choubani   general update
2460
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2461
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2462
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2463
                                        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
2464
2465
                                        ;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...
2466
2467
2468
                                        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
2469
                                        
5f04fa07   Ilyes Choubani   general update
2470
                                        ;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 ...
2471
                                        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...
2472
                                        
5f04fa07   Ilyes Choubani   general update
2473
                                    endif
4b745987   Ilyes Choubani   minor update
2474
2475
                                    
                                    
18e4331f   Ilyes Choubani   general update (f...
2476
2477
2478
                                ENDFOR
                                
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2479
2480
                                    
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
67bd858a   Ilyes Choubani   Replication of th...
2481
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2482
2483
                                         
                                            ;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 ...
2484
                                            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...
2485
                                        ENDIF
18e4331f   Ilyes Choubani   general update (f...
2486
2487
2488
2489
                                    ENDIF
                                endfor
                                
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2490
                                    xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2491
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2492
                                    ;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 ...
2493
                                    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...
2494
2495
2496
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2497
                                    xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2498
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2499
                                    ;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 ...
2500
                                    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...
2501
2502
                                ENDIF
                                
1bc09467   Ilyes Choubani   fixed issue with ...
2503
                                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...
2504
                                
18e4331f   Ilyes Choubani   general update (f...
2505
2506
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2507
                        
18e4331f   Ilyes Choubani   general update (f...
2508
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2509
                        
5f04fa07   Ilyes Choubani   general update
2510
                        ;stop
18e4331f   Ilyes Choubani   general update (f...
2511
                        if keyword_set(negative_only) then begin
5f04fa07   Ilyes Choubani   general update
2512
                            ;stop     
2df3360b   Ilyes Choubani   Correcting error:...
2513
                            if testngtv ne 0 then begin
c8368c6e   Ilyes Choubani   updating plotting...
2514
                            
5f04fa07   Ilyes Choubani   general update
2515
                                ;stop    
18e4331f   Ilyes Choubani   general update (f...
2516
2517
                                ;Plotting of the spectra of the dust species
                                FOR i=0L,Ngrains-1 DO BEGIN
07372e26   Ilyes Choubani   Corrected huge pl...
2518
2519
2520
                                    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
2521
2522
                                    ;stop
                                    if countneq ne 0 then begin 
07372e26   Ilyes Choubani   Corrected huge pl...
2523
                                        vecfin = vecto*0.0 ;em_tot can be used here right? 
5f04fa07   Ilyes Choubani   general update
2524
                                        ;stop
07372e26   Ilyes Choubani   Corrected huge pl...
2525
                                        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
2526
                                        ;stop    
07372e26   Ilyes Choubani   Corrected huge pl...
2527
                                        polar_ippsi2iqu,vecte*(*!dustem_HCD)/1.0e21,specqgrain,specugrain,vecfin,replicate(!dustem_psi_ext,n_elements(vecfin)) ;temporary solution
74103816   Ilyes Choubani   small update
2528
                                        
5f04fa07   Ilyes Choubani   general update
2529
                                        ;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 ...
2530
                                        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
2531
                                    endif 
18e4331f   Ilyes Choubani   general update (f...
2532
2533
2534
                                ENDFOR
                                ;Plotting of the plugins
                                for i=0L,n_plgns-1 do begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2535
2536
                                    IF isa((*!dustem_plugin).(0).spec) THEN BEGIN
                                    
67bd858a   Ilyes Choubani   Replication of th...
2537
                                        IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLEXT') THEN begin
3c479f24   Ilyes Choubani   Allowing to fix p...
2538
2539
     
                                            ;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 ...
2540
                                            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...
2541
2542
                                        ENDIF
                                        
18e4331f   Ilyes Choubani   general update (f...
2543
2544
2545
2546
                                    ENDIF
                                endfor
                                ;PLotting of the interpolates corresponding to spectrum and filter points
                                IF ct_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2547
                                    xx=((*(*!dustem_data).qext).wav)[idx_spec]
5f04fa07   Ilyes Choubani   general update
2548
                                    yy=dustem_interp[idx_spec]
18e4331f   Ilyes Choubani   general update (f...
2549
                                    ;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 ...
2550
                                    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...
2551
2552
2553
                                ENDIF
                                
                                IF ct_filt NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
2554
                                    xx=((*(*!dustem_data).qext).wav)[idx_filt]
5f04fa07   Ilyes Choubani   general update
2555
                                    yy=dustem_interp[idx_filt]
18e4331f   Ilyes Choubani   general update (f...
2556
                                    ;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 ...
2557
                                    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...
2558
2559
                                ENDIF
                                ;Plotting of the total dust emission spectrum
1bc09467   Ilyes Choubani   fixed issue with ...
2560
                                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...
2561
2562
2563
                            
                            endif
                                    
bc224f3e   Ilyes Choubani   Update of plottin...
2564
                        
18e4331f   Ilyes Choubani   general update (f...
2565
2566
2567
2568
2569
2570
                        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...
2571
                        xyouts,pospltxt[0],pospltxt[1],textoidl('\tau_{QEXT}'),color=0,/normal,charsize=1.3;,charthick=2.0  
2df3360b   Ilyes Choubani   Correcting error:...
2572
                        ;if ct_hdnpts ne 0 then begin ;Hidden data points are present 
18e4331f   Ilyes Choubani   general update (f...
2573
                            
2df3360b   Ilyes Choubani   Correcting error:...
2574
2575
                        ;Locating the hidden spectrum and filter data points     
                        ;SADLY I STILL DON'T HAVE A SOLUTION FOR THE PLOTTING OF NULL VALUES.                                   
0068116a   Ilyes Choubani   General update + ...
2576
2577
                        ;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...
2578
                        if ct_hdnpts then begin
0068116a   Ilyes Choubani   General update + ...
2579
2580
2581
2582
                            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...
2583
                        endif
bc224f3e   Ilyes Choubani   Update of plottin...
2584
                        
c8368c6e   Ilyes Choubani   updating plotting...
2585
                        
18e4331f   Ilyes Choubani   general update (f...
2586
                        if keyword_set(positive_only) then begin
afde94a3   Ilyes Choubani   general update
2587
                            
2df3360b   Ilyes Choubani   Correcting error:...
2588
                            if testpstv ne 0 then begin
07372e26   Ilyes Choubani   Corrected huge pl...
2589
                        
74103816   Ilyes Choubani   small update
2590
2591
2592
2593
2594
                                plotsym, 0
                                
                                
                                if ct_spec ne 0 then begin
                                
0068116a   Ilyes Choubani   General update + ...
2595
2596
                                    rms=3.*((*(*!dustem_data).qext).sigma)(idx_spec)/2.
                                    ;dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_spec),-((*(*!dustem_data).qsed).values)(idx_spec),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2597
                                
0068116a   Ilyes Choubani   General update + ...
2598
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,charsize=1.15,color='Powder Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2599
                                    
0068116a   Ilyes Choubani   General update + ...
2600
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_spec),((*(*!dustem_data).qext).values)(idx_spec),ppositions=position,color='Powder Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'     
74103816   Ilyes Choubani   small update
2601
2602
2603
2604
2605
                                     
                                endif
                                
                                if ct_filt ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2606
2607
2608
2609
2610
                                    rms=3.*((*(*!dustem_data).qext).sigma)(idx_filt)/2.
                                   ; dustem_plot_mlog,((*(*!dustem_data).qsed).wav)(idx_filt),-1.*((*(*!dustem_data).qsed).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,/nodata,noerase=1,/negative_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    if ct_spec ne 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr,ytickformat='(A1)'
                                    if ct_spec eq 0 then dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
                                    dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),((*(*!dustem_data).qext).values)(idx_filt),ppositions=position,color='Dodger Blue',/positive_only,noerase=1,/overplot,rms=rms,xtit='',charsize=1.15,xtickformat='(A1)',xs=1,psym=16,syms=0.8,xr=xr,/xlog,/ylog,yr=yr,ytickformat='(A1)'
74103816   Ilyes Choubani   small update
2611
2612
2613
                                        
                                endif
                                
18e4331f   Ilyes Choubani   general update (f...
2614
                                
74103816   Ilyes Choubani   small update
2615
                                if ct_hdnpts NE 0 then begin
18e4331f   Ilyes Choubani   general update (f...
2616
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2617
                                    if ct_spec_hdn_pstv ne 0 then begin
0068116a   Ilyes Choubani   General update + ...
2618
2619
2620
                                        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...
2621
                                        
74103816   Ilyes Choubani   small update
2622
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr
1bc09467   Ilyes Choubani   fixed issue with ...
2623
                                        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...
2624
2625
2626
2627
2628
                                    
                                    endif 
                                    
                                    if ct_filt_hdn_pstv ne 0 then begin
                                    
0068116a   Ilyes Choubani   General update + ...
2629
2630
2631
                                        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...
2632
                                        
74103816   Ilyes Choubani   small update
2633
                                        dustem_plot_mlog,1/xx,yy,ppositions=position,/positive_only,xs=1,noerase=1,/overplot,charsize=1.15,xtickformat='(A1)',xr=xr,color='Black',psym=16,syms=0.8,/xlog,/ylog,yr=yr   
1bc09467   Ilyes Choubani   fixed issue with ...
2634
                                        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...
2635
2636
                                    
                                    endif
18e4331f   Ilyes Choubani   general update (f...
2637
                                    
18e4331f   Ilyes Choubani   general update (f...
2638
2639
                                endif
                                
9cb38725   Ilyes Choubani   Fixed tests relat...
2640
                                
18e4331f   Ilyes Choubani   general update (f...
2641
2642
                            endif else begin
                            
1bc09467   Ilyes Choubani   fixed issue with ...
2643
                            
0068116a   Ilyes Choubani   General update + ...
2644
                                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...
2645
                                    
1bc09467   Ilyes Choubani   fixed issue with ...
2646
                                
0068116a   Ilyes Choubani   General update + ...
2647
                                if ct_filt ne 0 and ct_spec eq 0 then  dustem_plot_mlog,1/((*(*!dustem_data).qext).wav)(idx_filt),-((*(*!dustem_data).qext).values)(idx_filt),/nodata,ppositions=position,charsize=1.15,color='Dodger Blue',psym=16,syms=0.8,xs=1,xr=xr,noerase=1,/positive_only,xtickformat='(A1)',xtit='',/xlog,/ylog,yr=yr;,ytickformat='(A1)'
1bc09467   Ilyes Choubani   fixed issue with ...
2648
                                
f2caf3f1   Ilyes Choubani   Debugging some er...
2649

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

                    xxpos=(1-thiswidth)/2
8fbdb4c3   Ilyes Choubani   Fixed minor 0/0 e...
3297
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3298
3299
3300
3301
3302
                
                    ;stop
                    k=0   
                    res = dustem_interp
                    errors = dustem_spec
5f04fa07   Ilyes Choubani   general update
3303
                ;stop
53548c91   Ilyes Choubani   Display of frozen...
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
                
                    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 ...
3314
                        
53548c91   Ilyes Choubani   Display of frozen...
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
                      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
3339
                        
53548c91   Ilyes Choubani   Display of frozen...
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
                          ;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 - ...
3362
                    
fcb6eade   Ilyes Choubani   general update - ...
3363
                ENDIF
53548c91   Ilyes Choubani   Display of frozen...
3364
                    
5f04fa07   Ilyes Choubani   general update
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
                
            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...
3378
3379
3380
3381
3382
3383
                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
3384
                        
53548c91   Ilyes Choubani   Display of frozen...
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
                        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...
3410
                    if ~isa(yypos) then yypos = 0.8 else yypos-=0.22 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
                    
                    
                    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
3444
                            
53548c91   Ilyes Choubani   Display of frozen...
3445
3446
3447
3448
3449
3450
                        ENDIF          
                                
                    
                    ENDFOR
                
             ENDIF
5f04fa07   Ilyes Choubani   general update
3451
                
e9bb0ce2   Ilyes Choubani   Correcting small ...
3452
            endif else begin ;(FROZEN RUN = title strings + fixed plugins (TBDONE))
5f04fa07   Ilyes Choubani   general update
3453
                
53548c91   Ilyes Choubani   Display of frozen...
3454
3455
3456
                
                
                IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN
5f04fa07   Ilyes Choubani   general update
3457
                    
53548c91   Ilyes Choubani   Display of frozen...
3458
3459
                    Nfpar = n_elements((*(*!dustem_fit).fixed_param_descs))
                    res = (*(*!dustem_fit).fixed_param_init_values)
5f04fa07   Ilyes Choubani   general update
3460
                    
0068116a   Ilyes Choubani   General update + ...
3461
                    iii=0
74103816   Ilyes Choubani   small update
3462
3463
3464
3465
                    FOR i=0L,Nfpar-1 DO BEGIN
                        
                        parameter_description = (*(*!dustem_fit).fixed_param_descs)[i]     
                        parameter_type = dustem_parameter_description2type(parameter_description,string_name=string_name)
0068116a   Ilyes Choubani   General update + ...
3466
                        if parameter_type EQ 'PLUGIN' then iii+=1 
74103816   Ilyes Choubani   small update
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
                        
                    ENDFOR
                    k = 0
                    if iii ne 0 then begin
                        xxpos = 0.0
                        yypos = 0.9
                        ;xxpos = 0.0 ;might need to be modified
                        cgtext, xxpos, yypos, '-FROZEN-', charsize=-1, width=thiswidth, /normal  
                        xxpos=(1-thiswidth)/2
                        xyouts, xxpos, yypos, '-FROZEN-', charsize=1.2, /normal, color=0
                    endif
53548c91   Ilyes Choubani   Display of frozen...
3478
3479
3480
3481
3482
3483
3484
                    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
3485
                        
53548c91   Ilyes Choubani   Display of frozen...
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
                            
                            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
3507
                         
53548c91   Ilyes Choubani   Display of frozen...
3508
3509
3510
3511
                    ENDFOR  
                     
                ENDIF
                
0c487640   Ilyes Choubani   corrected missing...
3512
                xxpos = 0
53548c91   Ilyes Choubani   Display of frozen...
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
                
                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...
3526
                    if ~isa(yypos) then yypos = 0.9 else yypos-=0.1*1.2 ;not sure about this
53548c91   Ilyes Choubani   Display of frozen...
3527
3528
3529
3530
3531
                     ;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...
3532
                    xyouts, xxpos, yypos, '-FREE-', charsize=1.2, /normal,color=0
53548c91   Ilyes Choubani   Display of frozen...
3533
3534
3535
3536
3537
3538
3539
                    
                    
                    k=0
                    res = dustem_interp
                    errors = dustem_spec
                    yypos-=0.1
                    yypostmp = yypos
5f04fa07   Ilyes Choubani   general update
3540
                        
53548c91   Ilyes Choubani   Display of frozen...
3541
3542
3543
3544
                    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
3545
                        
5f04fa07   Ilyes Choubani   general update
3546
                        
53548c91   Ilyes Choubani   Display of frozen...
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
                        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
3573
                    
53548c91   Ilyes Choubani   Display of frozen...
3574
3575
                    ENDFOR
                ENDIF
5f04fa07   Ilyes Choubani   general update
3576
3577
3578
3579
            endelse
         
        
        
5f04fa07   Ilyes Choubani   general update
3580
3581
        end
        
b5314324   Ilyes Choubani   updating the plot...
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
    
    endcase


endif










b5314324   Ilyes Choubani   updating the plot...
3597
END