Blame view

src/idl/dustem_set_data.pro 14.1 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
6
;+
; NAME:
;    dustem_set_data
; PURPOSE:
04efbaa5   Ilyes Choubani   Correcting set_da...
7
;    ## adapting the data structures to the format used by the fitting algorithm 
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 
427f1205   Jean-Michel Glorian   version 4.2 merged
10
11
12
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
04efbaa5   Ilyes Choubani   Correcting set_da...
13
;    dustem_set_data(m_fit,x_fit,m_show,x_show,[/help])
427f1205   Jean-Michel Glorian   version 4.2 merged
14
; INPUTS:
04efbaa5   Ilyes Choubani   Correcting set_da...
15
16
17
18
19
20
;    ## 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
427f1205   Jean-Michel Glorian   version 4.2 merged
21
22
23
24
25
26
27
28
29
30
31
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
04efbaa5   Ilyes Choubani   Correcting set_da...
32
;    initializes !dustem_data/!dustem_show
427f1205   Jean-Michel Glorian   version 4.2 merged
33
34
35
36
37
38
39
40
;    wavelengths are forced to be the central filter wavelength for
;    photometric data
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    dustem_init
04efbaa5   Ilyes Choubani   Correcting set_da...
41
42
;    dir=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/'
;    file=dir+'example_SED_1.xcat'
427f1205   Jean-Michel Glorian   version 4.2 merged
43
;    spec=read_xcat(file,/silent)
04efbaa5   Ilyes Choubani   Correcting set_da...
44
45
;    var = dustem_set_data(spec,x_fit,spec,x_show)
;    #in this example !dustem_data and !dustem_show are identical
427f1205   Jean-Michel Glorian   version 4.2 merged
46
47
48
49
50
51
52
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
; 
;    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...
53
54
;    I. Choubani (2022): dustem_check_data is introduced and the data structure format of the latest release is respected.
;-                       dustem_set_data is turned into a procedure.
427f1205   Jean-Michel Glorian   version 4.2 merged
55

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
56

427f1205   Jean-Michel Glorian   version 4.2 merged
57
58
59
60
61
IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_set_data'
  goto,the_end
ENDIF

5a2643a4   Ilyes Choubani   cleaning/improvin...
62
;Cleaninig fitting/showing structure(s) 
0068116a   Ilyes Choubani   General update + ...
63
64
65
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
66
67
endfor

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

0068116a   Ilyes Choubani   General update + ...
70
71
72
73
74
75
;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...
76
    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 + ...
77
78
;ENDIF

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

abebbdf3   Ilyes Choubani   General update: A...
81
;FITTING STRUCTURE INITIALIZATION
0068116a   Ilyes Choubani   General update + ...
82
83
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 ...
84

3ff9cac3   Ilyes Choubani   general update
85
86
87
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
88
89
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
90
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
91
92
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
93
94
95
96
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

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

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

04efbaa5   Ilyes Choubani   Correcting set_da...
194
195
196
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
197

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

0068116a   Ilyes Choubani   General update + ...
203
204
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
205
206
207
208
  
;####################
;OLD VARIABLE. KEPT IT.
; If f_HI is specified, multiply the data by f_HI
0068116a   Ilyes Choubani   General update + ...
209
210
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
211
endif else f_HI = 1.
0068116a   Ilyes Choubani   General update + ...
212
213
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
214
215
216
217
218
endif else f_HI = 1.
defsysv,'!dustem_f_HI',f_HI
;####################

if !run_pol then begin
6a714abf   Ilyes Choubani   small fix to dust...
219
    
abebbdf3   Ilyes Choubani   General update: A...
220
    if isa(m_show) then begin ; because sometimes this keyword isn't set.
3ff9cac3   Ilyes Choubani   general update
221
222
223
        
        teststks = isa(qsed) and isa(used)
        
1355825c   Ilyes Choubani   General update
224
        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
225
        
1355825c   Ilyes Choubani   General update
226
227
228
229
230
231
        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
232
        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
233
        if teststks and ~(isa(polsed)) and ~(isa(polfrac)) and isa(psi_em) then nowshowing = 'QSED, USED and PSI_EM'
3ff9cac3   Ilyes Choubani   general update
234
        
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
235

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

09e61d64   Ilyes Choubani   cleaned set_data ...
315
IF keyword_set(rchi2_weight) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
316
317
	!fit_rchi2_weight.sed     = rchi2_weight.sed
	!fit_rchi2_weight.ext     = rchi2_weight.ext
09e61d64   Ilyes Choubani   cleaned set_data ...
318
	
6a714abf   Ilyes Choubani   small fix to dust...
319
	IF !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
320
    	
3ff9cac3   Ilyes Choubani   general update
321
322
    	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...
323
    	
3ff9cac3   Ilyes Choubani   general update
324
325
    	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...
326
327
    ENDIF
    
3ff9cac3   Ilyes Choubani   general update
328
329
330
331
332
333
ENDIF ELSE BEGIN

    !fit_rchi2_weight.sed=1.
    !fit_rchi2_weight.ext=1.
    
    If !run_pol THEN BEGIN
1355825c   Ilyes Choubani   General update
334
        
3ff9cac3   Ilyes Choubani   general update
335
336
        IF isa(qsed) THEN !fit_rchi2_weight.qsed=1.
        IF isa(used) THEN !fit_rchi2_weight.used=1.
1355825c   Ilyes Choubani   General update
337
        
3ff9cac3   Ilyes Choubani   general update
338
339
        IF isa(qext) THEN !fit_rchi2_weight.qext=1.
        IF isa(uext) THEN !fit_rchi2_weight.uext=1.
1355825c   Ilyes Choubani   General update
340
    
3ff9cac3   Ilyes Choubani   general update
341
    ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
342

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

04efbaa5   Ilyes Choubani   Correcting set_da...
345
346
347
; ;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...
348
349
350
351
352
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...
353

427f1205   Jean-Michel Glorian   version 4.2 merged
354
355
the_end:

04efbaa5   Ilyes Choubani   Correcting set_da...
356
357
; 
; return,0.
3ff9cac3   Ilyes Choubani   general update
358
359
360
361




427f1205   Jean-Michel Glorian   version 4.2 merged
362
END