Blame view

src/idl/dustem_make_polarization_ext_example.pro 5.89 KB
2d758fdd   Annie Hughes   improved commenti...
1
2
3
4
5
6
PRO dustem_make_polarization_ext_example,model=model $
                                         ,wave=wave $
                                         ,next=next $
                                         ,outfile=outfile $
                                         ,help=help $
                                         ,verbose=verbose
9c053027   Annie Hughes   first commit
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


;+
; NAME:
;    dustem_make_polarization_ext_example
;
; PURPOSE:
;    This is an example of how to generate an extinction curve using DustEMWrap.
;    It is meant to be an example to follow when writing your own
;    programs using DustEMWrap
;
; CATEGORY:
;    DustEMWrap, Distributed, High-Level, User Example
;
; CALLING SEQUENCE:
;    dustem_make_polarization_ext_example[,model=][,filters=][,/help]
;
; INPUTS:
2d758fdd   Annie Hughes   improved commenti...
25
26
27
28
29
30
;    wave = wavelength range specified as [minwave,maxwave] in microns over which
;           to construct the extinction curve. The resulting curve
;           will be defined on the vector :
;           wave_vector=10^(alog10(wave[0])+alog10(wave[1])*findgen(Next)/float(Next))
;           default is [0.01,50]
;    Next = number of measurements in the extinction curve. Default is 100.
9c053027   Annie Hughes   first commit
31
32
33
34
35
36
37
38
39
40
41
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    None
;
; OPTIONAL OUTPUT PARAMETERS:
;    outfile = path+filename for .xcat output of the EXT
;
; ACCEPTED KEY-WORDS:
6735604d   Annie Hughes   making FITS read ...
42
43
44
;    model = specifies the interstellar dust mixture used by
;            DustEM. See userguide or dustem_test_model_exists.pro
;            for more details about available models in current release.
9c053027   Annie Hughes   first commit
45
;    help      = If set print this help
2d758fdd   Annie Hughes   improved commenti...
46
;    verbose      = If set, subroutines will be more chatty
9c053027   Annie Hughes   first commit
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;    None
;
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
;
; PROCEDURE:
;    None
;
; EXAMPLES
;    dustem_make_polarization_ext_example
;    dustem_make_polarization_ext_example,model='G17_MODELC',outfile='my_polarized_ext.xcat'
;
; MODIFICATION HISTORY:
2d758fdd   Annie Hughes   improved commenti...
66
;    Written by AH Nov-2022
9c053027   Annie Hughes   first commit
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
;    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_polarization_ext_example'
  goto,the_end
ENDIF

dustem_define_la_common

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(outfile) THEN BEGIN
  use_outfile=outfile
ENDIF ELSE BEGIN
  use_outfile='./polarization_ext.xcat'
ENDELSE

6735604d   Annie Hughes   making FITS read ...
90
91
92
93
exists=dustem_test_model_exists(use_model,/pol)
if exists ne 1 then $
   message,'Unknown/unpolarised dust model: '+use_model

9c053027   Annie Hughes   first commit
94
95

use_verbose=0
2d758fdd   Annie Hughes   improved commenti...
96
97
98
use_polarization=1
use_next=100 ; number of extinction measurements
use_wave=10^(alog10(0.01)+alog10(50)*findgen(use_next)/float(use_next)) ; wavelengths at which extinction is defined
9c053027   Annie Hughes   first commit
99
if keyword_set(verbose) then use_verbose=1
2d758fdd   Annie Hughes   improved commenti...
100
101
if keyword_set(next) then use_next=next
if keyword_set(wave) then use_wave=10^(alog10(wave[0])+alog10(wave[1])*findgen(use_next)/float(use_next))
9c053027   Annie Hughes   first commit
102

2d758fdd   Annie Hughes   improved commenti...
103
104
   
dustem_init,mode=use_model,polarization=use_polarization
9c053027   Annie Hughes   first commit
105
106
107
108
109
110
111
112
113
114
115
116
117
!dustem_verbose=use_verbose
!dustem_nocatch=1

;=== initialize wavelengths for the EXTINCTION
ext=dustem_initialize_ext(use_next)
ext.instru='EXTINCTION'
ext.filter='SPECTRUM'
ext.wave=use_wave

;=== initialize IQU and associated errors to avoid problems when checking EXT in dustem_set_data.pro
ext[*].EXT_I=1.
ext.EXT_Q=ext.EXT_I/100.
ext.EXT_U=ext.EXT_I/100.
2d758fdd   Annie Hughes   improved commenti...
118
119
120
121
122
123
124
125
126
127
ext.SIGEXTII=ext.EXT_I/1000.
ext.SIGEXTQQ=ext.EXT_I/1000.
ext.SIGEXTUU=ext.EXT_I/1000.
ext.SIGEXTIQ=ext.EXT_I/1000.
ext.SIGEXTIU=ext.EXT_I/1000.
ext.SIGEXTQU=ext.EXT_I/1000.

;=== Set which model parameters to use for the EXT, this will depend
;=== on the selected dust model. For model parameters not specified
;=== here, the default Dustem fortran values will be used
9c053027   Annie Hughes   first commit
128
pd = [ $
2d758fdd   Annie Hughes   improved commenti...
129
130
     '(*!dustem_params).grains(0).mdust_o_mh', $          ;PAH0_MC10 mass fraction
     '(*!dustem_params).grains(1).mdust_o_mh', $          ;amCBE_0.3333x mass fraction   
9c053027   Annie Hughes   first commit
131
     '(*!dustem_params).grains(2).mdust_o_mh', $         ;aSil2001BE6pctG_0.4x mass fraction
2d758fdd   Annie Hughes   improved commenti...
132
133
134
     'dustem_plugin_modify_dust_polx_2' $                 ;Dust polarization angle in extinction
     ]                   
true_vals=[7.8000E-04,7.8000E-04,7.8000E-04, 52.]
9c053027   Annie Hughes   first commit
135

9c053027   Annie Hughes   first commit
136

9c053027   Annie Hughes   first commit
137
138
139
;== SET INITIAL VALUES AND LIMITS OF THE PARAMETERS FOR THE FIT 
;== AND ACTIVATE ANY PLUGINS
;== FOR REASONS, WE NEED TO DO THIS DUSTEM_SET_DATA CALL
97d6b02a   Annie Hughes   changed llims to ...
140
dustem_init_params,use_model,pd,true_vals,pol=use_polarization;,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,ulims=ulims,llims=llims
9c053027   Annie Hughes   first commit
141
142
143
144
145


;=== initialize the !dustem_data structure that will be used internally
;== note that m_fit and m_show do not exist -- this is deliberate
;== since we are not treating emission data
6735604d   Annie Hughes   making FITS read ...
146
dustem_set_data,m_fit=m_fit,m_show=m_show,x_fit=ext,x_show=ext
9c053027   Annie Hughes   first commit
147

2d758fdd   Annie Hughes   improved commenti...
148
149
;=== compute the extinction curve (I then QU) using the model and specified
;=== true_vals of parameters
9c053027   Annie Hughes   first commit
150
151
152
153
154
dustem_iext=dustem_compute_ext(true_vals,st=ssti) ;sst is not set on purpose, for dustem_compute_ext to compute the ext using fortran code
toto=dustem_compute_stokext(true_vals,st=sstqu) ;this procedure also allows for the extraction of the spectra
dustem_qext = toto[0]
dustem_uext = toto[1]

9c053027   Annie Hughes   first commit
155
156
157
158
159
160
161
162
163
ext.EXT_I=dustem_Iext
ext.EXT_Q=dustem_Qext
ext.EXT_U=dustem_Uext

;=== set uncertainties to I,Q,U
ext.SIGEXTII=abs(ext.EXT_I*0.000001)
ext.SIGEXTQQ=abs(ext.EXT_Q*0.000001)
ext.SIGEXTUU=abs(ext.EXT_U*0.000001)

2d758fdd   Annie Hughes   improved commenti...
164
;=== set covariances to 0.
9c053027   Annie Hughes   first commit
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
ext.SIGEXTIQ=0.
ext.SIGEXTIU=0.
ext.SIGEXTQU=0.

;==== fill in dependent columns of the EXT.
ext=dustem_fill_ext_dependent_columns(ext)

;======== save the EXT to a file
write_xcat,ext,use_outfile
message,'Wrote '+use_outfile,/continue

;======== move the file to the Data/EXAMPLE_OBSDATA/ subdirectory 
;filename_final=!dustem_wrap_soft_dir+'/Data/EXAMPLE_OBSDATA/my_example_EXT_###.xcat'
;str='cp '+use_outfile+' '+filename_final
;message,'Do '+str+' to make change permanent',/continue

the_end:

END