Blame view

src/idl/dustem_set_data.pro 14.2 KB
0068116a   Ilyes Choubani   General update + ...
1
PRO dustem_set_data,m_fit,m_show,x_fit,x_show,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help;,nocheck_data=nocheck_data
abebbdf3   Ilyes Choubani   General update: A...
2

427f1205   Jean-Michel Glorian   version 4.2 merged
3
4
5
;+
; NAME:
;    dustem_set_data
553fad92   Annie Hughes   updated doc help
6
;
427f1205   Jean-Michel Glorian   version 4.2 merged
7
; PURPOSE:
04efbaa5   Ilyes Choubani   Correcting set_da...
8
;    ## adapting the data structures to the format used by the fitting algorithm 
0068116a   Ilyes Choubani   General update + ...
9
;    Initializes the dustem data structure (*!dustem_data) used in the fitting
04efbaa5   Ilyes Choubani   Correcting set_da...
10
;    Initializes the !dustem_show structure which is either a copy or a more detailed version of !dustem_data 
553fad92   Annie Hughes   updated doc help
11
;
427f1205   Jean-Michel Glorian   version 4.2 merged
12
; CATEGORY:
553fad92   Annie Hughes   updated doc help
13
14
;    DustEMWrap, Mid-Level, Distributed, Initialization
;
427f1205   Jean-Michel Glorian   version 4.2 merged
15
; CALLING SEQUENCE:
04efbaa5   Ilyes Choubani   Correcting set_da...
16
;    dustem_set_data(m_fit,x_fit,m_show,x_show,[/help])
553fad92   Annie Hughes   updated doc help
17
;
427f1205   Jean-Michel Glorian   version 4.2 merged
18
; INPUTS:
04efbaa5   Ilyes Choubani   Correcting set_da...
19
20
21
22
23
24
;    ## used in initializing !dustem_data
;    m_fit : dustemwrap structure contaning emission data to be fitted 
;    x_fit : dustemwrap structure containing extinction data to be fitted
;    ## used in initializing !dustem_show
;    m_show : dustemwrap structure containing emission data to be displayed
;    x_show : dustemwrap structure containing extinctiond data to be displayed
553fad92   Annie Hughes   updated doc help
25
;
427f1205   Jean-Michel Glorian   version 4.2 merged
26
27
; OPTIONAL INPUT PARAMETERS:
;    None
553fad92   Annie Hughes   updated doc help
28
;
427f1205   Jean-Michel Glorian   version 4.2 merged
29
30
; OUTPUTS:
;    None
553fad92   Annie Hughes   updated doc help
31
;
427f1205   Jean-Michel Glorian   version 4.2 merged
32
33
; OPTIONAL OUTPUT PARAMETERS:
;    None
553fad92   Annie Hughes   updated doc help
34
;
427f1205   Jean-Michel Glorian   version 4.2 merged
35
36
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
553fad92   Annie Hughes   updated doc help
37
;
427f1205   Jean-Michel Glorian   version 4.2 merged
38
39
; COMMON BLOCKS:
;    None
553fad92   Annie Hughes   updated doc help
40
;
427f1205   Jean-Michel Glorian   version 4.2 merged
41
; SIDE EFFECTS:
04efbaa5   Ilyes Choubani   Correcting set_da...
42
;    initializes !dustem_data/!dustem_show
427f1205   Jean-Michel Glorian   version 4.2 merged
43
44
;    wavelengths are forced to be the central filter wavelength for
;    photometric data
553fad92   Annie Hughes   updated doc help
45
;
427f1205   Jean-Michel Glorian   version 4.2 merged
46
47
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
553fad92   Annie Hughes   updated doc help
48
;
427f1205   Jean-Michel Glorian   version 4.2 merged
49
50
; PROCEDURE:
;    None
553fad92   Annie Hughes   updated doc help
51
;
427f1205   Jean-Michel Glorian   version 4.2 merged
52
53
; EXAMPLES
;    dustem_init
04efbaa5   Ilyes Choubani   Correcting set_da...
54
55
;    dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
;    file=dir+'example_SED_1.xcat'
427f1205   Jean-Michel Glorian   version 4.2 merged
56
;    spec=read_xcat(file,/silent)
04efbaa5   Ilyes Choubani   Correcting set_da...
57
58
;    var = dustem_set_data(spec,x_fit,spec,x_show)
;    #in this example !dustem_data and !dustem_show are identical
553fad92   Annie Hughes   updated doc help
59
;
427f1205   Jean-Michel Glorian   version 4.2 merged
60
; MODIFICATION HISTORY:
553fad92   Annie Hughes   updated doc help
61
;    Written by J.-Ph. Bernard 2007
427f1205   Jean-Michel Glorian   version 4.2 merged
62
63
;    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...
64
;    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
65
66
67
68
;                       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...
69

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

5a2643a4   Ilyes Choubani   cleaning/improvin...
75
;Cleaninig fitting/showing structure(s) 
0068116a   Ilyes Choubani   General update + ...
76
77
78
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
79
80
endfor

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

0068116a   Ilyes Choubani   General update + ...
83
84
85
86
87
88
;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...
89
    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 + ...
90
91
;ENDIF

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

abebbdf3   Ilyes Choubani   General update: A...
94
;FITTING STRUCTURE INITIALIZATION
0068116a   Ilyes Choubani   General update + ...
95
96
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 ...
97

3ff9cac3   Ilyes Choubani   general update
98
99
100
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
101
102
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
103
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
104
105
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
106
107
108
109
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

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

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

04efbaa5   Ilyes Choubani   Correcting set_da...
207
208
209
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
210

3ff9cac3   Ilyes Choubani   general update
211
;Setting of the structure that will be displayed
0068116a   Ilyes Choubani   General update + ...
212
;IF not keyword_set(nocheck_data) THEN BEGIN
070144e1   Jean-Philippe Bernard   improved only sli...
213
    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 + ...
214
;ENDIF
5a2643a4   Ilyes Choubani   cleaning/improvin...
215

0068116a   Ilyes Choubani   General update + ...
216
217
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
218
219
220
221
  
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
222
223
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
224
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
225
226
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
227
228
229
230
231
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

if !run_pol then begin
6a714abf   Ilyes Choubani   small fix to dust...
232
    
abebbdf3   Ilyes Choubani   General update: A...
233
    if isa(m_show) then begin ; because sometimes this keyword isn't set.
3ff9cac3   Ilyes Choubani   general update
234
235
236
        
        teststks = isa(qsed) and isa(used)
        
1355825c   Ilyes Choubani   General update
237
        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
238
        
1355825c   Ilyes Choubani   General update
239
240
241
242
243
244
        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
245
        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
246
        if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM'
3ff9cac3   Ilyes Choubani   general update
247
        
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
248

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

09e61d64   Ilyes Choubani   cleaned set_data ...
328
IF keyword_set(rchi2_weight) THEN BEGIN
d0f68bb6   Jean-Philippe Bernard   replaced system v...
329
330
	(*!fit_rchi2_weight).sed     = rchi2_weight.sed
	(*!fit_rchi2_weight).ext     = rchi2_weight.ext
09e61d64   Ilyes Choubani   cleaned set_data ...
331
	
6a714abf   Ilyes Choubani   small fix to dust...
332
	IF !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
333
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
334
335
    	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...
336
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
337
338
    	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...
339
340
    ENDIF
    
3ff9cac3   Ilyes Choubani   general update
341
342
ENDIF ELSE BEGIN

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

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

04efbaa5   Ilyes Choubani   Correcting set_da...
358
359
360
; ;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...
361
362
363
364
365
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...
366

427f1205   Jean-Michel Glorian   version 4.2 merged
367
368
the_end:

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




427f1205   Jean-Michel Glorian   version 4.2 merged
375
END