Blame view

src/idl/dustem_set_data.pro 12.2 KB
89cb67ac   Annie Hughes   removed the reini...
1
2
3
4
5
6
7
PRO dustem_set_data,m_fit=m_fit $
                    ,m_show=m_show $
                    ,x_fit=x_fit $
                    ,x_show=x_show $
                    ,rchi2_weight=rchi2_weight $
                    ,f_HI=f_HI $
                    ,help=help
abebbdf3   Ilyes Choubani   General update: A...
8

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

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

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

88872c38   Ilyes Choubani   small update. Cha...
84
85
86
87
88
;Outputs have the format required by !dustem_data and the subsequent fitting process.
dustem_check_data, m_fit,x_fit,sed=sed,ext=ext,polext=polext, $
                   polsed=polsed,polfrac=polfrac,psi_em=psi_em, $
                   qsed=qsed,used=used,qext=qext,uext=uext, $
                   psi_ext=psi_ext,fpolext=fpolext
09e61d64   Ilyes Choubani   cleaned set_data ...
89

abebbdf3   Ilyes Choubani   General update: A...
90
;FITTING STRUCTURE INITIALIZATION
0068116a   Ilyes Choubani   General update + ...
91
92
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 ...
93

3ff9cac3   Ilyes Choubani   general update
94
;####################
88872c38   Ilyes Choubani   small update. Cha...
95
;RELIC. For Annie to judge if this is necessary
3ff9cac3   Ilyes Choubani   general update
96
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
97
98
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
99
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
100
101
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
102
103
104
105
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

88872c38   Ilyes Choubani   small update. Cha...
106
;Problem here is that the user can activate !run_pol without wanting to be in polarization mode. 
89cb67ac   Annie Hughes   removed the reini...
107
108
109
110
111
112
113
114
;reinitialze !run_pol here? IC - January 2023
; March 2023 -- Annie commented following lines since they prevent using a model to
; generate SEDs.
;; If !run_pol THEN BEGIN
;;    If tag_exist(*!dustem_show,'QSED') THEN BEGIN
;;         IF ~isa((*!dustem_data).qsed) THEN !run_pol=0 
;;     ENDIF ELSE !run_pol=0
;; ENDIF
88872c38   Ilyes Choubani   small update. Cha...
115

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

88872c38   Ilyes Choubani   small update. Cha...
209
210
;SHOWING STRUCTURE / IT IS NEEDED TO BE ABLE TO LOCATE THE HIDDEN DATA POINTS WHEN COMPARING WITH !dustem_data.
;when creating the HUGE system variable JP wants to create. We'll be able to omit it from DusteEMWrap for good.
3ff9cac3   Ilyes Choubani   general update
211

04efbaa5   Ilyes Choubani   Correcting set_da...
212
213
214
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

88872c38   Ilyes Choubani   small update. Cha...
215
216
217
218
dustem_check_data, m_show,x_show,sed=sed,ext=ext,polext=polext, $
                   polsed=polsed,polfrac=polfrac,psi_em=psi_em, $
                   qsed=qsed,used=used,qext=qext,uext=uext, $
                   psi_ext=psi_ext,fpolext=fpolext
5a2643a4   Ilyes Choubani   cleaning/improvin...
219

0068116a   Ilyes Choubani   General update + ...
220
221
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
222
223
  
;####################
88872c38   Ilyes Choubani   small update. Cha...
224
;RELIC
3ff9cac3   Ilyes Choubani   general update
225
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
226
227
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
228
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
229
230
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
231
232
233
234
235
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

if !run_pol then begin
6a714abf   Ilyes Choubani   small fix to dust...
236
    
abebbdf3   Ilyes Choubani   General update: A...
237
    if isa(m_show) then begin ; because sometimes this keyword isn't set.
3ff9cac3   Ilyes Choubani   general update
238
239
240
        
        teststks = isa(qsed) and isa(used)
        
1355825c   Ilyes Choubani   General update
241
        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
242
        
3ff9cac3   Ilyes Choubani   general update
243
        If isa(polsed) then BEGIN    ;Apply changes to !dustem_data here.      
0068116a   Ilyes Choubani   General update + ...
244
            (*!dustem_show).polsed = ptr_new(polsed)
3ff9cac3   Ilyes Choubani   general update
245
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
246
           	(*(*!dustem_show).polsed).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
247
248
        ENDIF
        If isa(polfrac) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
249
            (*!dustem_show).polfrac = ptr_new(polfrac)
3ff9cac3   Ilyes Choubani   general update
250
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
251
           	(*(*!dustem_show).polfrac).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
252
253
        ENDIF
        IF isa(qsed) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
254
            (*!dustem_show).qsed = ptr_new(qsed)
3ff9cac3   Ilyes Choubani   general update
255
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
256
           	(*(*!dustem_show).qsed).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
257
258
        ENDIF    
        if isa(used) then BEGIN
0068116a   Ilyes Choubani   General update + ...
259
            (*!dustem_show).used = ptr_new(used)
3ff9cac3   Ilyes Choubani   general update
260
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
261
           	(*(*!dustem_show).used).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
262
263
        ENDIF
        if isa(psi_em) then BEGIN
0068116a   Ilyes Choubani   General update + ...
264
            (*!dustem_show).psi_em = ptr_new(psi_em)
3ff9cac3   Ilyes Choubani   general update
265
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
266
            (*(*!dustem_show).psi_em).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
267
268
        ENDIF        
    endif
abebbdf3   Ilyes Choubani   General update: A...
269
    if isa(x_show) then begin
3ff9cac3   Ilyes Choubani   general update
270
271
        teststks = isa(qext) and isa(uext)
        
1355825c   Ilyes Choubani   General update
272
        IF (~teststks) then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...'
88872c38   Ilyes Choubani   small update. Cha...
273
      
3ff9cac3   Ilyes Choubani   general update
274
275
        ;EXTINCTION
        if isa(polext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
276
            (*!dustem_show).polext = ptr_new(polext)
3ff9cac3   Ilyes Choubani   general update
277
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
278
           	(*(*!dustem_show).polext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
279
280
        ENDIF
        IF isa(qext) THEN BEGIN        
0068116a   Ilyes Choubani   General update + ...
281
            (*!dustem_show).qext = ptr_new(qext)
3ff9cac3   Ilyes Choubani   general update
282
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
283
           	(*(*!dustem_show).qext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
284
285
        ENDIF
        if isa(uext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
286
            (*!dustem_show).uext = ptr_new(uext)
3ff9cac3   Ilyes Choubani   general update
287
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
288
           	(*(*!dustem_show).uext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
289
290
        ENDIF
        if isa(psi_ext) then BEGIN 
0068116a   Ilyes Choubani   General update + ...
291
            (*!dustem_show).psi_ext = ptr_new(psi_ext)
3ff9cac3   Ilyes Choubani   general update
292
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
293
           	(*(*!dustem_show).psi_ext).values *= f_HI
3ff9cac3   Ilyes Choubani   general update
294
        ENDIF
67bd858a   Ilyes Choubani   Replication of th...
295
296
297
298
        
        ;Added for completeness
        
        if isa(fpolext) then BEGIN        
0068116a   Ilyes Choubani   General update + ...
299
            (*!dustem_show).fpolext = ptr_new(fpolext)
67bd858a   Ilyes Choubani   Replication of th...
300
            if keyword_set(f_HI) then if f_HI gt 0 then $
0068116a   Ilyes Choubani   General update + ...
301
           	(*(*!dustem_show).fpolext).values *= f_HI
67bd858a   Ilyes Choubani   Replication of th...
302
303
        ENDIF
        
3ff9cac3   Ilyes Choubani   general update
304
305
    endif
endif
427f1205   Jean-Michel Glorian   version 4.2 merged
306

09e61d64   Ilyes Choubani   cleaned set_data ...
307
IF keyword_set(rchi2_weight) THEN BEGIN
d0f68bb6   Jean-Philippe Bernard   replaced system v...
308
309
	(*!fit_rchi2_weight).sed     = rchi2_weight.sed
	(*!fit_rchi2_weight).ext     = rchi2_weight.ext
09e61d64   Ilyes Choubani   cleaned set_data ...
310
	
6a714abf   Ilyes Choubani   small fix to dust...
311
	IF !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
312
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
313
314
    	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...
315
    	
d0f68bb6   Jean-Philippe Bernard   replaced system v...
316
317
    	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...
318
319
    ENDIF
    
3ff9cac3   Ilyes Choubani   general update
320
321
ENDIF ELSE BEGIN

d0f68bb6   Jean-Philippe Bernard   replaced system v...
322
323
    (*!fit_rchi2_weight).sed=1.
    (*!fit_rchi2_weight).ext=1.
3ff9cac3   Ilyes Choubani   general update
324
325
    
    If !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
326
        
d0f68bb6   Jean-Philippe Bernard   replaced system v...
327
328
        IF isa(qsed) THEN (*!fit_rchi2_weight).qsed=1.
        IF isa(used) THEN (*!fit_rchi2_weight).used=1.
1355825c   Ilyes Choubani   General update
329
        
d0f68bb6   Jean-Philippe Bernard   replaced system v...
330
331
        IF isa(qext) THEN (*!fit_rchi2_weight).qext=1.
        IF isa(uext) THEN (*!fit_rchi2_weight).uext=1.
1355825c   Ilyes Choubani   General update
332
    
3ff9cac3   Ilyes Choubani   general update
333
    ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
334

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

04efbaa5   Ilyes Choubani   Correcting set_da...
337
338
339
; ;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...
340
341
342
343
344
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...
345

427f1205   Jean-Michel Glorian   version 4.2 merged
346
347
the_end:

427f1205   Jean-Michel Glorian   version 4.2 merged
348
END