Blame view

src/idl/dustem_run_example.pro 6 KB
3583bcca   Annie Hughes   bug fix
1
PRO dustem_run_example,model=model $
80eb3ca5   Annie Hughes   clean up
2
3
4
                      ,png=png $
                      ,postscript=postscript $
                      ,help=help
9ebef1db   Jean-Philippe Bernard   First commit
5
6
7

;+
; NAME:
3583bcca   Annie Hughes   bug fix
8
;    dustem_run_example
9ebef1db   Jean-Philippe Bernard   First commit
9
; PURPOSE:
80eb3ca5   Annie Hughes   clean up
10
;    This is an example of how to run the DustEM fortran code using DustEMWrap
9ebef1db   Jean-Philippe Bernard   First commit
11
; CATEGORY:
80eb3ca5   Annie Hughes   clean up
12
;    DustEMWrap, Distributed, High-Level, User Example
9ebef1db   Jean-Philippe Bernard   First commit
13
; CALLING SEQUENCE:
3583bcca   Annie Hughes   bug fix
14
;    dustem_run_example,model=model,postscript=postscript,png=png,help=help
9ebef1db   Jean-Philippe Bernard   First commit
15
16
17
18
19
20
21
22
23
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
80eb3ca5   Annie Hughes   clean up
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;    model = specifies the interstellar dust mixture used by DustEM
;           'MC10' model from Compiegne et al 2010 (default)
;           'DBP90' model from Desert et al 1990
;           'DL01' model from Draine & Li 2001
;           'WD01_RV5p5B' model from Weingartner & Draine 2002 with Rv=5.5
;           'DL07' model from Draine & Li 2007
;           'J13' model from Jones et al 2013, as updated in
;                 Koehler et al 2014
;           'G17_ModelA' model A from Guillet et al (2018). Includes
;                 polarisation. See Tables 2 and 3 of that paper for details.
;           'G17_ModelB' model B from Guillet et al (2018)
;           'G17_ModelC' model C from Guillet et al (2018)
;           'G17_ModelD' model A from Guillet et al (2018)
;    postscript = if set, final plot is saved as postscript in the
;                 current working directory
;    png = if set, final plot is saved as png  in the
;          current working directory
;    help      = if set, print this help
9ebef1db   Jean-Philippe Bernard   First commit
42
43
44
45
46
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
80eb3ca5   Annie Hughes   clean up
47
48
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
9ebef1db   Jean-Philippe Bernard   First commit
49
50
51
; PROCEDURE:
;    None
; EXAMPLES
3583bcca   Annie Hughes   bug fix
52
;    dustem_run_example,model='DBP90',png='test_dbp90.png'
9ebef1db   Jean-Philippe Bernard   First commit
53
; MODIFICATION HISTORY:
80eb3ca5   Annie Hughes   clean up
54
55
56
;    Written JPB Apr-2011
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
9ebef1db   Jean-Philippe Bernard   First commit
57
58
59
;-

IF keyword_set(help) THEN BEGIN
3583bcca   Annie Hughes   bug fix
60
  doc_library,'dustem_run_example'
9ebef1db   Jean-Philippe Bernard   First commit
61
62
63
64
65
66
67
68
  goto,the_end
ENDIF

loadct,13

IF keyword_set(model) THEN BEGIN
  use_model=strupcase(model)
ENDIF ELSE BEGIN
80eb3ca5   Annie Hughes   clean up
69
  use_model='MC10'    ;Default is the Compiegne et al 2010 model
9ebef1db   Jean-Philippe Bernard   First commit
70
71
ENDELSE

80eb3ca5   Annie Hughes   clean up
72
;== INITIALISE DUSTEM
9ebef1db   Jean-Philippe Bernard   First commit
73
74
75
76
dustem_init,model=use_model
!dustem_verbose=1
!dustem_show_plot=1

80eb3ca5   Annie Hughes   clean up
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
CASE !dustem_which OF
   'DESERT': begin
      dir='DESERT_POST_ISO_MORE/'
      message,'DESERT version disabled for this routine',/info
   end
   'COMPIEGNE': begin
      dir='MC_DAT/'
      message,'COMPIEGNE version disabled for this routine',/info
   end
   'VERSTRAETE': begin
      dir='LV_DAT/'
      message,'VERSTRAETE version disabled for this routine',/info
   end
   'RELEASE': dir_in=!dustem_soft_dir  
   ELSE: dir_in=!dustem_soft_dir  
   ;dir='les_DAT/'
ENDCASE
9ebef1db   Jean-Philippe Bernard   First commit
94

80eb3ca5   Annie Hughes   clean up
95
;== Fill the following structure contains with default inputs to the model
9ebef1db   Jean-Philippe Bernard   First commit
96
97
98
st_model=dustem_read_all(dir_in)
;help,st_model,/str

80eb3ca5   Annie Hughes   clean up
99
100
101
102
103
104
105
106
107
108
109
110
;=== You can modify the model inputs by changing the values in the
;=== st_model structure

;=== e.g. modify the default value of the ISRF intensity used by DustEM
;st_model.G0=2.

;===== e.g. modify keywords related to spinning dust. Does not work with DBP90 !
;st_model.grains[0].type_keywords='logn-chrg-spin'
;st_model.gas.NH=1.e2
;st_model.gas.Tgas=1.e5

;== The following line saves the modified inputs for use by the Fortran
9ebef1db   Jean-Philippe Bernard   First commit
111
dustem_write_all,st_model,!dustem_dat
80eb3ca5   Annie Hughes   clean up
112
113

;== The following line runs the Fortran. The ouput structure st contains the results
9ebef1db   Jean-Philippe Bernard   First commit
114
st=dustem_run()
80eb3ca5   Annie Hughes   clean up
115

9ebef1db   Jean-Philippe Bernard   First commit
116
117
118
119
120
121
122
123
124
125
126
;== Optionaly, this creates an SED to be overploted
;stop
;filters=['IRAS1','IRAS4']
;Nfilt=n_elements(filters)
;sed=dustem_initialize_sed(Nfilt)
;sed.filter=filters
;sed.wave=dustem_filter2wav(filters)
;sed.instru=dustem_filter2instru(filters)
;stop
;stt=dustem_set_data(sed=sed)

80eb3ca5   Annie Hughes   clean up
127
;== The following lines plot the resulting SED (emission)
9ebef1db   Jean-Philippe Bernard   First commit
128
129
130
131
132
win=0L
window,win & win=win+2
xtit=textoidl('\lambda (\mum)')
;=== same plot as in Compiegne et al. 2010
ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
80eb3ca5   Annie Hughes   clean up
133
tit='DustEMWrap Emitted Intensity '+use_model
9ebef1db   Jean-Philippe Bernard   First commit
134
135
136
yr=[1e-11,6.e-7]
xr=[1,5e3]
dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
80eb3ca5   Annie Hughes   clean up
137
138
139
140
141
142
143
144
145
146
IF keyword_set(postscript) THEN BEGIN
   dir_ps='./'
   file_ps=dir_ps+postscript
   previous_device=!d.name
   set_plot,'PS'
   device,filename=file_ps
   dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
   device,/close
   set_plot,previous_device
   message,'Wrote '+file_ps,/continue
9ebef1db   Jean-Philippe Bernard   First commit
147
148
ENDIF

80eb3ca5   Annie Hughes   clean up
149
;== The following plots the resulting SED (extinction)
9ebef1db   Jean-Philippe Bernard   First commit
150
151
152
153
154
window,win & win=win+1
yr=[0,2.5]  ;range of 1/lambda
xr=[1,10]   ;range of sigma
xtit=textoidl('1/\lambda (\mum^{-1})')
ytit=textoidl('\sigma_{ext} (1e-21 cm^2/H)')
80eb3ca5   Annie Hughes   clean up
155
tit='DustEMWrap extinction '+use_model
9ebef1db   Jean-Philippe Bernard   First commit
156
dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
80eb3ca5   Annie Hughes   clean up
157
158
IF keyword_set(postscript) THEN BEGIN
  file_ps=dir_ps+file_basename(file_ps,'.ps')+'_extinction.ps'
9ebef1db   Jean-Philippe Bernard   First commit
159
160
161
162
163
164
165
166
167
168
169
170
  previous_device=!d.name
  set_plot,'PS'
  device,filename=file_ps
  dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
  device,/close
  set_plot,previous_device
  message,'Wrote '+file_ps,/continue
ENDIF

IF keyword_set(png) THEN BEGIN
  win=10L
  window,win ;& win=win+2
80eb3ca5   Annie Hughes   clean up
171
172
  dir_png='./'
  file_png=dir_png+png
9ebef1db   Jean-Philippe Bernard   First commit
173
174
  xtit=textoidl('\lambda (\mum)')
  ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
80eb3ca5   Annie Hughes   clean up
175
  tit='DustEMWrap Emitted Intensity '+use_model
9ebef1db   Jean-Philippe Bernard   First commit
176
177
178
179
180
181
  yr=[1e-11,6.e-7]
  xr=[1,5e3]
  dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
  write_png,file_png,tvrd(/true)
  message,'Wrote '+file_png,/info
  ;=====
80eb3ca5   Annie Hughes   clean up
182
183
  file_png=dir_png+file_basename(file_png,'.png')+'_extinction.png'

9ebef1db   Jean-Philippe Bernard   First commit
184
185
186
187
  yr=[0,2.5]  ;range of 1/lambda
  xr=[1,10]   ;range of sigma
  xtit=textoidl('1/\lambda (\mum^{-1})')
  ytit=textoidl('\sigma_{ext} (1e-21 cm^2/H)')
80eb3ca5   Annie Hughes   clean up
188
  tit='DustEMWrap extinction '+use_model
9ebef1db   Jean-Philippe Bernard   First commit
189
190
191
192
193
194
195
196
  dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
  write_png,file_png ,tvrd(/true),/verbose
  message,'Wrote '+file_png,/info
ENDIF

the_end:

END