Blame view

src/idl/dustem_run_example.pro 7.02 KB
e93c2314   Annie Hughes   cleaned up for tuto
1
2
3
4
PRO dustem_run_example, model $
                        ,show=show $
                        ,postscript=postscript $
                        ,help=help
9ebef1db   Jean-Philippe Bernard   First commit
5
6
7

;+
; NAME:
3583bcca   Annie Hughes   bug fix
8
;    dustem_run_example
bff3067a   Annie Hughes   inline help
9
;
9ebef1db   Jean-Philippe Bernard   First commit
10
; PURPOSE:
80eb3ca5   Annie Hughes   clean up
11
;    This is an example of how to run the DustEM fortran code using DustEMWrap
bff3067a   Annie Hughes   inline help
12
;
9ebef1db   Jean-Philippe Bernard   First commit
13
; CATEGORY:
80eb3ca5   Annie Hughes   clean up
14
;    DustEMWrap, Distributed, High-Level, User Example
bff3067a   Annie Hughes   inline help
15
;
9ebef1db   Jean-Philippe Bernard   First commit
16
; CALLING SEQUENCE:
e93c2314   Annie Hughes   cleaned up for tuto
17
;    dustem_run_example,model,show=show,postscript=postscript,help=help
bff3067a   Annie Hughes   inline help
18
;
9ebef1db   Jean-Philippe Bernard   First commit
19
; INPUTS:
6735604d   Annie Hughes   making FITS read ...
20
21
22
;    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.
bff3067a   Annie Hughes   inline help
23
;
e93c2314   Annie Hughes   cleaned up for tuto
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; OPTIONAL INPUT PARAMETERS:
;       show = vector specifying the type of plot(s) to show. Possible
;       values (for all dust models) are
;       ["emis", "extuv", "extir", "alb", "sdist","rfield"]
;       Additionally, for the G17_MODEL?s with polarisation, you can specify
;        [ "polext", "polsed", "align"]
;       "emis" -- Stokes I SED in emission predicted by the model
;       "extuv" -- Extinction in the UV predicted by the model
;       "extir" -- Extinction in the IR predicted by the model
;       "alb" -- Albedo of the grain types
;       "sdist" -- Size distribution of the grain types
;       "rfield" -- Dust-heating radiation field
;       "polsed" -- Polarised intensity SED predicted by the model
;       "polext" -- Polarised extinction predicted by the model
;       "align" -- Grain alignment fraction predicted by the model
;       "all" -- All plots appropriate to the model  
bff3067a   Annie Hughes   inline help
40
;
e93c2314   Annie Hughes   cleaned up for tuto
41
42
; OUTPUTS:
;    Plots
bff3067a   Annie Hughes   inline help
43
;
e93c2314   Annie Hughes   cleaned up for tuto
44
45
; OPTIONAL OUTPUT PARAMETERS:
;    None
bff3067a   Annie Hughes   inline help
46
;
e93c2314   Annie Hughes   cleaned up for tuto
47
48
49
; ACCEPTED KEY-WORDS:
;    postscript = on/off if set, plots are saved as postscript in the
;                 current working directory (and not shown on screen)
80eb3ca5   Annie Hughes   clean up
50
;    help      = if set, print this help
bff3067a   Annie Hughes   inline help
51
;
9ebef1db   Jean-Philippe Bernard   First commit
52
53
; COMMON BLOCKS:
;    None
bff3067a   Annie Hughes   inline help
54
;
9ebef1db   Jean-Philippe Bernard   First commit
55
56
; SIDE EFFECTS:
;    None
bff3067a   Annie Hughes   inline help
57
;
9ebef1db   Jean-Philippe Bernard   First commit
58
; RESTRICTIONS:
80eb3ca5   Annie Hughes   clean up
59
60
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
bff3067a   Annie Hughes   inline help
61
;
9ebef1db   Jean-Philippe Bernard   First commit
62
63
; PROCEDURE:
;    None
bff3067a   Annie Hughes   inline help
64
;
9ebef1db   Jean-Philippe Bernard   First commit
65
; EXAMPLES
e93c2314   Annie Hughes   cleaned up for tuto
66
;    dustem_run_example,'DBP90',show="all",/post
bff3067a   Annie Hughes   inline help
67
;
9ebef1db   Jean-Philippe Bernard   First commit
68
; MODIFICATION HISTORY:
80eb3ca5   Annie Hughes   clean up
69
70
71
;    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
72
73
74
;-

IF keyword_set(help) THEN BEGIN
3583bcca   Annie Hughes   bug fix
75
  doc_library,'dustem_run_example'
9ebef1db   Jean-Philippe Bernard   First commit
76
77
78
  goto,the_end
ENDIF

e93c2314   Annie Hughes   cleaned up for tuto
79
80
IF keyword_set(show) THEN BEGIN
  use_show=show
9ebef1db   Jean-Philippe Bernard   First commit
81
ENDIF ELSE BEGIN
e93c2314   Annie Hughes   cleaned up for tuto
82
  use_show=['all']    ;Default is to show everything
9ebef1db   Jean-Philippe Bernard   First commit
83
84
ENDELSE

6735604d   Annie Hughes   making FITS read ...
85
86
87
88
exists=dustem_test_model_exists(model)
if exists ne 1 then $
   message,'Unknown dust model'
polct=dustem_test_model_exists(model,/pol,/silent)
e93c2314   Annie Hughes   cleaned up for tuto
89

80eb3ca5   Annie Hughes   clean up
90
;== INITIALISE DUSTEM
e93c2314   Annie Hughes   cleaned up for tuto
91
dustem_init,model=model
9ebef1db   Jean-Philippe Bernard   First commit
92
93
!dustem_verbose=1
!dustem_show_plot=1
e93c2314   Annie Hughes   cleaned up for tuto
94
95
!dustem_which='RELEASE'
dir_in=!dustem_soft_dir  
9ebef1db   Jean-Philippe Bernard   First commit
96

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

b125205a   Annie Hughes   updated examples ...
100

e93c2314   Annie Hughes   cleaned up for tuto
101
102
103
104
105
106
107
;=== You could modify the model inputs here by directly editing the values in the
;=== st_model structure. To inspect contents, type IDL> help,st_model,/str
;=== e.g.
;=== st_model.G0=2.0 ; change the default value of the ISRF intensity used by DustEM
;=== st_model.isrf.isrf=sqrt(st_model.isrf.isrf) ; change the shape of ISRF
;=== st_model.grains[0].mdust_O_mh=5.e-4 ; change the abundance of grain[0]
;=== st_model.grains[1].type_keywords='plaw' ; change the size distribution description of grain[1]
80eb3ca5   Annie Hughes   clean up
108

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

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

e93c2314   Annie Hughes   cleaned up for tuto
116
117
known_plots=["emis", "extuv", "extir", "alb", "sdist"]
if polct gt 0 then known_plots=["emis", "extuv", "extir", "alb", "sdist","polext", "polsed", "align"]
66c68b4a   Annie Hughes   not sure
118
119
if n_elements(use_show) eq 1 then $
   if strupcase(use_show) eq "ALL" then use_show=[known_plots,"rfield"]
e93c2314   Annie Hughes   cleaned up for tuto
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

;== The following lines generate plots that show the outputs of the fortran.
;=== For this release (V2.0), we use the old method (dustem_show_fortran) to
;=== access model quantities.
;=== This method will be deprecated in a future release and plots will be
;=== constructed directly from the st and st_model structures.
match,known_plots,use_show,a,b
if total(a,/nan) ne -1 and keyword_set(postscript) then $
   dustem_show_fortran,model=model,st=st,show=known_plots[a],hard=1,tit="DustEM_run_example "+model+" :"
if total(a,/nan) ne -1 and not keyword_set(postscript) then $
   dustem_show_fortran,model=model,st=st,show=known_plots[a],tit="DustEM_run_example "+model+" :"

;== The following lines generate a plot of the ISRF using the
;== st_model structure. For illustration purposes.
use_win=12
rfield_plot=["rfield"]
match,rfield_plot,use_show,a,b
if total(a,/nan) ne -1 then begin
      xtit=textoidl('\lambda (\mum)')
      ytit=textoidl('log ISRF [4 \pi I_\nu (erg/cm^2/s/Hz)]')
6735604d   Annie Hughes   making FITS read ...
140
      tit='DustEM_run_example : ISRF'
e93c2314   Annie Hughes   cleaned up for tuto
141
142
143
      yr=[min(st_model.isrf.isrf),5.*max(st_model.isrf.isrf)]
      xr=[min(st_model.isrf.lambisrf),max(st_model.isrf.lambisrf)]
   IF not keyword_set(postscript) THEN BEGIN
6735604d   Annie Hughes   making FITS read ...
144
      window,use_win,xs=600,ys=400,tit='DustEM-run_example: ISRF '+strtrim(use_win,2) & use_win=use_win+2
e93c2314   Annie Hughes   cleaned up for tuto
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
      cgplot,st_model.isrf.lambisrf,st_model.isrf.isrf $
             ,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog $
             ,title=tit,xtit=xtit,ytit=ytit,color=cgcolor('black'),/nodata
      oplot,st_model.isrf.lambisrf,st_model.isrf.isrf,col=cgcolor('black')
   END ELSE BEGIN
      file_ps="isrf.ps"
      previous_device=!d.name
       !y.thick = 5
       !x.thick = 5
       !p.thick = 5
       !p.charsize = 1.3
       !p.charthick = 5
       !x.ticklen = 0.04
      set_plot,'PS'
      device,filename=file_ps,/portrait,/color
      cgplot,st_model.isrf.lambisrf,st_model.isrf.isrf $
             ,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog $
             ,title=tit,xtit=xtit,ytit=ytit,color=cgcolor('black'),/nodata
      oplot,st_model.isrf.lambisrf,st_model.isrf.isrf ,col=cgcolor('black')
      device,/close
      !y.thick = 0
      !x.thick = 0
      !p.thick = 0
      !p.charsize = 1
      !p.charthick = 0
      !x.ticklen = 0.02
      set_plot,previous_device
   END
end

goto,the_end     

;;== The following lines plot the resulting SED (emission)
;;== using st/st_model structure and a dedicated plotting function 
;;== Prototype for future releases.
;; win=0L
;; window,win & win=win+2
;; xtit=textoidl('\lambda (\mum)')
;; ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
;; tit='DustEMWrap Emission: '+model
;; 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,post=postscript

;;== The following plots the resulting SED (extinction)
;;== using st/st_model structure and a dedicated plotting function 
;;== Prototype for future releases.
;; 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)')
;; tit='DustEMWrap extinction: '+model
;; dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit,post=postscript
9ebef1db   Jean-Philippe Bernard   First commit
199
200

the_end:
e431104b   Annie Hughes   general updates f...
201
message,'Finished dustem_run_example',/info
9ebef1db   Jean-Philippe Bernard   First commit
202
203

END