Commit 56829eab3b4bd2a544712d093fba81d28337475d

Authored by Jean-Philippe Bernard
1 parent a2e70a54
Exists in master

First commit

Showing 1 changed file with 136 additions and 0 deletions   Show diff stats
src/idl/dustem_variational_study_readme.pro 0 → 100644
... ... @@ -0,0 +1,136 @@
  1 +PRO dustem_variational_study_readme,model=model,help=help,png=png,postscript=postscript
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_variational_study_readme
  6 +; PURPOSE:
  7 +; This is an example of how to run a variational study on the dust model parameters with the dustem wrapper.
  8 +; CATEGORY:
  9 +; Dustem
  10 +; CALLING SEQUENCE:
  11 +; dustem_variational_study_readme[,model=][,/help][,/png][,/postscript]
  12 +; INPUTS:
  13 +; None
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; None
  16 +; OUTPUTS:
  17 +; None
  18 +; OPTIONAL OUTPUT PARAMETERS:
  19 +; None
  20 +; ACCEPTED KEY-WORDS:
  21 +; model = Selects one of the dust mixture used by dustem
  22 +; 'COMPIEGNE_ETAL2010' 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 +; postscript = if set, plot is done in DUSTEM/Docs/Figures/Last_dustem_fit.ps
  27 +; help = If set, print this help
  28 +; COMMON BLOCKS:
  29 +; None
  30 +; SIDE EFFECTS:
  31 +; None
  32 +; RESTRICTIONS:
  33 +; The dustem fortran code must be installed
  34 +; The dustem idl wrapper must be installed
  35 +; PROCEDURE:
  36 +; None
  37 +; EXAMPLES
  38 +; dustem_variational_study_readme,model='DBP90',/postscript
  39 +; dustem_variational_study_readme,model='COMPIEGNE_ETAL2010',/postscript
  40 +; MODIFICATION HISTORY:
  41 +; Written by J.P. Bernard July 15 2021
  42 +; see evolution details on the dustem gitlab
  43 +; Contact J.-Ph. Bernard (Jean-Philippe.Bernard@irap.omp.eu) in case of problems.
  44 +;-
  45 +
  46 +;This Readme shows how to run dustem from the wrapper
  47 +
  48 +IF keyword_set(help) THEN BEGIN
  49 + doc_library,'dustem_variational_study_readme'
  50 + goto,the_end
  51 +ENDIF
  52 +
  53 +;loadct,13
  54 +
  55 +IF keyword_set(model) THEN BEGIN
  56 + use_model=strupcase(model)
  57 +ENDIF ELSE BEGIN
  58 + use_model='COMPIEGNE_ETAL2010' ;Default is last dustem model
  59 +ENDELSE
  60 +
  61 +;== This just initializes dustem wrapper
  62 +dustem_init,model=use_model
  63 +!dustem_verbose=1
  64 +!dustem_show_plot=1
  65 +
  66 +IF keyword_set(png) THEN BEGIN
  67 + dir_png=!dustem_dat+'/Figures/'
  68 + force_mkdir,dir_png
  69 +ENDIF
  70 +IF keyword_set(postscript) THEN BEGIN
  71 + dir_ps=!dustem_dat+'/Figures/'
  72 + force_mkdir,dir_ps
  73 +ENDIF
  74 +
  75 +IF not keyword_set(dir) THEN BEGIN
  76 +; CASE getenv('DUSTEM_WHICH') OF
  77 + CASE !dustem_which OF
  78 + 'DESERT':dir='DESERT_POST_ISO_MORE/'
  79 + 'COMPIEGNE': dir='MC_DAT/'
  80 + 'VERSTRAETE': dir='d_3.5/'
  81 + 'VERSTRAETE': dir='LV_DAT/'
  82 + 'WEB3p8': dir_in=!dustem_soft_dir
  83 + ELSE: dir='les_DAT/'
  84 + ENDCASE
  85 +ENDIF
  86 +;== The following structure contains the inputs to the model
  87 +st_model=dustem_read_all(dir_in)
  88 +
  89 +;These are the values of G0 to be explored
  90 +g0s=[1.,2.,5.,10.,100.,1000.]
  91 +n_g0s=n_elements(g0s)
  92 +
  93 +win=0L
  94 +window,win,title='DustemWrap Variational study'
  95 +
  96 +CASE use_model OF
  97 + 'DBP90': pd = ['(*!dustem_params).G0'] ;This is the parameter description of G0 for models without gas parameters
  98 + 'COMPIEGNE_ETAL2010': pd = ['(*!dustem_params).gas.G0'] ;This is the parameter description of G0 for models with gas parameters
  99 + 'AJ13' : pd = ['(*!dustem_params).G0'] ;This is the parameter description of G0 for models without gas parameters
  100 +ENDCASE
  101 +
  102 +FOR i=0L,n_g0s-1 DO BEGIN
  103 + iv = [g0s[i]]
  104 + dustem_init_parinfo,pd,iv
  105 + params=[g0s[i]]
  106 + st=dustem_run(params)
  107 + ;do the plot
  108 + cleanplot
  109 + xtit=textoidl('\lambda (\mum)')
  110 + ;=== same plot as in Compiegne et al. 2010
  111 + ytit=textoidl('\nuI_\nu^{em} (W/m^2/sr for N_H=1.e20 H/cm^2)')
  112 + tit='Dustem Emitted Intensity '+use_model+' G0='+strtrim(g0s[i],2)
  113 + yr=[1e-11,1.e-4]
  114 + xr=[1,5e3]
  115 + ;stop
  116 + dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
  117 + IF keyword_set(postscript) THEN BEGIN
  118 + file_ps=dir_ps+use_model+'_variational_study_nuinuem_G0='+strtrim(g0s[i],2)+'.ps'
  119 + spawn,'rm '+file_ps
  120 + previous_device=!d.name
  121 + set_plot,'PS'
  122 + device,filename=file_ps
  123 + !p.charsize=0.8
  124 + dustem_plot_nuinu_em,st,yr=yr,/ysty,xr=xr,/xsty,/xlog,/ylog,title=tit,xtit=xtit,ytit=ytit
  125 + device,/close
  126 + set_plot,previous_device
  127 + message,'Wrote '+file_ps,/continue
  128 + ENDIF
  129 +
  130 +ENDFOR
  131 +
  132 +;stop
  133 +
  134 +the_end:
  135 +
  136 +END
... ...