Blame view

src/idl/dustem_make_fits_predicted_ext.pro 4.44 KB
b7dca888   Jean-Philippe Bernard   improved to recov...
1
2
3
FUNCTION dustem_make_fits_predicted_ext ,syst_var $
										,dustem_predicted_ext $
										,str_input_ext=str_input_ext $
ec7558b1   Ilyes Choubani   small correction ...
4
5
										,dustem_predicted_Qext=dustem_predicted_Qext $
    									,dustem_predicted_Uext=dustem_predicted_Uext $
b7dca888   Jean-Philippe Bernard   improved to recov...
6
										,help=help
244eeac8   Jean-Philippe Bernard   First commit
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

;+
; 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:
b7dca888   Jean-Philippe Bernard   improved to recov...
22
23
;    dustem_predicted_Qext : Stokes Q extinction SED
;    dustem_predicted_Uext : Stokes U extinction SED
244eeac8   Jean-Philippe Bernard   First commit
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
; 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
3196a378   Ilyes Choubani   Complementing fit...
54
55
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
56
57
58
59
60

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...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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?
244eeac8   Jean-Philippe Bernard   First commit
84
85
86
87
88
89
90
91
92
93
;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...
94
	str_predicted_EXT.StokesI_EXT=dustem_predicted_ext
244eeac8   Jean-Philippe Bernard   First commit
95
ENDELSE
3196a378   Ilyes Choubani   Complementing fit...
96

244eeac8   Jean-Philippe Bernard   First commit
97
IF !run_pol THEN BEGIN
3196a378   Ilyes Choubani   Complementing fit...
98
99
	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
100
ENDIF ELSE BEGIN
3196a378   Ilyes Choubani   Complementing fit...
101
102
	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
103
104
105
106
ENDELSE

RETURN,str_predicted_EXT

ec7558b1   Ilyes Choubani   small correction ...
107
108
the_end: 

244eeac8   Jean-Philippe Bernard   First commit
109
END