dustem_make_fits_predicted_ext.pro
4.44 KB
1
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
FUNCTION dustem_make_fits_predicted_ext ,syst_var $
,dustem_predicted_ext $
,str_input_ext=str_input_ext $
,dustem_predicted_Qext=dustem_predicted_Qext $
,dustem_predicted_Uext=dustem_predicted_Uext $
,help=help
;+
; NAME:
; dustem_make_fits_predicted_ext
; PURPOSE:
; extracts dustemwrap predicted extinction SED from dustem system variable syst_var, to be put into fits files
; CATEGORY:
; DustEMWrap, Distributed, High-Level, User Convenience
; CALLING SEQUENCE:
; str_predicted_EXT=dustem_make_fits_predicted_ext(syst_var,dustem_predicted_ext[,str_input_ext=])
; see dustem_write_fits_table.pro
; INPUTS:
; syst_var : dustem system variable (*!dustem_data or *!dustem_show)
; dustem_predicted_ext : dustemwrap predicted extinction SED as output by dustem_compute_ext.pro
; OPTIONAL INPUT PARAMETERS:
; dustem_predicted_Qext : Stokes Q extinction SED
; dustem_predicted_Uext : Stokes U extinction SED
; OUTPUTS:
; str_predicted_EXT : dustemwrap predicted extinction SED as used to store into fits file
; OPTIONAL OUTPUT PARAMETERS:
; str_input_ext : dustem wrap input extinction SED
; ACCEPTED KEY-WORDS:
; help = If set, print this help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; None
; RESTRICTIONS:
; The DustEMWrap IDL code must be installed
; PROCEDURE:
; None
; EXAMPLES:
; str_predicted_EXT=dustem_make_fits_predicted_ext(*!dustem_data,dustem_predicted_ext,str_input_ext=str_input_ext)
; MODIFICATION HISTORY:
; Written by J.-Ph. Bernard Dec 2022
; Evolution details on the DustEMWrap gitlab.
; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
;-
IF keyword_set(help) THEN BEGIN
doc_library,'dustem_make_fits_predicted_ext'
str_predicted_SED=-1
goto,the_end
ENDIF
;===== define structures containing results
one_str_input_EXT={FILTER:'',Wavelength:la_undef(4),StokesI_EXT:la_undef(5),StokesQ_EXT:la_undef(5),StokesU_EXT:la_undef(5),varianceII_EXT:la_undef(5),varianceQQ_EXT:la_undef(5),varianceUU_EXT:la_undef(5)}
one_str_predicted_EXT={FILTER:'',Wavelength:la_undef(4),StokesI_EXT:la_undef(5),StokesQ_EXT:la_undef(5),StokesU_EXT:la_undef(5)}
Next=n_elements((*syst_var.ext).filt_names)
str_input_EXT=replicate(one_str_input_EXT,Next)
str_input_EXT.FILTER=(*syst_var.ext).filt_names
str_input_EXT.Wavelength=(*syst_var.ext).wav
str_input_EXT.StokesI_EXT=(*syst_var.ext).values
str_input_EXT.varianceII_EXT=la_power((*syst_var.ext).sigma,2.)
stop
;IC; if I didn't misunderstand the str_input_EXT output lacks this information
IF !run_pol THEN BEGIN
qext=aos2soa(*syst_var.qext)
FOR i=0L,n_elements(qext.wav)-1 DO BEGIN
ind=where(str_input_EXT.FILTER EQ qext[i].filt_names and str_input_EXT.wavelength EQ qext[i].wav,count)
IF count NE 0 THEN BEGIN
str_input_EXT[ind[0]].STOKESQ_EXT=qext[i].values
str_input_EXT[ind[0]].varianceQQ_EXT=la_power(qext[i].sigma,2.)
ENDIF
ENDFOR
uext=aos2soa(*syst_var.uext)
FOR i=0L,n_elements(uext.wav)-1 DO BEGIN
ind=where(str_input_EXT.FILTER EQ uext[i].filt_names and str_input_EXT.wavelength EQ uext[i].wav,count)
IF count NE 0 THEN BEGIN
str_input_EXT[ind[0]].STOKESU_EXT=uext[i].values
str_input_EXT[ind[0]].varianceUU_EXT=la_power(uext[i].sigma,2.)
ENDIF
ENDFOR
ENDIF
;IC: If we make an analogy with emission, why aren't there any predicted variances?
;N_predicted_ext=n_elements(dustem_predicted_polext[0])
N_predicted_ext=n_elements(dustem_predicted_ext)
str_predicted_EXT=replicate(one_str_predicted_EXT,N_predicted_EXT)
fully_undefined_ext=str_predicted_ext
IF N_predicted_ext NE Next THEN BEGIN ;This is for cases when the extinction data to fit did not have the dimension of computed extinction curve
message,'I have a problem with dimensions ...',/continue
stop
ENDIF ELSE BEGIN
str_predicted_EXT.FILTER=(*syst_var.ext).filt_names ;taken from input SED
str_predicted_EXT.Wavelength=(*syst_var.ext).wav ;taken from input SED
str_predicted_EXT.StokesI_EXT=dustem_predicted_ext
ENDELSE
IF !run_pol THEN BEGIN
str_predicted_EXT.StokesQ_EXT=interpol(dustem_predicted_Qext,(*syst_var.qext).wav,(*syst_var.ext).wav)
str_predicted_EXT.StokesU_EXT=interpol(dustem_predicted_Uext,(*syst_var.uext).wav,(*syst_var.ext).wav)
ENDIF ELSE BEGIN
str_predicted_EXT.StokesQ_EXT=fully_undefined_ext.StokesQ_EXT
str_predicted_EXT.StokesU_EXT=fully_undefined_ext.StokesU_EXT
ENDELSE
RETURN,str_predicted_EXT
the_end:
END