Commit 80eb3ca5370b3db15291c016138d20c3d2d47bc0

Authored by Annie Hughes
1 parent d7efe307
Exists in master

clean up

Showing 1 changed file with 90 additions and 64 deletions   Show diff stats
src/idl/dustem_run_example.pro 100644 → 100755
1   -PRO dustem_run_example,model=model,help=help,plot_it=plot_it,png=png,postcript=postcript
  1 +PRO dustem_run_readme,model=model $
  2 + ,png=png $
  3 + ,postscript=postscript $
  4 + ,help=help
2 5  
3 6 ;+
4 7 ; NAME:
5   -; dustem_run_example
  8 +; dustem_run_readme
6 9 ; PURPOSE:
7   -; This is an example of how to run dustem SEDs with the dustem wrapper.
  10 +; This is an example of how to run the DustEM fortran code using DustEMWrap
8 11 ; CATEGORY:
9   -; Dustem
  12 +; DustEMWrap, Distributed, High-Level, User Example
10 13 ; CALLING SEQUENCE:
11   -; dustem_run_example,model=model,help=help,/postcript,/help,/plot_it
  14 +; dustem_run_readme,model=model,postscript=postscript,png=png,help=help
12 15 ; INPUTS:
13 16 ; None
14 17 ; OPTIONAL INPUT PARAMETERS:
... ... @@ -18,32 +21,43 @@ PRO dustem_run_example,model=model,help=help,plot_it=plot_it,png=png,postcript=p
18 21 ; OPTIONAL OUTPUT PARAMETERS:
19 22 ; None
20 23 ; ACCEPTED KEY-WORDS:
21   -; model = Selects one of the dust mixture used by dustem
22   -; 'MC10' from Compiegne et al 2010 (default)
23   -; 'DBP90' from Desert et al 1990
24   -; 'DL01' from Draine & Li 2001
25   -; 'DL07' from Draine & Li 2007
26   -; postcript = if set, plot is done in DUSTEM/Docs/Figures/Last_dustem_fit.ps
27   -; help = If set, print this help
  24 +; model = specifies the interstellar dust mixture used by DustEM
  25 +; 'MC10' model from Compiegne et al 2010 (default)
  26 +; 'DBP90' model from Desert et al 1990
  27 +; 'DL01' model from Draine & Li 2001
  28 +; 'WD01_RV5p5B' model from Weingartner & Draine 2002 with Rv=5.5
  29 +; 'DL07' model from Draine & Li 2007
  30 +; 'J13' model from Jones et al 2013, as updated in
  31 +; Koehler et al 2014
  32 +; 'G17_ModelA' model A from Guillet et al (2018). Includes
  33 +; polarisation. See Tables 2 and 3 of that paper for details.
  34 +; 'G17_ModelB' model B from Guillet et al (2018)
  35 +; 'G17_ModelC' model C from Guillet et al (2018)
  36 +; 'G17_ModelD' model A from Guillet et al (2018)
  37 +; postscript = if set, final plot is saved as postscript in the
  38 +; current working directory
  39 +; png = if set, final plot is saved as png in the
  40 +; current working directory
  41 +; help = if set, print this help
28 42 ; COMMON BLOCKS:
29 43 ; None
30 44 ; SIDE EFFECTS:
31 45 ; None
32 46 ; RESTRICTIONS:
33   -; The dustem fortran code must be installed
34   -; The dustem idl wrapper must be installed
  47 +; The DustEM fortran code must be installed
  48 +; The DustEMWrap IDL code must be installed
35 49 ; PROCEDURE:
36 50 ; None
37 51 ; EXAMPLES
38   -; dustem_run_readme,model='DBP90'
  52 +; dustem_run_readme,model='DBP90',png='test_dbp90.png'
39 53 ; MODIFICATION HISTORY:
40   -; Written by J.P. Bernard April 1st 2011
41   -; see evolution details on the dustem cvs maintained at IRAP
42   -; Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
  54 +; Written JPB Apr-2011
  55 +; Evolution details on the DustEMWrap gitlab.
  56 +; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
43 57 ;-
44 58  
45 59 IF keyword_set(help) THEN BEGIN
46   - doc_library,'dustem_run_example'
  60 + doc_library,'dustem_run_readme'
47 61 goto,the_end
48 62 ENDIF
49 63  
... ... @@ -52,44 +66,53 @@ loadct,13
52 66 IF keyword_set(model) THEN BEGIN
53 67 use_model=strupcase(model)
54 68 ENDIF ELSE BEGIN
55   - use_model='MC10' ;Default is last dustem model
  69 + use_model='MC10' ;Default is the Compiegne et al 2010 model
56 70 ENDELSE
57 71  
58   -;== This just initializes
  72 +;== INITIALISE DUSTEM
59 73 dustem_init,model=use_model
60 74 !dustem_verbose=1
61 75 !dustem_show_plot=1
62 76  
63   -IF keyword_set(png) THEN BEGIN
64   - dir_png=!dustem_dat+'/Figures/'
65   - force_mkdir,dir_png
66   -ENDIF
67   -IF keyword_set(postcript) THEN BEGIN
68   - dir_ps=!dustem_dat+'/Figures/'
69   - force_mkdir,dir_ps
70   -ENDIF
71   -
72   -IF not keyword_set(dir) THEN BEGIN
73   -; CASE getenv('DUSTEM_WHICH') OF
74   - CASE !dustem_which OF
75   - 'DESERT':dir='DESERT_POST_ISO_MORE/'
76   - 'COMPIEGNE': dir='MC_DAT/'
77   - 'VERSTRAETE': dir='d_3.5/'
78   - 'VERSTRAETE': dir='LV_DAT/'
79   - 'WEB3p8': dir_in=!dustem_soft_dir ; I changed this
80   - 'RELEASE': dir_in=!dustem_soft_dir ; I changed this
81   - ELSE: dir='les_DAT/'
82   - ENDCASE
83   -ENDIF
  77 +CASE !dustem_which OF
  78 + 'DESERT': begin
  79 + dir='DESERT_POST_ISO_MORE/'
  80 + message,'DESERT version disabled for this routine',/info
  81 + end
  82 + 'COMPIEGNE': begin
  83 + dir='MC_DAT/'
  84 + message,'COMPIEGNE version disabled for this routine',/info
  85 + end
  86 + 'VERSTRAETE': begin
  87 + dir='LV_DAT/'
  88 + message,'VERSTRAETE version disabled for this routine',/info
  89 + end
  90 + 'RELEASE': dir_in=!dustem_soft_dir
  91 + ELSE: dir_in=!dustem_soft_dir
  92 + ;dir='les_DAT/'
  93 +ENDCASE
84 94  
85   -;== The following structure contains the inputs to the model
  95 +;== Fill the following structure contains with default inputs to the model
86 96 st_model=dustem_read_all(dir_in)
87 97 ;help,st_model,/str
88 98  
89   -;== The following line writes inputs to the Fortran
  99 +;=== You can modify the model inputs by changing the values in the
  100 +;=== st_model structure
  101 +
  102 +;=== e.g. modify the default value of the ISRF intensity used by DustEM
  103 +;st_model.G0=2.
  104 +
  105 +;===== e.g. modify keywords related to spinning dust. Does not work with DBP90 !
  106 +;st_model.grains[0].type_keywords='logn-chrg-spin'
  107 +;st_model.gas.NH=1.e2
  108 +;st_model.gas.Tgas=1.e5
  109 +
  110 +;== The following line saves the modified inputs for use by the Fortran
90 111 dustem_write_all,st_model,!dustem_dat
91   -;== This runs the Fortran. The ouput structure contains the results
  112 +
  113 +;== The following line runs the Fortran. The ouput structure st contains the results
92 114 st=dustem_run()
  115 +
93 116 ;== Optionaly, this creates an SED to be overploted
94 117 ;stop
95 118 ;filters=['IRAS1','IRAS4']
... ... @@ -101,37 +124,38 @@ st=dustem_run()
101 124 ;stop
102 125 ;stt=dustem_set_data(sed=sed)
103 126  
104   -;== The following plots the resulting emission SED
  127 +;== The following lines plot the resulting SED (emission)
105 128 win=0L
106 129 window,win & win=win+2
107 130 xtit=textoidl('\lambda (\mum)')
108 131 ;=== same plot as in Compiegne et al. 2010
109 132 ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
110   -tit='DUSTEMWrapper Emitted Intensity '+use_model
  133 +tit='DustEMWrap Emitted Intensity '+use_model
111 134 yr=[1e-11,6.e-7]
112 135 xr=[1,5e3]
113 136 dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
114   -IF keyword_set(postcript) THEN BEGIN
115   - file_ps=dir_ps+'Last_dustem_run_readme_nuinuem.ps'
116   - previous_device=!d.name
117   - set_plot,'PS'
118   - device,filename=file_ps
119   - dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
120   - device,/close
121   - set_plot,previous_device
122   - message,'Wrote '+file_ps,/continue
  137 +IF keyword_set(postscript) THEN BEGIN
  138 + dir_ps='./'
  139 + file_ps=dir_ps+postscript
  140 + previous_device=!d.name
  141 + set_plot,'PS'
  142 + device,filename=file_ps
  143 + dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
  144 + device,/close
  145 + set_plot,previous_device
  146 + message,'Wrote '+file_ps,/continue
123 147 ENDIF
124 148  
125   -;== The following plots the resulting extinction
  149 +;== The following plots the resulting SED (extinction)
126 150 window,win & win=win+1
127 151 yr=[0,2.5] ;range of 1/lambda
128 152 xr=[1,10] ;range of sigma
129 153 xtit=textoidl('1/\lambda (\mum^{-1})')
130 154 ytit=textoidl('\sigma_{ext} (1e-21 cm^2/H)')
131   -tit='DUSTEMWrapper extinction '+use_model
  155 +tit='DustEMWrap extinction '+use_model
132 156 dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
133   -IF keyword_set(postcript) THEN BEGIN
134   - file_ps=dir_ps+'Last_dustem_run_readme_extinction.ps'
  157 +IF keyword_set(postscript) THEN BEGIN
  158 + file_ps=dir_ps+file_basename(file_ps,'.ps')+'_extinction.ps'
135 159 previous_device=!d.name
136 160 set_plot,'PS'
137 161 device,filename=file_ps
... ... @@ -144,22 +168,24 @@ ENDIF
144 168 IF keyword_set(png) THEN BEGIN
145 169 win=10L
146 170 window,win ;& win=win+2
147   - file_png=dir_png+'Last_dustem_run_readme_nuinuem.png'
  171 + dir_png='./'
  172 + file_png=dir_png+png
148 173 xtit=textoidl('\lambda (\mum)')
149 174 ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
150   - tit='DUSTEMWrapper Emitted Intensity '+use_model
  175 + tit='DustEMWrap Emitted Intensity '+use_model
151 176 yr=[1e-11,6.e-7]
152 177 xr=[1,5e3]
153 178 dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
154 179 write_png,file_png,tvrd(/true)
155 180 message,'Wrote '+file_png,/info
156 181 ;=====
157   - file_png=dir_png+'Last_dustem_run_readme_extinction.png'
  182 + file_png=dir_png+file_basename(file_png,'.png')+'_extinction.png'
  183 +
158 184 yr=[0,2.5] ;range of 1/lambda
159 185 xr=[1,10] ;range of sigma
160 186 xtit=textoidl('1/\lambda (\mum^{-1})')
161 187 ytit=textoidl('\sigma_{ext} (1e-21 cm^2/H)')
162   - tit='DUSTEMWrapper extinction '+use_model
  188 + tit='DustEMWrap extinction '+use_model
163 189 dustem_plot_extinction,st,st_model,xr=xr,yr=yr,/xsty,/ysty,xtit=xtit,ytit=ytit,title=tit
164 190 write_png,file_png ,tvrd(/true),/verbose
165 191 message,'Wrote '+file_png,/info
... ...