Blame view

src/idl/dustem_set_data.pro 14.2 KB
ebbb68b1   Jean-Philippe Bernard   improved the help
1
PRO dustem_set_data,m_fit,m_show,x_fit,x_show,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help
abebbdf3   Ilyes Choubani   General update: A...
2

427f1205   Jean-Michel Glorian   version 4.2 merged
3
4
5
;+
; NAME:
;    dustem_set_data
edeb9236   Annie Hughes   updated doc help
6
;
427f1205   Jean-Michel Glorian   version 4.2 merged
7
; PURPOSE:
0068116a   Ilyes Choubani   General update + ...
8
;    Initializes the dustem data structure (*!dustem_data) used in the fitting
04efbaa5   Ilyes Choubani   Correcting set_da...
9
;    Initializes the !dustem_show structure which is either a copy or a more detailed version of !dustem_data 
edeb9236   Annie Hughes   updated doc help
10
;
427f1205   Jean-Michel Glorian   version 4.2 merged
11
; CATEGORY:
553fad92   Annie Hughes   updated doc help
12
;    DustEMWrap, Mid-Level, Distributed, Initialization
edeb9236   Annie Hughes   updated doc help
13
;
427f1205   Jean-Michel Glorian   version 4.2 merged
14
; CALLING SEQUENCE:
ebbb68b1   Jean-Philippe Bernard   improved the help
15
;    dustem_set_data[,m_fit,x_fit][,m_show,x_show][,rchi2_weight=][,f_HI=][,/help]
edeb9236   Annie Hughes   updated doc help
16
;
427f1205   Jean-Michel Glorian   version 4.2 merged
17
; INPUTS:
ebbb68b1   Jean-Philippe Bernard   improved the help
18
;    None
edeb9236   Annie Hughes   updated doc help
19
;
ebbb68b1   Jean-Philippe Bernard   improved the help
20
; OPTIONAL INPUT PARAMETERS:
04efbaa5   Ilyes Choubani   Correcting set_da...
21
22
;    m_fit : dustemwrap structure contaning emission data to be fitted 
;    x_fit : dustemwrap structure containing extinction data to be fitted
04efbaa5   Ilyes Choubani   Correcting set_da...
23
24
;    m_show : dustemwrap structure containing emission data to be displayed
;    x_show : dustemwrap structure containing extinctiond data to be displayed
ebbb68b1   Jean-Philippe Bernard   improved the help
25
26
;    rchi2_weight : dustemwrap structure containing the wieghts for chi2 calculation
;    f_HI : multiplicative factor for the SED values (extinction and emission)
edeb9236   Annie Hughes   updated doc help
27
;
427f1205   Jean-Michel Glorian   version 4.2 merged
28
29
; OUTPUTS:
;    None
edeb9236   Annie Hughes   updated doc help
30
;
427f1205   Jean-Michel Glorian   version 4.2 merged
31
32
; OPTIONAL OUTPUT PARAMETERS:
;    None
edeb9236   Annie Hughes   updated doc help
33
;
427f1205   Jean-Michel Glorian   version 4.2 merged
34
35
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
edeb9236   Annie Hughes   updated doc help
36
;
427f1205   Jean-Michel Glorian   version 4.2 merged
37
38
; COMMON BLOCKS:
;    None
edeb9236   Annie Hughes   updated doc help
39
;
427f1205   Jean-Michel Glorian   version 4.2 merged
40
; SIDE EFFECTS:
ebbb68b1   Jean-Philippe Bernard   improved the help
41
42
;    initializes !dustem_data and !dustem_show
;    wavelengths are forced to be the central filter wavelength for photometric data
edeb9236   Annie Hughes   updated doc help
43
;
427f1205   Jean-Michel Glorian   version 4.2 merged
44
; RESTRICTIONS:
edeb9236   Annie Hughes   updated doc help
45
46
;    The DustEMWrap IDL code must be installed
; 
427f1205   Jean-Michel Glorian   version 4.2 merged
47
48
; PROCEDURE:
;    None
edeb9236   Annie Hughes   updated doc help
49
;
427f1205   Jean-Michel Glorian   version 4.2 merged
50
51
; EXAMPLES
;    dustem_init
04efbaa5   Ilyes Choubani   Correcting set_da...
52
53
;    dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
;    file=dir+'example_SED_1.xcat'
427f1205   Jean-Michel Glorian   version 4.2 merged
54
;    spec=read_xcat(file,/silent)
ebbb68b1   Jean-Philippe Bernard   improved the help
55
;    dustem_set_data,spec,x_fit,spec,x_show)
04efbaa5   Ilyes Choubani   Correcting set_da...
56
;    #in this example !dustem_data and !dustem_show are identical
edeb9236   Annie Hughes   updated doc help
57
;
427f1205   Jean-Michel Glorian   version 4.2 merged
58
; MODIFICATION HISTORY:
553fad92   Annie Hughes   updated doc help
59
;    Written by J.-Ph. Bernard 2007
427f1205   Jean-Michel Glorian   version 4.2 merged
60
61
;    V. Guillet (2012) : dustem_set_data is turned into a function which can be used 
;                        indifferently for sed, ext, polext
04efbaa5   Ilyes Choubani   Correcting set_da...
62
;    I. Choubani (2022): dustem_check_data is introduced and the data structure format of the latest release is respected.
553fad92   Annie Hughes   updated doc help
63
64
65
66
;                       dustem_set_data is turned into a procedure.
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
67

427f1205   Jean-Michel Glorian   version 4.2 merged
68
69
70
71
72
IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_set_data'
  goto,the_end
ENDIF

5a2643a4   Ilyes Choubani   cleaning/improvin...
73
;Cleaninig fitting/showing structure(s) 
0068116a   Ilyes Choubani   General update + ...
74
75
76
for i=0L,n_tags(*!dustem_data)-1 do begin
    (*!dustem_data).(i) = ptr_new()
    (*!dustem_show).(i) = ptr_new()
3ff9cac3   Ilyes Choubani   general update
77
78
endfor

5a2643a4   Ilyes Choubani   cleaning/improvin...
79
;#FITTING STRUCTURE
3c479f24   Ilyes Choubani   Allowing to fix p...
80

0068116a   Ilyes Choubani   General update + ...
81
82
83
84
85
86
;To me this is unnecessary... as dustem_check_data is always needed as it shapes the output structures (that would otherwise not exist)
;in order to prepare them for the mpfit run.
;the *!dustem_data tags are always cleaned so data will never exist if this keyword is used.
;commenting the use of nocheck_data for now
  
;IF not keyword_set(nocheck_data) THEN BEGIN
070144e1   Jean-Philippe Bernard   improved only sli...
87
    dustem_check_data,m_fit,x_fit,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext
0068116a   Ilyes Choubani   General update + ...
88
89
;ENDIF

3ff9cac3   Ilyes Choubani   general update
90
;outputs whatever the input structure has, into organized seperate structures formatted for the fitting process.
09e61d64   Ilyes Choubani   cleaned set_data ...
91

abebbdf3   Ilyes Choubani   General update: A...
92
;FITTING STRUCTURE INITIALIZATION
0068116a   Ilyes Choubani   General update + ...
93
94
IF isa(sed) THEN (*!dustem_data).sed = ptr_new(sed)
IF isa(ext) THEN (*!dustem_data).ext = ptr_new(ext)
09e61d64   Ilyes Choubani   cleaned set_data ...
95

3ff9cac3   Ilyes Choubani   general update
96
97
98
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
99
100
If keyword_set(f_HI) and ptr_valid((*!dustem_data).sed) then begin
    if f_HI gt 0 then (*(*!dustem_data).sed).values *= f_HI else f_HI = 1.
3ff9cac3   Ilyes Choubani   general update
101
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
102
103
if keyword_set(f_HI) and ptr_valid((*!dustem_data).ext) then begin
    if f_HI gt 0 then (*(*!dustem_data).ext).values *= f_HI else f_HI = 1.
3ff9cac3   Ilyes Choubani   general update
104
105
106
107
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

3ff9cac3   Ilyes Choubani   general update
108
if !run_pol then begin
266ae799   Ilyes Choubani   General update
109
    
abebbdf3   Ilyes Choubani   General update: A...
110
    if keyword_set(m_fit) then begin
262cff06   Ilyes Choubani   minor changes to ...
111
    
3ff9cac3   Ilyes Choubani   general update
112
        teststks = isa(qsed) and isa(used)
9074d6cd   Jean-Philippe Bernard   fixed a bug of Na...
113
    ;stop
1355825c   Ilyes Choubani   General update
114
        IF ~teststks  then message, 'Stokes parameters are not set correctly. Please check the input structure. Aborting...'
3ff9cac3   Ilyes Choubani   general update
115
    
abebbdf3   Ilyes Choubani   General update: A...
116
        ;☆EMISSION 
1355825c   Ilyes Choubani   General update
117
        message, 'Polarization component(s) to fit: QSED and USED' ,/continue
abebbdf3   Ilyes Choubani   General update: A...
118
119
120
        
        
        ;☆Mandatory presence in polar mode 
3ff9cac3   Ilyes Choubani   general update
121
        IF isa(qsed) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
122
            (*!dustem_data).qsed = ptr_new(qsed)
b0cabd3c   Ilyes Choubani   general update
123
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
124
          	(*(*!dustem_data).qsed).values *= f_HI
b0cabd3c   Ilyes Choubani   general update
125
        ENDIF    
abebbdf3   Ilyes Choubani   General update: A...
126
        ;☆Mandatory presence in polar mode
3ff9cac3   Ilyes Choubani   general update
127
        if isa(used) then BEGIN
0068116a   Ilyes Choubani   General update + ...
128
            (*!dustem_data).used = ptr_new(used)
b0cabd3c   Ilyes Choubani   general update
129
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
130
          	(*(*!dustem_data).used).values *= f_HI
b0cabd3c   Ilyes Choubani   general update
131
        ENDIF
1355825c   Ilyes Choubani   General update
132
133
134
        
        if isa(polsed) then BEGIN
            
0068116a   Ilyes Choubani   General update + ...
135
            (*!dustem_data).polsed = ptr_new(polsed)
1355825c   Ilyes Choubani   General update
136
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
137
          	(*(*!dustem_data).polsed).values *= f_HI
1355825c   Ilyes Choubani   General update
138
139
140
141
142
            
        ENDIF 
        
        if isa(polfrac) then BEGIN
            
0068116a   Ilyes Choubani   General update + ...
143
            (*!dustem_data).polfrac = ptr_new(polfrac)
1355825c   Ilyes Choubani   General update
144
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
145
          	(*(*!dustem_data).polfrac).values *= f_HI
1355825c   Ilyes Choubani   General update
146
        
abebbdf3   Ilyes Choubani   General update: A...
147
        ENDIF
1355825c   Ilyes Choubani   General update
148
149
150
        
        if isa(psi_em) then BEGIN
            
0068116a   Ilyes Choubani   General update + ...
151
            (*!dustem_data).psi_em = ptr_new(psi_em)
1355825c   Ilyes Choubani   General update
152
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
153
          	(*(*!dustem_data).psi_em).values *= f_HI
1355825c   Ilyes Choubani   General update
154
155
156
157
        
        ENDIF 
        
        
b0cabd3c   Ilyes Choubani   general update
158
    endif
759a527d   Ilyes Choubani   general update
159
    
abebbdf3   Ilyes Choubani   General update: A...
160
    if keyword_set(x_fit) then begin
5a2643a4   Ilyes Choubani   cleaning/improvin...
161
    
3ff9cac3   Ilyes Choubani   general update
162
        ;Two tests that determine what the user will eventually fit
3ff9cac3   Ilyes Choubani   general update
163
        testexstks = isa(qext) and isa(uext)
3ff9cac3   Ilyes Choubani   general update
164
        
1355825c   Ilyes Choubani   General update
165
166
        IF ~testexstks then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...'
         
3ff9cac3   Ilyes Choubani   general update
167
        ;EXTINCTION - allowed for the default fitting of both because I do not know if the same formalism should be applied to the extinction data because it also implies deviding extinction data into two components. 
1355825c   Ilyes Choubani   General update
168
169
170
       
        message, 'Extinction polarization component(s) to fit: QEXT and UEXT',/continue
       
3ff9cac3   Ilyes Choubani   general update
171
        if isa(polext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
172
            (*!dustem_data).polext = ptr_new(polext)
b0cabd3c   Ilyes Choubani   general update
173
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
174
           	(*(*!dustem_data).polext).values *= f_HI
b0cabd3c   Ilyes Choubani   general update
175
        ENDIF
3ff9cac3   Ilyes Choubani   general update
176
        IF isa(qext) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
177
            (*!dustem_data).qext = ptr_new(qext)
b0cabd3c   Ilyes Choubani   general update
178
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
179
           	(*(*!dustem_data).qext).values *= f_HI
b0cabd3c   Ilyes Choubani   general update
180
        ENDIF
3ff9cac3   Ilyes Choubani   general update
181
        if isa(uext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
182
            (*!dustem_data).uext = ptr_new(uext)
b0cabd3c   Ilyes Choubani   general update
183
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
184
           	(*(*!dustem_data).uext).values *= f_HI
b0cabd3c   Ilyes Choubani   general update
185
        ENDIF
1355825c   Ilyes Choubani   General update
186
        
07372e26   Ilyes Choubani   Corrected huge pl...
187
        if isa(psi_ext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
188
            (*!dustem_data).psi_ext = ptr_new(psi_ext)
07372e26   Ilyes Choubani   Corrected huge pl...
189
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
190
           	(*(*!dustem_data).psi_ext).values *= f_HI
07372e26   Ilyes Choubani   Corrected huge pl...
191
192
        ENDIF
        
67bd858a   Ilyes Choubani   Replication of th...
193
194
        ;added for completeness 
        if isa(fpolext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
195
            (*!dustem_data).fpolext = ptr_new(fpolext)
67bd858a   Ilyes Choubani   Replication of th...
196
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
197
           	(*(*!dustem_data).fpolext).values *= f_HI
67bd858a   Ilyes Choubani   Replication of th...
198
199
        ENDIF
        
b0cabd3c   Ilyes Choubani   general update
200
    endif
3ff9cac3   Ilyes Choubani   general update
201
202
endif

5a2643a4   Ilyes Choubani   cleaning/improvin...
203
;#SHOWING STRUCTURE
3ff9cac3   Ilyes Choubani   general update
204

04efbaa5   Ilyes Choubani   Correcting set_da...
205
206
207
if keyword_set(m_fit) and not keyword_set(m_show) then m_show=m_fit
if keyword_set(x_fit) and not keyword_set(x_show) then x_show = x_fit

427f1205   Jean-Michel Glorian   version 4.2 merged
208

3ff9cac3   Ilyes Choubani   general update
209
;Setting of the structure that will be displayed
0068116a   Ilyes Choubani   General update + ...
210
;IF not keyword_set(nocheck_data) THEN BEGIN
070144e1   Jean-Philippe Bernard   improved only sli...
211
    dustem_check_data,m_show,x_show,sed,ext,polext,polsed,polfrac,psi_em,qsed,used,qext,uext,psi_ext,fpolext
0068116a   Ilyes Choubani   General update + ...
212
;ENDIF
5a2643a4   Ilyes Choubani   cleaning/improvin...
213

0068116a   Ilyes Choubani   General update + ...
214
215
IF isa(sed) THEN (*!dustem_show).sed = ptr_new(sed)
IF isa(ext) THEN (*!dustem_show).ext = ptr_new(ext)
3ff9cac3   Ilyes Choubani   general update
216
217
218
219
  
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
220
221
If keyword_set(f_HI) and ptr_valid((*!dustem_show).sed) then begin
    if f_HI gt 0 then (*(*!dustem_show).sed).values *= f_HI else f_HI = 1.
3ff9cac3   Ilyes Choubani   general update
222
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
223
224
if keyword_set(f_HI) and ptr_valid((*!dustem_show).ext) then begin
    if f_HI gt 0 then (*(*!dustem_show).ext).values *= f_HI else f_HI = 1.
3ff9cac3   Ilyes Choubani   general update
225
226
227
228
229
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

if !run_pol then begin
6a714abf   Ilyes Choubani   small fix to dust...
230
    
abebbdf3   Ilyes Choubani   General update: A...
231
    if isa(m_show) then begin ; because sometimes this keyword isn't set.
3ff9cac3   Ilyes Choubani   general update
232
233
234
        
        teststks = isa(qsed) and isa(used)
        
1355825c   Ilyes Choubani   General update
235
        IF (~teststks and ~isa(polsed)) or (~teststks and ~isa(polfrac)) then message, 'Stokes parameters/Polarization showing data is not set correctly. Please check the input structure. Aborting...'
3ff9cac3   Ilyes Choubani   general update
236
        
1355825c   Ilyes Choubani   General update
237
238
239
240
241
242
        if teststks and isa(polsed) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLSED'
        if teststks and isa(polsed) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED, POLSED and PSI_EM'
        if teststks and ~(isa(polsed)) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED and POLFRAC'
        if teststks and ~(isa(polsed)) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC and PSI_EM'
        if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and ~(isa(psi_em)) then nowshowing = 'QSED and USED'
        if teststks and isa(polsed) and isa(polfrac) and ~(isa(psi_em)) then nowshowing = 'QSED, USED, POLSED and POLFRAC'
3ff9cac3   Ilyes Choubani   general update
243
        if teststks and isa(polsed) and isa(polfrac) and isa(psi_em) then nowshowing = 'QSED, USED, POLFRAC, POLSED and PSI_EM'
1355825c   Ilyes Choubani   General update
244
        if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM'
3ff9cac3   Ilyes Choubani   general update
245
        
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
246

3ff9cac3   Ilyes Choubani   general update
247
248
249
250
        message, 'Polarization component(s) to show: '+nowshowing ,/continue
        
        
        If isa(polsed) then BEGIN    ;Apply changes to !dustem_data here.      
0068116a   Ilyes Choubani   General update + ...
251
            (*!dustem_show).polsed = ptr_new(polsed)
3ff9cac3   Ilyes Choubani   general update
252
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
253
           	(*(*!dustem_show).polsed).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
254
255
        ENDIF
        If isa(polfrac) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
256
            (*!dustem_show).polfrac = ptr_new(polfrac)
3ff9cac3   Ilyes Choubani   general update
257
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
258
           	(*(*!dustem_show).polfrac).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
259
260
        ENDIF
        IF isa(qsed) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
261
            (*!dustem_show).qsed = ptr_new(qsed)
3ff9cac3   Ilyes Choubani   general update
262
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
263
           	(*(*!dustem_show).qsed).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
264
265
        ENDIF    
        if isa(used) then BEGIN
0068116a   Ilyes Choubani   General update + ...
266
            (*!dustem_show).used = ptr_new(used)
3ff9cac3   Ilyes Choubani   general update
267
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
268
           	(*(*!dustem_show).used).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
269
270
        ENDIF
        if isa(psi_em) then BEGIN
0068116a   Ilyes Choubani   General update + ...
271
            (*!dustem_show).psi_em = ptr_new(psi_em)
3ff9cac3   Ilyes Choubani   general update
272
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
273
            (*(*!dustem_show).psi_em).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
274
275
        ENDIF        
    endif
abebbdf3   Ilyes Choubani   General update: A...
276
    if isa(x_show) then begin
3ff9cac3   Ilyes Choubani   general update
277
278
        teststks = isa(qext) and isa(uext)
        
1355825c   Ilyes Choubani   General update
279
        IF (~teststks) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...'
04efbaa5   Ilyes Choubani   Correcting set_da...
280
                
67bd858a   Ilyes Choubani   Replication of th...
281
282
283
284
285
286
287
288
        if teststks and isa(polext) and ~(isa(polextfrac)) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXT'
        if teststks and isa(polext) and ~(isa(polextfrac)) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXT and PSI_EXT'
        if teststks and ~(isa(polext)) and isa(polextfrac) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT and POLEXTFRAC'
        if teststks and ~(isa(polext)) and isa(polextfrac) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXTFRAC and PSI_EXT'
        if teststks and ~(isa(polext)) and ~(isa(polextfrac)) and ~(isa(psi_ext)) then nowshowing = 'QEXT and UEXT'
        if teststks and isa(polext) and isa(polextfrac) and ~(isa(psi_ext)) then nowshowing = 'QEXT, UEXT, POLEXT and POLEXTFRAC'
        if teststks and isa(polext) and isa(polextfrac) and isa(psi_ext) then nowshowing = 'QEXT, UEXT, POLEXTFRAC, POLEXT and PSI_EXT'
        if teststks and ~(isa(polext)) and ~(isa(polextfrac)) and isa(psi_ext) then nowshowing = 'QEXT, UEXT and PSI_EXT'
3ff9cac3   Ilyes Choubani   general update
289
        
3ff9cac3   Ilyes Choubani   general update
290
291
292
293
294
        
        message, 'Polarization component(s) to show: '+nowshowing ,/continue
        
        ;EXTINCTION
        if isa(polext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
295
            (*!dustem_show).polext = ptr_new(polext)
3ff9cac3   Ilyes Choubani   general update
296
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
297
           	(*(*!dustem_show).polext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
298
299
        ENDIF
        IF isa(qext) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
300
            (*!dustem_show).qext = ptr_new(qext)
3ff9cac3   Ilyes Choubani   general update
301
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
302
           	(*(*!dustem_show).qext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
303
304
        ENDIF
        if isa(uext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
305
            (*!dustem_show).uext = ptr_new(uext)
3ff9cac3   Ilyes Choubani   general update
306
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
307
           	(*(*!dustem_show).uext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
308
309
        ENDIF
        if isa(psi_ext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
310
            (*!dustem_show).psi_ext = ptr_new(psi_ext)
3ff9cac3   Ilyes Choubani   general update
311
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
312
           	(*(*!dustem_show).psi_ext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
313
        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
314
315
316
317
        
        ;Added for completeness
        
        if isa(fpolext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
318
            (*!dustem_show).fpolext = ptr_new(fpolext)
67bd858a   Ilyes Choubani   Replication of th...
319
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
320
           	(*(*!dustem_show).fpolext).values *= f_HI
67bd858a   Ilyes Choubani   Replication of th...
321
322
        ENDIF
        
3ff9cac3   Ilyes Choubani   general update
323
324
    endif
endif
427f1205   Jean-Michel Glorian   version 4.2 merged
325

09e61d64   Ilyes Choubani   cleaned set_data ...
326
IF keyword_set(rchi2_weight) THEN BEGIN
d0f68bb6   Jean-Philippe Bernard   replaced system v...
327
328
	(*!fit_rchi2_weight).sed     = rchi2_weight.sed
	(*!fit_rchi2_weight).ext     = rchi2_weight.ext
09e61d64   Ilyes Choubani   cleaned set_data ...
329
	
6a714abf   Ilyes Choubani   small fix to dust...
330
	IF !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
331
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
332
333
    	IF isa(qsed) THEN (*!fit_rchi2_weight).qsed  = rchi2_weight.qsed
    	IF isa(used) THEN (*!fit_rchi2_weight).used  = rchi2_weight.used
6a714abf   Ilyes Choubani   small fix to dust...
334
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
335
336
    	IF isa(qext) THEN (*!fit_rchi2_weight).qext  = rchi2_weight.qext
    	IF isa(uext) THEN (*!fit_rchi2_weight).uext  = rchi2_weight.uext
6a714abf   Ilyes Choubani   small fix to dust...
337
338
    ENDIF
    
3ff9cac3   Ilyes Choubani   general update
339
340
ENDIF ELSE BEGIN

d0f68bb6   Jean-Philippe Bernard   replaced system v...
341
342
    (*!fit_rchi2_weight).sed=1.
    (*!fit_rchi2_weight).ext=1.
3ff9cac3   Ilyes Choubani   general update
343
344
    
    If !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
345
        
d0f68bb6   Jean-Philippe Bernard   replaced system v...
346
347
        IF isa(qsed) THEN (*!fit_rchi2_weight).qsed=1.
        IF isa(used) THEN (*!fit_rchi2_weight).used=1.
1355825c   Ilyes Choubani   General update
348
        
d0f68bb6   Jean-Philippe Bernard   replaced system v...
349
350
        IF isa(qext) THEN (*!fit_rchi2_weight).qext=1.
        IF isa(uext) THEN (*!fit_rchi2_weight).uext=1.
1355825c   Ilyes Choubani   General update
351
    
3ff9cac3   Ilyes Choubani   general update
352
    ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
353

3ff9cac3   Ilyes Choubani   general update
354
ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
355

04efbaa5   Ilyes Choubani   Correcting set_da...
356
357
358
; ;Setting the data and wavelength tags in '!dustem_fit'
; ;ask about it because !dustem_fit's tag was initially empty...s
; ((*!dustem_fit).data)=ptr_new(!dustem_data)
a5aa7a87   Jean-Philippe Bernard   added a stop when...
359
360
361
362
363
IF not ptr_valid((*!dustem_data).sed) AND not ptr_valid((*!dustem_data).ext) THEN BEGIN
  message,'dustemwrap system variable was not set properly.',/continue
  message,'Check the existence of at least some non undefined values in StokesI and sigmaII.',/continue
  stop
ENDIF
5a2643a4   Ilyes Choubani   cleaning/improvin...
364

427f1205   Jean-Michel Glorian   version 4.2 merged
365
366
the_end:

04efbaa5   Ilyes Choubani   Correcting set_da...
367
368
; 
; return,0.
3ff9cac3   Ilyes Choubani   general update
369
370
371
372




427f1205   Jean-Michel Glorian   version 4.2 merged
373
END