Blame view

src/idl/dustem_make_fits_predicted_ext.pro 4.62 KB
b7dca888   Jean-Philippe Bernard   improved to recov...
1
FUNCTION dustem_make_fits_predicted_ext ,syst_var $
440f1ae1   Annie Hughes   unknown
2
3
4
5
6
                                         ,dustem_predicted_ext $
                                         ,str_input_ext=str_input_ext $
                                         ,dustem_predicted_Qext=dustem_predicted_Qext $
                                         ,dustem_predicted_Uext=dustem_predicted_Uext $
                                         ,help=help
244eeac8   Jean-Philippe Bernard   First commit
7
8
9
10

;+
; NAME:
;    dustem_make_fits_predicted_ext
440f1ae1   Annie Hughes   unknown
11
;  
244eeac8   Jean-Philippe Bernard   First commit
12
13
; PURPOSE:
;    extracts dustemwrap predicted extinction SED from dustem system variable syst_var, to be put into fits files
440f1ae1   Annie Hughes   unknown
14
;
244eeac8   Jean-Philippe Bernard   First commit
15
16
; CATEGORY:
;    DustEMWrap, Distributed, High-Level, User Convenience
440f1ae1   Annie Hughes   unknown
17
;
244eeac8   Jean-Philippe Bernard   First commit
18
19
20
; CALLING SEQUENCE:
;    str_predicted_EXT=dustem_make_fits_predicted_ext(syst_var,dustem_predicted_ext[,str_input_ext=])
;    see dustem_write_fits_table.pro
440f1ae1   Annie Hughes   unknown
21
;
244eeac8   Jean-Philippe Bernard   First commit
22
23
24
; 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
440f1ae1   Annie Hughes   unknown
25
;
244eeac8   Jean-Philippe Bernard   First commit
26
; OPTIONAL INPUT PARAMETERS:
b7dca888   Jean-Philippe Bernard   improved to recov...
27
28
;    dustem_predicted_Qext : Stokes Q extinction SED
;    dustem_predicted_Uext : Stokes U extinction SED
440f1ae1   Annie Hughes   unknown
29
;
244eeac8   Jean-Philippe Bernard   First commit
30
31
; OUTPUTS:
;    str_predicted_EXT : dustemwrap predicted extinction SED as used to store into fits file
440f1ae1   Annie Hughes   unknown
32
;
244eeac8   Jean-Philippe Bernard   First commit
33
34
; OPTIONAL OUTPUT PARAMETERS:
;    str_input_ext : dustem wrap input extinction SED
440f1ae1   Annie Hughes   unknown
35
;
244eeac8   Jean-Philippe Bernard   First commit
36
37
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
440f1ae1   Annie Hughes   unknown
38
;
244eeac8   Jean-Philippe Bernard   First commit
39
40
; COMMON BLOCKS:
;    None
440f1ae1   Annie Hughes   unknown
41
;
244eeac8   Jean-Philippe Bernard   First commit
42
43
; SIDE EFFECTS:
;    None
440f1ae1   Annie Hughes   unknown
44
;
244eeac8   Jean-Philippe Bernard   First commit
45
46
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
440f1ae1   Annie Hughes   unknown
47
;
244eeac8   Jean-Philippe Bernard   First commit
48
49
; PROCEDURE:
;    None
440f1ae1   Annie Hughes   unknown
50
;
244eeac8   Jean-Philippe Bernard   First commit
51
52
; EXAMPLES:
;    str_predicted_EXT=dustem_make_fits_predicted_ext(*!dustem_data,dustem_predicted_ext,str_input_ext=str_input_ext)
440f1ae1   Annie Hughes   unknown
53
;
244eeac8   Jean-Philippe Bernard   First commit
54
55
56
57
58
59
60
61
62
63
64
65
66
67
; 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
3196a378   Ilyes Choubani   Complementing fit...
68
69
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)}
244eeac8   Jean-Philippe Bernard   First commit
70
71
72
73
74

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
3196a378   Ilyes Choubani   Complementing fit...
75
76
str_input_EXT.StokesI_EXT=(*syst_var.ext).values
str_input_EXT.varianceII_EXT=la_power((*syst_var.ext).sigma,2.)
440f1ae1   Annie Hughes   unknown
77
78

;stop
3196a378   Ilyes Choubani   Complementing fit...
79
;IC; if I didn't misunderstand the str_input_EXT output lacks this information
440f1ae1   Annie Hughes   unknown
80

3196a378   Ilyes Choubani   Complementing fit...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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?
244eeac8   Jean-Philippe Bernard   First commit
100
101
102
103
104
105
106
107
108
109
;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
3196a378   Ilyes Choubani   Complementing fit...
110
	str_predicted_EXT.StokesI_EXT=dustem_predicted_ext
244eeac8   Jean-Philippe Bernard   First commit
111
ENDELSE
3196a378   Ilyes Choubani   Complementing fit...
112

244eeac8   Jean-Philippe Bernard   First commit
113
IF !run_pol THEN BEGIN
3196a378   Ilyes Choubani   Complementing fit...
114
115
	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)
244eeac8   Jean-Philippe Bernard   First commit
116
ENDIF ELSE BEGIN
3196a378   Ilyes Choubani   Complementing fit...
117
118
	str_predicted_EXT.StokesQ_EXT=fully_undefined_ext.StokesQ_EXT
	str_predicted_EXT.StokesU_EXT=fully_undefined_ext.StokesU_EXT
244eeac8   Jean-Philippe Bernard   First commit
119
120
121
122
ENDELSE

RETURN,str_predicted_EXT

ec7558b1   Ilyes Choubani   small correction ...
123
124
the_end: 

440f1ae1   Annie Hughes   unknown
125
END