dustem_read_all_lv.pro 3.21 KB
FUNCTION dustem_read_all_lv,dir_in,silent=silent,help=help

;+
; NAME:
;   dustem_read_all_lv
;
; PURPOSE:
;  Manages reading of information from .DAT files used by the
;  LV version of the fortran
;
; CATEGORY:
;    DustEMWrap, Distributed, MidLevel, Initialization
;
; CALLING SEQUENCE:
;   st=dustem_read_all_lv(dir_in)
;
; INPUTS:
;    dir_in  : directory where input files are found
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    st : dustem data structure
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    help     : writes this help
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:  
;
; EXAMPLES:
;
; MODIFICATION HISTORY:
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_read_all_lv'
  st=0.
  goto,the_end
ENDIF


  
dir_in_dat=dir_in+'/les_DAT/'
dir_in_qabs=dir_in+'/les_QABS/'
dir_in_capa=dir_in+'/les_CAPA/'

;stop

;== note: the output keywords are set only for LV version
file=dir_in_dat+'GRAIN.DAT'
st_temp=dustem_read_grain(file,silent=silent,key_str=key_str,G0=G0)
Ngrains=n_elements(st_temp)
st_grains={keywords:key_str,G0:G0,Ngrains:fix(Ngrains),grains:st_temp}

file=dir_in_dat+'ISRF.DAT'
st_isrf=dustem_read_isrf(file,silent=silent,Nisrf=Nisrf)

;=== Read Qabs
;st_qabs=ptrarr(st_grains.ngrains)
st_qabs=ptrarr(Ngrains)
FOR i=0,Ngrains-1 DO BEGIN
  Qabs_file=dir_in_qabs+'Q_'+st_grains.grains[i].type+'.DAT'
  st=dustem_read_qabs_lv(Qabs_file,silent=silent)
  st_qabs(i)=ptr_new(st)
ENDFOR

;=== Read heat capacities
;st_calor=ptrarr(st_grains.ngrains)
st_calor=ptrarr(Ngrains)
FOR i=0,Ngrains-1 DO BEGIN
  Calor_file=dir_in_capa+'C_'+st_grains(i).type+'.DAT'
  st=dustem_read_calor_lv(Calor_file,silent=silent)
  st_calor(i)=ptr_new(st)
ENDFOR

;=== Read lambda
file=dir_in_qabs+'LAMBDA.DAT'
st_lambda=dustem_read_lambda(file,silent=silent)

;stop

;=== Read size distribution files
;st_size=ptrarr(st_grains.ngrains)
;mod by NF on October 2009: KEY_STR has to be tested for SIZE_XXX.DAT, not the indiviual flags !
st_size=ptrarr(Ngrains)
IF stregex(key_str, 'SIZE', /bool) THEN BEGIN
   FOR i=0,Ngrains-1 DO BEGIN
      Size_file=dir_in_dat+'SIZE_'+st_grains(i).type+'.DAT'
      st=dustem_read_size(Size_file,silent=silent)
      st_size(i)=ptr_new(st)
   ENDFOR
ENDIF ELSE BEGIN
   st_size = ptr_new()
ENDELSE
;mod by NF on October 2009: KEY_STR has to be tested for SIZE_XXX.DAT, not the indiviual flags !

;stop

;add by NF on October 2009
;=== Read MIX files
st_mix = ptrarr(Ngrains)
FOR i=0,Ngrains-1 DO BEGIN
   IF stregex(st_grains(i).flag, 'MIX', /bool) THEN BEGIN
      Mix_file=dir_in_dat+'MIX_'+st_grains(i).type+'.DAT'
      st=dustem_read_mix(Mix_file,silent=silent)
      st_mix(i)=ptr_new(st)
   ENDIF ELSE BEGIN
      st_mix(i)=ptr_new()
   ENDELSE
ENDFOR
;add by NF on October 2009



;mod by NF on October 2009: add MIX structure
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}
;mod by NF on October 2009: add MIX structure

the_end:
RETURN,st

END