Blame view

src/idl/dustem_set_data.pro 5.85 KB
09e61d64   Ilyes Choubani   cleaned set_data ...
1
FUNCTION dustem_set_data,help=help,sed=sed,ext=ext,polfrac=polfrac,rchi2_weight=rchi2_weight,f_HI=f_HI
427f1205   Jean-Michel Glorian   version 4.2 merged
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

;+
; NAME:
;    dustem_set_data
; PURPOSE:
;    Initializes the dustem data structure (!dustem_data)
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    dustem_set_data,spec[,help=]
; INPUTS:
;    spec: array of structures containing a SED
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    initializes !dustem_data
;    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
;    dir=getenv('DUSTEM_SOFT_DIR')+'/src/dustem3.8_web/SEDs/'
;    file=dir+'Gal_composite_spectrum.xcat'
;    spec=read_xcat(file,/silent)
;    dustem_set_data,spec
; 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
09e61d64   Ilyes Choubani   cleaned set_data ...
45
46
;    I. Choubani (2022): Adjusting the function to meet the format criteria set by the current release. 
;    The function uses two main input structures: SED and EXT. Polarization data is included within each. 
427f1205   Jean-Michel Glorian   version 4.2 merged
47
48
;-

09e61d64   Ilyes Choubani   cleaned set_data ...
49
;fully deprecate the use of polfrac?===>YES should do so
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
50

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

09e61d64   Ilyes Choubani   cleaned set_data ...
56
;Cleaninig data structure
427f1205   Jean-Michel Glorian   version 4.2 merged
57
58
!dustem_data.sed = ptr_new()
!dustem_data.ext = ptr_new()
36e8b879   Jean-Michel Glorian   update from deborah
59

09e61d64   Ilyes Choubani   cleaned set_data ...
60
;Cleaninig counters
9331f1cd   Jean-Philippe Bernard   introduced use of...
61
62
63
NP=0
NQ=0
NU=0
09e61d64   Ilyes Choubani   cleaned set_data ...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
NP_ext=0
NQ_ext=0
NU_ext=0

;SETTING THE DATA STRUCTURES FOR THE FITTING PROCESS - SED

IF keyword_set(sed) THEN BEGIN    
    IF !run_pol THEN BEGIN    
        ind=where(sed.largeP NE la_undef(),NP)
        if NP NE 0 then !dustem_data.polsed = ptr_new()
        ind=where(sed.StokesQ NE la_undef(),NQ)
        if NQ NE 0 then !dustem_data.qsed = ptr_new()
        ind=where(sed.StokesU NE la_undef(),NU)
        if NU NE 0 then !dustem_data.used = ptr_new()    
    ENDIF           
    xx=dustem_check_data(sed=sed,ist=ist,pst=pst,qst=qst,ust=ust)            
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
80
    ;=== fill !dustem_data
09e61d64   Ilyes Choubani   cleaned set_data ...
81
    !dustem_data.sed = ptr_new(ist)    
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
82
    ; If f_HI is specified, multiply the data by f_HI
09e61d64   Ilyes Choubani   cleaned set_data ...
83
    If keyword_set(f_HI) then begin
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
84
85
86
        if f_HI gt 0 then (*!dustem_data.sed).values *= f_HI else f_HI = 1.
    endif else f_HI = 1.
    defsysv,'!dustem_f_HI',f_HI
09e61d64   Ilyes Choubani   cleaned set_data ...
87
    If NP NE 0 then BEGIN        
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
88
        ;=== fill !dustem_data
09e61d64   Ilyes Choubani   cleaned set_data ...
89
        !dustem_data.polsed = ptr_new(pst)
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
90
91
92
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
      	(*!dustem_data.polsed).values *= f_HI
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
93
    ENDIF
09e61d64   Ilyes Choubani   cleaned set_data ...
94
    IF NQ NE 0 THEN BEGIN        
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
95
        ;=== fill !dustem_data
09e61d64   Ilyes Choubani   cleaned set_data ...
96
        !dustem_data.qsed = ptr_new(qst)
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
97
98
99
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
      	(*!dustem_data.qsed).values *= f_HI
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
100
    ENDIF    
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
101
    if NU NE 0 then BEGIN
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
102
        ;=== fill !dustem_data
09e61d64   Ilyes Choubani   cleaned set_data ...
103
        !dustem_data.used = ptr_new(ust)
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
104
105
106
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
      	(*!dustem_data.used).values *= f_HI
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
107
    ENDIF
452c334e   Ilyes Choubani   Implementation Of...
108
109
ENDIF

09e61d64   Ilyes Choubani   cleaned set_data ...
110
;SETTING THE DATA STRUCTURES FOR THE FITTING PROCESS - EXT
427f1205   Jean-Michel Glorian   version 4.2 merged
111
112

IF keyword_set(ext) THEN BEGIN
09e61d64   Ilyes Choubani   cleaned set_data ...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    IF !run_pol THEN BEGIN
        ind=where(ext.EXT_P NE la_undef(),NP_ext)
        if NP_ext NE 0 then !dustem_data.polext = ptr_new() 
        ind=where(ext.EXT_Q NE la_undef(),NQ_ext)
        if NQ_ext NE 0 then !dustem_data.qext = ptr_new()
        ind=where(ext.EXT_U NE la_undef(),NU_ext)
        if NU_ext NE 0 then !dustem_data.uext = ptr_new()    
    ENDIF
    xx=dustem_check_data(ext=ext,exst=exst,pexst=pexst,qexst=qexst,uexst=uexst)
    ;=== fill !dustem_data
    !dustem_data.ext = ptr_new(exst)        
    ; If f_HI is specified, multiply the data by f_HI
    if keyword_set(f_HI) then begin
        if f_HI gt 0 then (*!dustem_data.ext).values *= f_HI else f_HI = 1.
    endif else f_HI = 1.
    defsysv,'!dustem_f_HI',f_HI
    if NP_ext NE 0 then BEGIN        
        !dustem_data.polext = ptr_new(pexst)
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
       	(*!dustem_data.polext).values *= f_HI
    ENDIF
    IF NQ_ext NE 0 THEN BEGIN        
        ;=== fill !dustem_data
        !dustem_data.qext = ptr_new(qexst)
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
       	(*!dustem_data.qext).values *= f_HI
    ENDIF
    if NU_ext NE 0 then BEGIN 
        ;=== fill !dustem_data
        !dustem_data.uext = ptr_new(uexst)
        ; If f_HI is specified, multiply the data by f_HI
        if keyword_set(f_HI) then if f_HI gt 0 then $
       	(*!dustem_data.uext).values *= f_HI
    ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
149
150
ENDIF

427f1205   Jean-Michel Glorian   version 4.2 merged
151
152
!fit_rchi2_weight.sed=1.
!fit_rchi2_weight.ext=1.
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
153

09e61d64   Ilyes Choubani   cleaned set_data ...
154
;SED
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
155
156
157
158
IF NP NE 0 THEN !fit_rchi2_weight.polsed=1.
IF NQ NE 0 THEN !fit_rchi2_weight.qsed=1.
IF NU NE 0 THEN !fit_rchi2_weight.used=1.

09e61d64   Ilyes Choubani   cleaned set_data ...
159
160
161
162
;EXT
IF NP_ext NE 0 THEN !fit_rchi2_weight.polext=1.
IF NQ_ext NE 0 THEN !fit_rchi2_weight.qext=1.
IF NU_ext NE 0 THEN !fit_rchi2_weight.uext=1.
427f1205   Jean-Michel Glorian   version 4.2 merged
163

09e61d64   Ilyes Choubani   cleaned set_data ...
164
IF keyword_set(rchi2_weight) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
165
166
	!fit_rchi2_weight.sed     = rchi2_weight.sed
	!fit_rchi2_weight.ext     = rchi2_weight.ext
09e61d64   Ilyes Choubani   cleaned set_data ...
167
	
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
168
169
170
171
	IF NP NE 0 THEN !fit_rchi2_weight.polsed  = rchi2_weight.polsed
	IF NQ NE 0 THEN !fit_rchi2_weight.qsed  = rchi2_weight.qsed
	IF NU NE 0 THEN !fit_rchi2_weight.used  = rchi2_weight.used
	
09e61d64   Ilyes Choubani   cleaned set_data ...
172
173
174
175
176
	IF NP_ext NE 0 THEN !fit_rchi2_weight.polext  = rchi2_weight.polext
	IF NQ_ext NE 0 THEN !fit_rchi2_weight.qext  = rchi2_weight.qext
	IF NU_ext NE 0 THEN !fit_rchi2_weight.uext  = rchi2_weight.uext

ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
177
178
179
180
181
182
183

return,ptr_new(obs_st)


the_end:

END