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.
427f1205   Jean-Michel Glorian   version 4.2 merged
16
; CATEGORY:
553fad92   Annie Hughes   updated doc help
17
;    DustEMWrap, Mid-Level, Distributed, Initialization
edeb9236   Annie Hughes   updated doc help
18
;
427f1205   Jean-Michel Glorian   version 4.2 merged
19
; CALLING SEQUENCE:
88872c38   Ilyes Choubani   small update. Cha...
20
;    dustem_set_data,[,m_fit=,x_fit=][,m_show=,x_show=],[,rchi2_weight=][,f_HI=][,/help]
edeb9236   Annie Hughes   updated doc help
21
;
427f1205   Jean-Michel Glorian   version 4.2 merged
22
; INPUTS:
ebbb68b1   Jean-Philippe Bernard   improved the help
23
;    None
edeb9236   Annie Hughes   updated doc help
24
;
ebbb68b1   Jean-Philippe Bernard   improved the help
25
; OPTIONAL INPUT PARAMETERS:
88872c38   Ilyes Choubani   small update. Cha...
26
27
28
29
30
;    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
31
;    f_HI : multiplicative factor for the SED values (extinction and emission)
edeb9236   Annie Hughes   updated doc help
32
;
427f1205   Jean-Michel Glorian   version 4.2 merged
33
; OUTPUTS:
88872c38   Ilyes Choubani   small update. Cha...
34
;    None/ALL OF THE ABOVE? 
edeb9236   Annie Hughes   updated doc help
35
;
427f1205   Jean-Michel Glorian   version 4.2 merged
36
37
; OPTIONAL OUTPUT PARAMETERS:
;    None
edeb9236   Annie Hughes   updated doc help
38
;
427f1205   Jean-Michel Glorian   version 4.2 merged
39
40
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
edeb9236   Annie Hughes   updated doc help
41
;
427f1205   Jean-Michel Glorian   version 4.2 merged
42
43
; COMMON BLOCKS:
;    None
edeb9236   Annie Hughes   updated doc help
44
;
427f1205   Jean-Michel Glorian   version 4.2 merged
45
; SIDE EFFECTS:
ebbb68b1   Jean-Philippe Bernard   improved the help
46
47
;    initializes !dustem_data and !dustem_show
;    wavelengths are forced to be the central filter wavelength for photometric data
edeb9236   Annie Hughes   updated doc help
48
;
427f1205   Jean-Michel Glorian   version 4.2 merged
49
; RESTRICTIONS:
edeb9236   Annie Hughes   updated doc help
50
51
;    The DustEMWrap IDL code must be installed
; 
427f1205   Jean-Michel Glorian   version 4.2 merged
52
53
; PROCEDURE:
;    None
edeb9236   Annie Hughes   updated doc help
54
;
427f1205   Jean-Michel Glorian   version 4.2 merged
55
56
; EXAMPLES
;    dustem_init
04efbaa5   Ilyes Choubani   Correcting set_da...
57
58
;    dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
;    file=dir+'example_SED_1.xcat'
427f1205   Jean-Michel Glorian   version 4.2 merged
59
;    spec=read_xcat(file,/silent)
88872c38   Ilyes Choubani   small update. Cha...
60
61
;    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
62
;
427f1205   Jean-Michel Glorian   version 4.2 merged
63
; MODIFICATION HISTORY:
553fad92   Annie Hughes   updated doc help
64
;    Written by J.-Ph. Bernard 2007
427f1205   Jean-Michel Glorian   version 4.2 merged
65
66
;    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...
67
;    I. Choubani (2022): dustem_set_data is turned into a procedure for emission/extinction with/without polarization.
553fad92   Annie Hughes   updated doc help
68
69
70
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
71

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

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

88872c38   Ilyes Choubani   small update. Cha...
83
84
85
86
87
;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 ...
88

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

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

88872c38   Ilyes Choubani   small update. Cha...
105
;Problem here is that the user can activate !run_pol without wanting to be in polarization mode. 
89cb67ac   Annie Hughes   removed the reini...
106
107
108
109
110
111
112
113
;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...
114

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

88872c38   Ilyes Choubani   small update. Cha...
208
209
;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
210

04efbaa5   Ilyes Choubani   Correcting set_da...
211
212
213
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...
214
215
216
217
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...
218

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

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

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

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

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

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

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

427f1205   Jean-Michel Glorian   version 4.2 merged
347
END