Blame view

src/idl/dustem_make_polarization_sed_example.pro 5.49 KB
2d758fdd   Annie Hughes   improved commenti...
1
2
3
4
5
PRO dustem_make_polarization_sed_example,model=model $
                                         ,filters=filters $
                                         ,outfile=outfile $
                                         ,help=help $
                                         ,verbose=verbose 
21b2be95   Jean-Philippe Bernard   First commit
6
7
8
9

;+
; NAME:
;    dustem_make_polarization_sed_example
2d758fdd   Annie Hughes   improved commenti...
10
;
21b2be95   Jean-Philippe Bernard   First commit
11
; PURPOSE:
fd152fd2   Annie Hughes   cosmetic changes ...
12
;    This is an example of how to generate an SED using DustEMWrap.
21b2be95   Jean-Philippe Bernard   First commit
13
;    It is meant to be an example to follow when writing your own
fd152fd2   Annie Hughes   cosmetic changes ...
14
;    programs using DustEMWrap
2d758fdd   Annie Hughes   improved commenti...
15
;
21b2be95   Jean-Philippe Bernard   First commit
16
; CATEGORY:
fd152fd2   Annie Hughes   cosmetic changes ...
17
;    DustEMWrap, Distributed, High-Level, User Example
2d758fdd   Annie Hughes   improved commenti...
18
;
21b2be95   Jean-Philippe Bernard   First commit
19
; CALLING SEQUENCE:
fd152fd2   Annie Hughes   cosmetic changes ...
20
;    dustem_make_polarization_sed_example[,model=][,filters=][,/help]
2d758fdd   Annie Hughes   improved commenti...
21
;
21b2be95   Jean-Philippe Bernard   First commit
22
23
; INPUTS:
;    None
2d758fdd   Annie Hughes   improved commenti...
24
;
21b2be95   Jean-Philippe Bernard   First commit
25
; OPTIONAL INPUT PARAMETERS:
2d758fdd   Annie Hughes   improved commenti...
26
27
28
;    filters = instrument bands for which SED is created. Default is
;    ['IRAS1','IRAS2','IRAS3','IRAS4','PACS3','SPIRE1','SPIRE2','SPIRE3','HFI2','HFI3','HFI4','HFI5','HFI6','LFI1','LFI2','LFI3']
;
21b2be95   Jean-Philippe Bernard   First commit
29
30
; OUTPUTS:
;    None
2d758fdd   Annie Hughes   improved commenti...
31
;
21b2be95   Jean-Philippe Bernard   First commit
32
; OPTIONAL OUTPUT PARAMETERS:
2d758fdd   Annie Hughes   improved commenti...
33
34
;    outfile = path+filename for .xcat output of the SED. Default is './polarization_sed.xcat'
;
21b2be95   Jean-Philippe Bernard   First commit
35
; ACCEPTED KEY-WORDS:
2d758fdd   Annie Hughes   improved commenti...
36
;    model     = if set, name of the DustEM dust model to use (default='G17_MODELD')
21b2be95   Jean-Philippe Bernard   First commit
37
;    help      = If set print this help
2d758fdd   Annie Hughes   improved commenti...
38
39
;    verbose      = If set, subroutines will be more chatty
;
21b2be95   Jean-Philippe Bernard   First commit
40
41
; COMMON BLOCKS:
;    None
2d758fdd   Annie Hughes   improved commenti...
42
;
21b2be95   Jean-Philippe Bernard   First commit
43
44
; SIDE EFFECTS:
;    None
2d758fdd   Annie Hughes   improved commenti...
45
;
21b2be95   Jean-Philippe Bernard   First commit
46
; RESTRICTIONS:
fd152fd2   Annie Hughes   cosmetic changes ...
47
48
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
2d758fdd   Annie Hughes   improved commenti...
49
;
21b2be95   Jean-Philippe Bernard   First commit
50
51
; PROCEDURE:
;    None
2d758fdd   Annie Hughes   improved commenti...
52
;
21b2be95   Jean-Philippe Bernard   First commit
53
; EXAMPLES
eab2e158   Jean-Philippe Bernard   did some (sometim...
54
;    dustem_make_polarization_sed_example
2d758fdd   Annie Hughes   improved commenti...
55
56
;    dustem_make_polarization_sed_example,model='G17_MODELA',outfile='mysed.xcat'
;
21b2be95   Jean-Philippe Bernard   First commit
57
; MODIFICATION HISTORY:
fd152fd2   Annie Hughes   cosmetic changes ...
58
59
60
;    Written by JPB June-2022
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
21b2be95   Jean-Philippe Bernard   First commit
61
62
63
;-

IF keyword_set(help) THEN BEGIN
fd152fd2   Annie Hughes   cosmetic changes ...
64
  doc_library,'dustem_make_polarization_sed_example'
21b2be95   Jean-Philippe Bernard   First commit
65
66
67
68
69
  goto,the_end
ENDIF

dustem_define_la_common

fd152fd2   Annie Hughes   cosmetic changes ...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
IF keyword_set(model) THEN BEGIN
  use_model=strupcase(model)
ENDIF ELSE BEGIN
  use_model='G17_MODELD'    ;Default is one of the Guillet et al (2017) models since they treat dust polarisation properties
ENDELSE

IF keyword_set(filters) THEN BEGIN
  use_filters=strupcase(filters)
ENDIF ELSE BEGIN
  use_filters=['IRAS1','IRAS2','IRAS3','IRAS4','PACS3','SPIRE1','SPIRE2','SPIRE3','HFI2','HFI3','HFI4','HFI5','HFI6','LFI1','LFI2','LFI3']
ENDELSE

IF keyword_set(outfile) THEN BEGIN
  use_outfile=outfile
ENDIF ELSE BEGIN
  use_outfile='./polarization_sed.xcat'
ENDELSE

6735604d   Annie Hughes   making FITS read ...
88
89
90
exists=dustem_test_model_exists(use_model,/pol)
if exists eq 0 then $
   message,'Unknown or unpolarized dust model'
fd152fd2   Annie Hughes   cosmetic changes ...
91

2d758fdd   Annie Hughes   improved commenti...
92
93
use_verbose=0
use_polarization=1
fd152fd2   Annie Hughes   cosmetic changes ...
94
95
if keyword_set(verbose) then use_verbose=1

2d758fdd   Annie Hughes   improved commenti...
96
97
dustem_init,mode=use_model,polarization=use_polarization
!dustem_verbose=use_verbose
21b2be95   Jean-Philippe Bernard   First commit
98
99
!dustem_nocatch=1

fd152fd2   Annie Hughes   cosmetic changes ...
100
101
;=== initialize filters for the SED
Nfilt=n_elements(use_filters)
21b2be95   Jean-Philippe Bernard   First commit
102
sed=dustem_initialize_sed(Nfilt)
fd152fd2   Annie Hughes   cosmetic changes ...
103
104
105
sed.filter=use_filters
sed.wave=dustem_filter2wav(use_filters)
sed.instru=dustem_filter2instru(use_filters)
21b2be95   Jean-Philippe Bernard   First commit
106

fd152fd2   Annie Hughes   cosmetic changes ...
107
;=== initialize IQU and associated errors to avoid problems when checking SED in dustem_set_data.pro
21b2be95   Jean-Philippe Bernard   First commit
108
109
110
111
112
113
114
115
116
117
sed[*].StokesI=1.
sed.StokesQ=sed.StokesI/100.
sed.StokesU=sed.StokesI/100.
sed.SigmaII=sed.StokesI/100.
sed.SigmaQQ=sed.StokesI/100.
sed.SigmaUU=sed.StokesI/100.
sed.SigmaIQ=sed.StokesI/100.
sed.SigmaIU=sed.StokesI/100.
sed.SigmaQU=sed.StokesI/100.

fd152fd2   Annie Hughes   cosmetic changes ...
118
;=== initialize the !dustem_data structure that will be used internally
6735604d   Annie Hughes   making FITS read ...
119
dustem_set_data,m_fit=sed,m_show=sed
21b2be95   Jean-Philippe Bernard   First commit
120

21b2be95   Jean-Philippe Bernard   First commit
121
;=== Set which model parameters to use for the SED
01f481d4   Jean-Philippe Bernard   added dust polari...
122
123
pd = [ $
             '(*!dustem_params).G0', $                   ;G0
fd152fd2   Annie Hughes   cosmetic changes ...
124
125
126
127
             '(*!dustem_params).grains(0).mdust_o_mh',$  ;PAH0_MC10 mass fraction
             '(*!dustem_params).grains(1).mdust_o_mh',$  ;amCBE_0.3333x mass fraction   
             '(*!dustem_params).grains(2).mdust_o_mh', $    ;aSil2001BE6pctG_0.4x mass fraction
             'dustem_plugin_modify_dust_pol_2',  $     ;Dust polarization angle
01f481d4   Jean-Philippe Bernard   added dust polari...
128
129
130
131
132
             'dustem_plugin_synchrotron_1', $   ;Synchrotron spectra index
             'dustem_plugin_synchrotron_2', $   ;Synchrotron amplitude at 10 mm
             'dustem_plugin_synchrotron_3', $    ;Synchrotron polarization fraction
             'dustem_plugin_synchrotron_4'  $    ;Synchrotron polarization angle
             ]                   
2d758fdd   Annie Hughes   improved commenti...
133
pd_true=[1.,7.8000E-04,7.8000E-04,7.8000E-04, 48.,3., 1.e-2, 0.3, 45.]
01f481d4   Jean-Philippe Bernard   added dust polari...
134

2d758fdd   Annie Hughes   improved commenti...
135
136
;== SET INITIAL VALUES AND LIMITS 
;== AND ACTIVATE ANY PLUGINS
6735604d   Annie Hughes   making FITS read ...
137

2d758fdd   Annie Hughes   improved commenti...
138
dustem_init_params,use_model,pd,pd_true,pol=use_polarization
21b2be95   Jean-Philippe Bernard   First commit
139

6735604d   Annie Hughes   making FITS read ...
140

2d758fdd   Annie Hughes   improved commenti...
141
142
;=== compute the SED (I then QU) using the model and specified
;=== true_vals of parameters
86f1665a   Annie Hughes   updated to confor...
143
144
145
146
dustem_Ised=dustem_compute_sed(pd_true,st=ssti)   ;sst is not set on purpose, for dustem_compute_sed to compute the sed using fortran code
toto=dustem_compute_stokes(pd_true,st=sstqu) ;this procedure also allows for the extraction of the spectra
dustem_qsed = toto[0]
dustem_used = toto[1]
21b2be95   Jean-Philippe Bernard   First commit
147

eab2e158   Jean-Philippe Bernard   did some (sometim...
148

4d1fdbd6   Jean-Philippe Bernard   added some synchr...
149
150
151
152
sed.stokesI=dustem_Ised
sed.stokesQ=dustem_Qsed
sed.stokesU=dustem_Used

2d758fdd   Annie Hughes   improved commenti...
153
;=== set uncertainties for I,Q,U
eab2e158   Jean-Philippe Bernard   did some (sometim...
154
155
sed.sigmaII=abs(sed.StokesI*0.000001)
sed.sigmaQQ=abs(sed.StokesQ*0.000001)
21b2be95   Jean-Philippe Bernard   First commit
156
157
sed.sigmaUU=abs(sed.StokesU*0.000001)

2d758fdd   Annie Hughes   improved commenti...
158
;=== set covariances to 0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
159
160
161
162
sed.sigmaIQ=0.
sed.sigmaIU=0.
sed.sigmaQU=0.

4d1fdbd6   Jean-Philippe Bernard   added some synchr...
163
164
165
;==== fill in dependent columns of the SED.
sed=dustem_fill_sed_dependent_columns(sed)

fd152fd2   Annie Hughes   cosmetic changes ...
166
167
168
;======== save the SED to a file
write_xcat,sed,use_outfile
message,'Wrote '+use_outfile,/continue
21b2be95   Jean-Philippe Bernard   First commit
169

fd152fd2   Annie Hughes   cosmetic changes ...
170
171
172
173
;======== move the file to the Data/EXAMPLE_OBSDATA/ subdirectory 
;filename_final=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/my_example_SED_###.xcat'
;str='cp '+use_outfile+' '+filename_final
;message,'Do '+str+' to make change permanent',/continue
2a47d796   Jean-Philippe Bernard   improved
174

21b2be95   Jean-Philippe Bernard   First commit
175
176
the_end:

fd152fd2   Annie Hughes   cosmetic changes ...
177
END