Blame view

src/idl/dustem_run_readme.pro 5.54 KB
9707968f   Jean-Philippe Bernard   added postscript ...
1
PRO dustem_run_readme,model=model,help=help,plot_it=plot_it,png=png,postcript=postcript
427f1205   Jean-Michel Glorian   version 4.2 merged
2
3
4
5
6
7
8
9
10

;+
; NAME:
;    dustem_run_readme
; PURPOSE:
;    This is an example of how to run dustem SEDs with the dustem wrapper.
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
e69bf245   Jean-Philippe Bernard   improved
11
;    dustem_run_readme,model=model,help=help,/postcript,/help,/plot_it
427f1205   Jean-Michel Glorian   version 4.2 merged
12
13
14
15
16
17
18
19
20
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
e69bf245   Jean-Philippe Bernard   improved
21
;    model = Selects one of the dust mixture used by dustem
427f1205   Jean-Michel Glorian   version 4.2 merged
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;           'COMPIEGNE_ETAL2010' from Compiegne et al 2010 (default)
;           'DBP90' from Desert et al 1990
;           'DL01' from Draine & Li 2001
;           'DL07' from Draine & Li 2007
;    postcript = if set, plot is done in DUSTEM/Docs/Figures/Last_dustem_fit.ps
;    help      = If set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
e69bf245   Jean-Philippe Bernard   improved
38
;    dustem_run_readme,model='COMPIEGNE_ETAL2010'
427f1205   Jean-Michel Glorian   version 4.2 merged
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; MODIFICATION HISTORY:
;    Written by J.P. Bernard April 1st 2011
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
;-

;This Readme shows how to run dustem from the wrapper
;Obviously, the dustem package must have been installed succesfully (see
;dustem_cvs_readme.txt for install instructions).

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_run_readme'
  goto,the_end
ENDIF

427f1205   Jean-Michel Glorian   version 4.2 merged
54
55
loadct,13

e69bf245   Jean-Philippe Bernard   improved
56
57
IF keyword_set(model) THEN BEGIN
  use_model=strupcase(model)
427f1205   Jean-Michel Glorian   version 4.2 merged
58
ENDIF ELSE BEGIN
e69bf245   Jean-Philippe Bernard   improved
59
  use_model='COMPIEGNE_ETAL2010'    ;Default is last dustem model
427f1205   Jean-Michel Glorian   version 4.2 merged
60
61
62
ENDELSE

;== This just initializes 
e69bf245   Jean-Philippe Bernard   improved
63
dustem_init,model=use_model
427f1205   Jean-Michel Glorian   version 4.2 merged
64
65
66
!dustem_verbose=1
!dustem_show_plot=1

3dd007df   Jean-Philippe Bernard   added png plot op...
67
68
69
70
IF keyword_set(png) THEN BEGIN
  dir_png=!dustem_dat+'/Figures/'
  force_mkdir,dir_png
ENDIF
9707968f   Jean-Philippe Bernard   added postscript ...
71
72
73
74
IF keyword_set(postcript) THEN BEGIN
  dir_ps=!dustem_dat+'/Figures/'
  force_mkdir,dir_ps
ENDIF
3dd007df   Jean-Philippe Bernard   added png plot op...
75

427f1205   Jean-Michel Glorian   version 4.2 merged
76
77
78
79
80
81
IF not keyword_set(dir) THEN BEGIN
;  CASE getenv('DUSTEM_WHICH') OF
  CASE !dustem_which OF
    'DESERT':dir='DESERT_POST_ISO_MORE/'
    'COMPIEGNE': dir='MC_DAT/'
    'VERSTRAETE': dir='d_3.5/'
4750086c   Ilyes Choubani   nouvelle philosph...
82
    'VERSTRAETE': dir='LV_DAT/' 
908d12ff   Jean-Philippe Bernard   fixed path
83
84
    ;'WEB3p8': dir_in='dustem3.8_web/' ; this is the original 
    'WEB3p8': dir_in=!dustem_soft_dir ; I changed this 
427f1205   Jean-Michel Glorian   version 4.2 merged
85
86
87
88
89
90
91
92
    ELSE: dir='les_DAT/'
  ENDCASE
ENDIF
;== This is the input directory selected for Dustem
;dir_in=getenv('DUSTEM_SOFT_DIR')+'/src/'+dir
;dir_in=!dustem_soft_dir+'/src/'+dir
;== The following structure contains the inputs to the model
st_model=dustem_read_all(dir_in)
e69bf245   Jean-Philippe Bernard   improved
93
;help,st_model,/str
427f1205   Jean-Michel Glorian   version 4.2 merged
94
95
96
97
98

;=== You can here modify the model inputs
;=== e.g.
;stop
;st_model.G0=2.
e69bf245   Jean-Philippe Bernard   improved
99
100
101
102
;===== This below is to test spinning. 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
427f1205   Jean-Michel Glorian   version 4.2 merged
103
104

;== The following line writes inputs to the Fortran
427f1205   Jean-Michel Glorian   version 4.2 merged
105
dustem_write_all,st_model,!dustem_dat
9ccf7615   Jean-Philippe Bernard   modified to fit u...
106
;== This runs the Fortran. The ouput structure contains the results
427f1205   Jean-Michel Glorian   version 4.2 merged
107
st=dustem_run()
9ccf7615   Jean-Philippe Bernard   modified to fit u...
108
109
110
111
112
113
114
115
116
117
118
;== 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)

b36e1e5e   Jean-Philippe Bernard   added png plot op...
119
;== The following plots the resulting emission SED
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
120
121
win=0L
window,win & win=win+2
e69bf245   Jean-Philippe Bernard   improved
122
123
124
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)')
666cba76   Jean-Philippe Bernard   cleaned the code
125
tit='DUSTEMWrapper Emitted Intensity '+use_model
e69bf245   Jean-Philippe Bernard   improved
126
127
yr=[1e-11,6.e-7]
xr=[1,5e3]
26361fb3   Jean-Philippe Bernard   improved
128
dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
9707968f   Jean-Philippe Bernard   added postscript ...
129
130
131
132
133
134
135
136
137
138
IF keyword_set(postcript) THEN BEGIN
  file_ps=dir_ps+'Last_dustem_run_readme_nuinuem.ps'
  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
ENDIF
b36e1e5e   Jean-Philippe Bernard   added png plot op...
139
140

;== The following plots the resulting extinction
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
141
window,win & win=win+1
e69bf245   Jean-Philippe Bernard   improved
142
143
144
145
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)')
666cba76   Jean-Philippe Bernard   cleaned the code
146
tit='DUSTEMWrapper extinction '+use_model
e69bf245   Jean-Philippe Bernard   improved
147
dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
9707968f   Jean-Philippe Bernard   added postscript ...
148
149
150
151
152
153
154
155
156
157
IF keyword_set(postcript) THEN BEGIN
  file_ps=dir_ps+'Last_dustem_run_readme_extinction.ps'
  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
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
158

b36e1e5e   Jean-Philippe Bernard   added png plot op...
159
IF keyword_set(png) THEN BEGIN
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
160
161
162
163
164
  win=10L
  window,win ;& win=win+2
  file_png=dir_png+'Last_dustem_run_readme_nuinuem.png'
  xtit=textoidl('\lambda (\mum)')
  ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
666cba76   Jean-Philippe Bernard   cleaned the code
165
  tit='DUSTEMWrapper Emitted Intensity '+use_model
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
166
167
168
  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
b36e1e5e   Jean-Philippe Bernard   added png plot op...
169
170
  write_png,file_png,tvrd(/true)
  message,'Wrote '+file_png,/info
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
171
172
173
174
175
176
  ;=====
  file_png=dir_png+'Last_dustem_run_readme_extinction.png'
  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)')
666cba76   Jean-Philippe Bernard   cleaned the code
177
  tit='DUSTEMWrapper extinction '+use_model
0939ca0c   Jean-Philippe Bernard   fixed png issue w...
178
179
180
  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
b36e1e5e   Jean-Philippe Bernard   added png plot op...
181
ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
182
183
184
185

the_end:

END