Commit 6412862797fd2fccec4c6f51e51ee1b961d71776

Authored by Annie Hughes
1 parent 74611862
Exists in master

Copy without substantive changes from dustem_read_all_web3p8

Showing 1 changed file with 225 additions and 0 deletions   Show diff stats
src/idl/dustem_read_all_release.pro 0 → 100755
... ... @@ -0,0 +1,225 @@
  1 +FUNCTION dustem_read_all_release,dir_in,silent=silent,help=help,kwords=kwords
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_read_all_release
  6 +; PURPOSE:
  7 +; Reads all Dustem input data, as of the web available dustem fortran version
  8 +; CATEGORY:
  9 +; Dustem
  10 +; CALLING SEQUENCE:
  11 +; st=dustem_read_all_release(dir_in[,/silent])
  12 +; INPUTS:
  13 +; dir_in: input directory
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; None
  16 +; OUTPUTS:
  17 +; None
  18 +; OPTIONAL OUTPUT PARAMETERS:
  19 +; None
  20 +; ACCEPTED KEY-WORDS:
  21 +; help = If set, print this help
  22 +; sielnt = If set, keep silent
  23 +; COMMON BLOCKS:
  24 +; None
  25 +; SIDE EFFECTS:
  26 +; None
  27 +; RESTRICTIONS:
  28 +; The dustem idl wrapper must be installed
  29 +; PROCEDURE:
  30 +; None
  31 +; EXAMPLES
  32 +;
  33 +; MODIFICATION HISTORY:
  34 +; Written by J.-Ph. Bernard
  35 +; see evolution details on the dustem cvs maintained at CESR
  36 +; Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
  37 +;-
  38 +
  39 +IF keyword_set(help) THEN BEGIN
  40 + doc_library,'dustem_read_all_release'
  41 + st=0
  42 + goto,the_end
  43 +ENDIF
  44 +
  45 +dir_in_dat=dir_in+'data/'
  46 +dir_in_qabs=dir_in+'oprop/'
  47 +dir_in_capa=dir_in+'hcap/'
  48 +
  49 +file=dir_in_dat+(*!dustem_inputs).grain
  50 +;st_grains=dustem_read_grain(file,silent=silent)
  51 +st_grains=dustem_read_grain(file,silent=silent,key_str=key_str,G0=G0)
  52 +Ngrains=n_elements(st_grains)
  53 +;stop
  54 +
  55 +file=dir_in_dat+'ISRF.DAT'
  56 +st_isrf=dustem_read_isrf(file,silent=silent,Nisrf=Nisrf)
  57 +
  58 +;stop
  59 +
  60 +file=dir_in_dat+'GAS.DAT'
  61 +st_gas=dustem_read_gas(file,silent=silent)
  62 +
  63 +;=== Read Qabs
  64 +
  65 +st_qabs=ptrarr(Ngrains)
  66 +FOR i=0L,Ngrains-1 DO BEGIN
  67 + read_densities=0
  68 + IF st_grains[i].rho LE 0 THEN read_densities=1
  69 + Qabs_file=dir_in_qabs+'Q_'+st_grains(i).grain_type+'.DAT'
  70 + st=dustem_read_qabs_lv(Qabs_file,silent=silent,read_densities=read_densities)
  71 + st_qabs(i)=ptr_new(st)
  72 +ENDFOR
  73 +
  74 +;=== Read heat capacities
  75 +st_calor=ptrarr(Ngrains)
  76 +FOR i=0L,Ngrains-1 DO BEGIN
  77 + Calor_file=dir_in_capa+'C_'+st_grains(i).grain_type+'.DAT'
  78 + st=dustem_read_calor_lv(Calor_file,silent=silent)
  79 + st_calor(i)=ptr_new(st)
  80 +ENDFOR
  81 +
  82 +;=== Read lambda
  83 +file=dir_in_qabs+'LAMBDA.DAT'
  84 +st_lambda=dustem_read_lambda(file,silent=silent)
  85 +
  86 +if keyword_set(kwords) then begin
  87 + FOR i=0L,n_elements(kwords)-1 DO BEGIN
  88 + st_grains(i).type_keywords=kwords(i)
  89 + ENDFOR
  90 +endif
  91 +
  92 +;=== Read size distribution files
  93 +st_size=ptrarr(Ngrains)
  94 +FOR i=0L,Ngrains-1 DO BEGIN
  95 + IF stregex(st_grains(i).type_keywords, 'size', /bool) THEN BEGIN
  96 + Size_file=dir_in_dat+'SIZE_'+st_grains(i).grain_type+'.DAT'
  97 + st=dustem_read_size(Size_file,silent=silent)
  98 + st_size(i)=ptr_new(st)
  99 + ENDIF ELSE BEGIN
  100 + st_size(i) = ptr_new()
  101 + ENDELSE
  102 +ENDFOR
  103 +
  104 +;stop
  105 +;=== Read MIX files
  106 +st_mix = ptrarr(Ngrains)
  107 +FOR i=0L,Ngrains-1 DO BEGIN
  108 + IF stregex(st_grains(i).type_keywords, 'mix', /bool) THEN BEGIN
  109 + Mix_file=dir_in_dat+'MIX_'+st_grains(i).grain_type+'.DAT'
  110 + st=dustem_read_mix(Mix_file,silent=silent)
  111 + st_mix(i)=ptr_new(st)
  112 + ENDIF ELSE BEGIN
  113 + st_mix(i)=ptr_new()
  114 + ENDELSE
  115 +ENDFOR
  116 +
  117 +;=== Read CHRG files
  118 +st_chrg = ptrarr(Ngrains)
  119 +FOR i=0L,Ngrains-1 DO BEGIN
  120 + IF stregex(st_grains(i).type_keywords, 'chrg', /bool) THEN BEGIN
  121 + chrg_file=dir_in_dat+'CHRG_'+st_grains(i).grain_type+'.DAT'
  122 + st=dustem_read_chrg(chrg_file,silent=silent)
  123 + st_chrg(i)=ptr_new(st)
  124 + ENDIF ELSE BEGIN
  125 + st_chrg(i)=ptr_new()
  126 + ENDELSE
  127 +ENDFOR
  128 +
  129 +;=== Read SPIN files
  130 +st_spin = ptrarr(Ngrains)
  131 +FOR i=0L,Ngrains-1 DO BEGIN
  132 + IF stregex(st_grains(i).type_keywords, 'spin', /bool) THEN BEGIN
  133 + chrg_file=dir_in_dat+'SPIN_'+st_grains[i].grain_type+'.DAT'
  134 + st=dustem_read_spin(chrg_file,silent=silent)
  135 + st_spin[i]=ptr_new(st)
  136 + ENDIF ELSE BEGIN
  137 + st_spin[i]=ptr_new()
  138 + ENDELSE
  139 +ENDFOR
  140 +
  141 +;stop
  142 +
  143 +;=== Read POL and Qabs files
  144 +st_qpol = ptrarr(2,Ngrains)
  145 +st_qH = ptrarr(2,Ngrains)
  146 +st_qcirc = ptrarr(Ngrains)
  147 +
  148 +;=== JPB : this organisation may not be optimal
  149 +st_pol={file:'',qpol:st_qpol,qH:st_qH,qcirc:st_qcirc}
  150 +;st_pol = replicate(one_st,Ngrains)
  151 +
  152 +IF !run_pol THEN BEGIN
  153 + st_align=dustem_read_align(dir_in_dat,st_grains,silent=silent)
  154 + FOR i=0L,Ngrains-1 DO BEGIN
  155 + i_alig = 0
  156 + ;IF stregex(st_grains.grains(i).type_keywords, 'pol', /bool) THEN BEGIN
  157 + IF stregex(st_grains(i).type_keywords, 'pol', /bool) THEN BEGIN
  158 + IF not stregex(st_align.keywords, 'rrf', /bool) THEN BEGIN
  159 + FOR i_axis = 1, 2 DO BEGIN
  160 + ;Q_file=dir_in_qabs+'Q'+strtrim(i_axis,2)+'_'+st_grains.grains(i).grain_type+'.DAT'
  161 + Q_file=dir_in_qabs+'Q'+strtrim(i_axis,2)+'_'+st_grains(i).grain_type+'.DAT'
  162 + st=dustem_read_qabs_lv(Q_file,silent=silent)
  163 + st_qpol(i_axis-1,i)=ptr_new(st)
  164 + ENDFOR
  165 + ENDIF
  166 +
  167 + IF (st_align.anisG0 > 0) THEN BEGIN
  168 + FOR i_axis = 1, 2 DO BEGIN
  169 + ;Q_file=dir_in_qabs+'QH'+strtrim(i_axis,2)+'_'+st_grains.grains(i).grain_type+'.DAT'
  170 + Q_file=dir_in_qabs+'QH'+strtrim(i_axis,2)+'_'+st_grains(i).grain_type+'.DAT'
  171 + st=dustem_read_qabs_lv(Q_file,silent=silent)
  172 + st_qH(i_axis-1,i)=ptr_new(st)
  173 + ENDFOR
  174 + ENDIF
  175 +
  176 + IF stregex(st_align.keywords, 'circ', /bool) THEN BEGIN
  177 + ;Q_file=dir_in_qabs+'Qc_'+st_grains.grains(i).grain_type+'.DAT'
  178 + Q_file=dir_in_qabs+'Qc_'+st_grains(i).grain_type+'.DAT'
  179 + st=dustem_read_qabs_lv(Q_file,silent=silent)
  180 + st_qcirc(i)=ptr_new(st)
  181 + ENDIF
  182 + ENDIF ELSE BEGIN
  183 + st_qpol(0:1,i)=ptr_new()
  184 + st_qH(0:1,i)=ptr_new()
  185 + st_qcirc(i)=ptr_new()
  186 + ENDELSE
  187 + ENDFOR
  188 + st_pol={qpol:st_qpol,qH:st_qH,qcirc:st_qcirc}
  189 +ENDIF
  190 +
  191 +;DP :ADD DTLS
  192 +one_st={file:'',a_dtls:0.,lc:0.,c_delta:0.,vt:0.,Pmu:0.,gamma_e:0.,omega_m:0.,tau_0:0.,V0:0.,Vmin:0.,Vm:0.,ldtresh:0.}
  193 +st_tls = replicate(one_st,Ngrains)
  194 +
  195 +if !run_tls then begin
  196 + FOR i=0L,Ngrains-1 DO BEGIN
  197 + IF stregex(st_grains(i).type_keywords, 'dtls', /bool) THEN BEGIN
  198 + TLS_file='DTLS_'+st_grains.grains(i).grain_type+'.DAT'
  199 + st=dustem_read_tls(dir_in,TLS_file,silent=silent)
  200 + st_tls(i)=st
  201 + ENDIF ELSE BEGIN
  202 + st_tls(i)=one_st
  203 + ENDELSE
  204 + ENDFOR
  205 +ENDIF
  206 +
  207 +;=== This will become !dustem_params - MAYBE THIS WILL NEED TO BE CHANGED FOR THE G0 TREATMENT
  208 +
  209 +;st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains, $
  210 +; isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,pol:st_pol,tls:st_tls}
  211 +;VG Add NH
  212 +if !run_pol then begin
  213 + st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains,isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,align:st_align,qpol:st_qpol,qcirc:st_qcirc,qH:st_qH,tls:st_tls}
  214 +endif else begin
  215 + st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains,isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,tls:st_tls}
  216 +endelse
  217 +
  218 +;stop
  219 +
  220 +the_end:
  221 +
  222 +RETURN,st
  223 +
  224 +END
  225 +
... ...