Blame view

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

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

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

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

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

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

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

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

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

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

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

04efbaa5   Ilyes Choubani   Correcting set_da...
191
192
193
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
194

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

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

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

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

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

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

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

04efbaa5   Ilyes Choubani   Correcting set_da...
342
343
344
; ;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...
345
346
347
348
349
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...
350

427f1205   Jean-Michel Glorian   version 4.2 merged
351
352
the_end:

04efbaa5   Ilyes Choubani   Correcting set_da...
353
354
; 
; return,0.
3ff9cac3   Ilyes Choubani   general update
355
356
357
358




427f1205   Jean-Michel Glorian   version 4.2 merged
359
END