Commit 244eeac80e4d926d898793d9ca4f97b0c0d0af69
1 parent
344fa44b
Exists in
master
First commit
Showing
3 changed files
with
231 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,26 @@ |
1 | +PRO dustem_fillup_systvar_from_fits,syst_var,sed,str_input_SED,used_pol | |
2 | + | |
3 | + (syst_var).sed=ptr_new(sed) | |
4 | + | |
5 | + (*syst_var.sed).instru_names=dustem_filter2instru(str_input_SED.filter) | |
6 | + (*syst_var.sed).filt_names=str_input_SED.filter | |
7 | + (*syst_var.sed).wav=str_input_SED.wavelength | |
8 | + (*syst_var.sed).values=str_input_SED.STOKESI | |
9 | + (*syst_var.sed).sigma=la_power(str_input_SED.varianceII,0.5) | |
10 | + | |
11 | + IF used_pol THEN BEGIN | |
12 | + ;stop | |
13 | + syst_var.qsed=ptr_new(sed) | |
14 | + syst_var.used=ptr_new(sed) | |
15 | + (*syst_var.qsed).instru_names=dustem_filter2instru(str_input_SED.filter) | |
16 | + (*syst_var.qsed).filt_names=str_input_SED.filter | |
17 | + (*syst_var.qsed).wav=str_input_SED.wavelength | |
18 | + (*syst_var.qsed).values=str_input_SED.STOKESQ | |
19 | + (*syst_var.qsed).sigma=la_power(str_input_SED.varianceQQ,0.5) | |
20 | + (*syst_var.used).instru_names=dustem_filter2instru(str_input_SED.filter) | |
21 | + (*syst_var.used).filt_names=str_input_SED.filter | |
22 | + (*syst_var.used).wav=str_input_SED.wavelength | |
23 | + (*syst_var.used).values=str_input_SED.STOKESU | |
24 | + (*syst_var.used).sigma=la_power(str_input_SED.varianceUU,0.5) | |
25 | + ENDIF | |
26 | +END | |
0 | 27 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,81 @@ |
1 | +FUNCTION dustem_make_fits_predicted_ext,syst_var,dustem_predicted_ext,str_input_ext=str_input_ext,help=help | |
2 | + | |
3 | +;+ | |
4 | +; NAME: | |
5 | +; dustem_make_fits_predicted_ext | |
6 | +; PURPOSE: | |
7 | +; extracts dustemwrap predicted extinction SED from dustem system variable syst_var, to be put into fits files | |
8 | +; CATEGORY: | |
9 | +; DustEMWrap, Distributed, High-Level, User Convenience | |
10 | +; CALLING SEQUENCE: | |
11 | +; str_predicted_EXT=dustem_make_fits_predicted_ext(syst_var,dustem_predicted_ext[,str_input_ext=]) | |
12 | +; see dustem_write_fits_table.pro | |
13 | +; INPUTS: | |
14 | +; syst_var : dustem system variable (*!dustem_data or *!dustem_show) | |
15 | +; dustem_predicted_ext : dustemwrap predicted extinction SED as output by dustem_compute_ext.pro | |
16 | +; OPTIONAL INPUT PARAMETERS: | |
17 | +; None | |
18 | +; OUTPUTS: | |
19 | +; str_predicted_EXT : dustemwrap predicted extinction SED as used to store into fits file | |
20 | +; OPTIONAL OUTPUT PARAMETERS: | |
21 | +; str_input_ext : dustem wrap input extinction SED | |
22 | +; ACCEPTED KEY-WORDS: | |
23 | +; help = If set, print this help | |
24 | +; COMMON BLOCKS: | |
25 | +; None | |
26 | +; SIDE EFFECTS: | |
27 | +; None | |
28 | +; RESTRICTIONS: | |
29 | +; The DustEMWrap IDL code must be installed | |
30 | +; PROCEDURE: | |
31 | +; None | |
32 | +; EXAMPLES: | |
33 | +; str_predicted_EXT=dustem_make_fits_predicted_ext(*!dustem_data,dustem_predicted_ext,str_input_ext=str_input_ext) | |
34 | +; MODIFICATION HISTORY: | |
35 | +; Written by J.-Ph. Bernard Dec 2022 | |
36 | +; Evolution details on the DustEMWrap gitlab. | |
37 | +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. | |
38 | +;- | |
39 | + | |
40 | +IF keyword_set(help) THEN BEGIN | |
41 | + doc_library,'dustem_make_fits_predicted_ext' | |
42 | + str_predicted_SED=-1 | |
43 | + goto,the_end | |
44 | +ENDIF | |
45 | + | |
46 | + | |
47 | +;===== define structures containing results | |
48 | +one_str_input_EXT={FILTER:'',Wavelength:la_undef(4),I:la_undef(5),Q:la_undef(5),U:la_undef(5),varianceII:la_undef(5),varianceQQ:la_undef(5),varianceUU:la_undef(5)} | |
49 | +one_str_predicted_EXT={FILTER:'',Wavelength:la_undef(4),I:la_undef(5),Q:la_undef(5),U:la_undef(5)} | |
50 | + | |
51 | +Next=n_elements((*syst_var.ext).filt_names) | |
52 | +str_input_EXT=replicate(one_str_input_EXT,Next) | |
53 | +str_input_EXT.FILTER=(*syst_var.ext).filt_names | |
54 | +str_input_EXT.Wavelength=(*syst_var.ext).wav | |
55 | +str_input_EXT.I=(*syst_var.ext).values | |
56 | +str_input_EXT.varianceII=la_power((*syst_var.ext).sigma,2.) | |
57 | + | |
58 | +;N_predicted_ext=n_elements(dustem_predicted_polext[0]) | |
59 | +N_predicted_ext=n_elements(dustem_predicted_ext) | |
60 | +str_predicted_EXT=replicate(one_str_predicted_EXT,N_predicted_EXT) | |
61 | +fully_undefined_ext=str_predicted_ext | |
62 | +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 | |
63 | + message,'I have a problem with dimensions ...',/continue | |
64 | + stop | |
65 | +ENDIF ELSE BEGIN | |
66 | + str_predicted_EXT.FILTER=(*syst_var.ext).filt_names ;taken from input SED | |
67 | + str_predicted_EXT.Wavelength=(*syst_var.ext).wav ;taken from input SED | |
68 | + str_predicted_EXT.I=dustem_predicted_ext | |
69 | +ENDELSE | |
70 | +;stop | |
71 | +IF !run_pol THEN BEGIN | |
72 | + str_predicted_EXT.Q=interpol(dustem_predicted_Qext,(*syst_var.qext).wav,(*syst_var.ext).wav) | |
73 | + str_predicted_EXT.U=interpol(dustem_predicted_Uext,(*syst_var.uext).wav,(*syst_var.ext).wav) | |
74 | +ENDIF ELSE BEGIN | |
75 | + str_predicted_EXT.Q=fully_undefined_ext.Q | |
76 | + str_predicted_EXT.U=fully_undefined_ext.U | |
77 | +ENDELSE | |
78 | + | |
79 | +RETURN,str_predicted_EXT | |
80 | + | |
81 | +END | |
0 | 82 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,124 @@ |
1 | +FUNCTION dustem_make_fits_predicted_sed,syst_var,dustem_predicted_sed,str_input_sed=str_input_sed,help=help | |
2 | + | |
3 | +;+ | |
4 | +; NAME: | |
5 | +; dustem_make_fits_predicted_sed | |
6 | +; PURPOSE: | |
7 | +; extracts dustemwrap predicted SED from dustem system variable syst_var, to be put into fits files | |
8 | +; CATEGORY: | |
9 | +; DustEMWrap, Distributed, High-Level, User Convenience | |
10 | +; CALLING SEQUENCE: | |
11 | +; str_predicted_SED=dustem_make_fits_predicted_sed(syst_var,dustem_predicted_sed[,str_input_sed=]) | |
12 | +; see dustem_write_fits_table.pro | |
13 | +; INPUTS: | |
14 | +; syst_var : dustem system variable (*!dustem_data or *!dustem_show) | |
15 | +; dustem_predicted_sed : dustemwrap predicted SED as output by dustem_compute_sed.pro | |
16 | +; OPTIONAL INPUT PARAMETERS: | |
17 | +; None | |
18 | +; OUTPUTS: | |
19 | +; str_predicted_SED : dustemwrap predicted SED as used to store into fits file | |
20 | +; OPTIONAL OUTPUT PARAMETERS: | |
21 | +; str_input_sed : dustem wrap input SED | |
22 | +; ACCEPTED KEY-WORDS: | |
23 | +; help = If set, print this help | |
24 | +; COMMON BLOCKS: | |
25 | +; None | |
26 | +; SIDE EFFECTS: | |
27 | +; None | |
28 | +; RESTRICTIONS: | |
29 | +; The DustEMWrap IDL code must be installed | |
30 | +; PROCEDURE: | |
31 | +; None | |
32 | +; EXAMPLES: | |
33 | +; str_predicted_SED=dustem_make_fits_predicted_sed(*!dustem_data,dustem_predicted_sed,str_input_sed=str_input_sed) | |
34 | +; MODIFICATION HISTORY: | |
35 | +; Written by J.-Ph. Bernard Dec 2022 | |
36 | +; Evolution details on the DustEMWrap gitlab. | |
37 | +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. | |
38 | +;- | |
39 | + | |
40 | +IF keyword_set(help) THEN BEGIN | |
41 | + doc_library,'dustem_make_fits_predicted_sed' | |
42 | + str_predicted_SED=-1 | |
43 | + goto,the_end | |
44 | +ENDIF | |
45 | + | |
46 | +;example: | |
47 | +;str_predicted_SED=dustem_make_fits_predicted_sed(*!dustem_data,str_input_sed=str_input_sed) | |
48 | + | |
49 | +;===== define structures containing input and predicted SEDs | |
50 | +one_str_input_SED={FILTER:'',Wavelength:la_undef(4),STOKESI:la_undef(5),STOKESQ:la_undef(5),STOKESU:la_undef(5),varianceII:la_undef(5),varianceQQ:la_undef(5),varianceUU:la_undef(5)} | |
51 | +one_str_predicted_SED={FILTER:'',Wavelength:la_undef(4),STOKESI:la_undef(5),STOKESQ:la_undef(5),STOKESU:la_undef(5)} | |
52 | + | |
53 | +Nsed=n_elements((*syst_var.sed).filt_names) | |
54 | +str_input_SED=replicate(one_str_input_SED,Nsed) | |
55 | +str_input_SED.FILTER=(*syst_var.sed).filt_names | |
56 | +str_input_SED.Wavelength=(*syst_var.sed).wav | |
57 | +str_input_SED.STOKESI=(*syst_var.sed).values | |
58 | +str_input_SED.varianceII=la_power((*syst_var.sed).sigma,2) ;This is the variance | |
59 | + | |
60 | +N_predicted_sed=n_elements(dustem_predicted_sed) | |
61 | +str_predicted_SED=replicate(one_str_predicted_SED,N_predicted_sed) | |
62 | +;str_predicted_EXT=replicate(one_str_predicted_SED,N_predicted_sed) | |
63 | +fully_undefined_sed=str_predicted_SED | |
64 | +str_predicted_SED.FILTER=(*syst_var.sed).filt_names ;taken from input SED | |
65 | +str_predicted_SED.Wavelength=(*syst_var.sed).wav ;taken from input SED | |
66 | +str_predicted_SED.STOKESI=dustem_predicted_sed | |
67 | +;stop | |
68 | +IF !run_pol THEN BEGIN | |
69 | + qsed=aos2soa(*syst_var.qsed) | |
70 | + ind=where(qsed.filt_names NE 'SPECTRUM',count,complement=inds,Ncomplement=counts) | |
71 | + IF count NE 0 THEN BEGIN | |
72 | + qsed=qsed[ind] | |
73 | + FOR i=0L,n_elements(qsed.wav)-1 DO BEGIN | |
74 | + ind=where(str_input_SED.FILTER EQ qsed[i].filt_names,count) | |
75 | + IF count NE 0 THEN BEGIN | |
76 | + str_input_SED[ind[0]].STOKESQ=qsed[i].values | |
77 | + str_input_SED[ind[0]].varianceQQ=la_power(qsed[i].sigma,2.) | |
78 | + ENDIF | |
79 | + str_predicted_SED[ind[0]].STOKESQ=dustem_predicted_Qsed[i] | |
80 | + ENDFOR | |
81 | + ENDIF | |
82 | + qsed=aos2soa(*syst_var.qsed) | |
83 | + IF counts NE 0 THEN BEGIN | |
84 | + qsed=qsed[inds] | |
85 | + ind2=where(str_predicted_SED.filter EQ 'SPECTRUM',count2) | |
86 | + str_predicted_SED[ind2].STOKESQ=interpol(qsed.values,qsed.wav,str_predicted_SED[ind2].Wavelength) | |
87 | + str_predicted_SED[ind2].varianceQQ=interpol(la_power(qsed.sigma,2.),qsed.wav,str_predicted_SED[ind2].Wavelength) | |
88 | + ENDIF | |
89 | + used=aos2soa(*syst_var.used) | |
90 | + ind=where(used.filt_names NE 'SPECTRUM',count,complement=inds,Ncomplement=counts) | |
91 | + IF count NE 0 THEN BEGIN | |
92 | + used=used[ind] | |
93 | + FOR i=0L,n_elements(used.wav)-1 DO BEGIN | |
94 | + ind=where(str_input_SED.FILTER EQ used[i].filt_names,count) | |
95 | + IF count NE 0 THEN BEGIN | |
96 | + str_input_SED[ind[0]].STOKESU=used[i].values | |
97 | + str_input_SED[ind[0]].varianceUU=la_power(used[i].sigma,2.) | |
98 | + ENDIF | |
99 | + str_predicted_SED[ind[0]].STOKESU=dustem_predicted_Used[i] | |
100 | + ENDFOR | |
101 | + ENDIF | |
102 | + used=aos2soa(*syst_var.used) | |
103 | + IF counts NE 0 THEN BEGIN | |
104 | + used=used[inds] | |
105 | + ind2=where(str_predicted_SED.filter EQ 'SPECTRUM',count2) | |
106 | + str_predicted_SED[ind2].STOKESU=interpol(used.values,used.wav,str_predicted_SED[ind2].Wavelength) | |
107 | + str_predicted_SED[ind2].varianceUU=interpol(la_power(used.sigma,2.),used.wav,str_predicted_SED[ind2].Wavelength) | |
108 | + ENDIF | |
109 | + ;stop | |
110 | + ;str_predicted_SED.Q=dustem_predicted_Qsed | |
111 | + ;str_predicted_SED.U=dustem_predicted_Used | |
112 | + ;str_predicted_SED.Q=interpol(dustem_predicted_Qsed,(*(*!dustem_data).qsed).wav,(*(*!dustem_data).sed).wav) | |
113 | + ;str_predicted_SED.U=interpol(dustem_predicted_Used,(*(*!dustem_data).used).wav,(*(*!dustem_data).sed).wav) | |
114 | + ;ENDFOR | |
115 | +ENDIF ELSE BEGIN | |
116 | + str_predicted_SED.STOKESQ=fully_undefined_sed.STOKESQ | |
117 | + str_predicted_SED.STOKESU=fully_undefined_sed.STOKESU | |
118 | +ENDELSE | |
119 | + | |
120 | +the_end: | |
121 | + | |
122 | +RETURN,str_predicted_SED | |
123 | + | |
124 | +END | ... | ... |