dustem_read_tls.pro 2.15 KB
FUNCTION dustem_read_tls,dir_in,file,silent=silent,help=help


;+
; NAME:
;   dustem_read_tls
;
; PURPOSE:
;   read information relating to TLS model parameters from the .DAT
;   files into a structure.
;
; CATEGORY:
;    DustEMWrap, Distributed, LowLevel, Initialization
;
; CALLING SEQUENCE:
;   st=dustem_read_tls(dir,file)
;
; INPUTS:
;    file : TLS .dat file name to be read
;    dir  : input directory to find TLS .dat file
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    st : dustem data structure
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    silent     : quiet mode
;    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:
;    Written DP (?)
;    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_tls' 
  full_st=0
  goto,the_end
ENDIF

  
st=''
Nmax=10000L
sts=strarr(Nmax)
openr,unit,dir_in+'data/'+file,/get_lun

;==read comments
str1='' & first_char='#'
str2=''
str3=''
WHILE first_char EQ '#' DO BEGIN
  readf,unit,str1
  readf,unit,str2
  readf,unit,str3
  first_char=strmid(str1,0,1)
ENDWHILE

; row 1 of DTLS_XX.DAT FILE
stv1=str_sep(strtrim(strcompress(str1),2),' ')
a_dtls=float(stv1[0])
lc=float(stv1[1])
c_delta=float(stv1[2])

; row 2 of DTLS_XX.DAT FILE
stv2=str_sep(strtrim(strcompress(str2),2),' ')
vt=float(stv2[0])
Pmu=float(stv2[1])
gamma_e=float(stv2[2])

; row 3 of DTLS_XX.DAT FILE
stv3=str_sep(strtrim(strcompress(str3),2),' ')
omega_m=float(stv3[0])
tau_0=float(stv3[1])
V0=float(stv3[2])
Vmin=float(stv3[3])
Vm=float(stv3[4])

; row 4 of DTLS_XX.DAT FILE
readf,unit,ldtresh

; structure must have same order of tags as in dustem_read_all_release.pro
full_st={file:file,vt:vt,lc:lc,a_dtls:a_dtls $
         ,Pmu:Pmu,gamma_e:gamma_e, omega_m:omega_m $
         ,c_delta:c_delta,tau_0:tau_0 $
         ,V0:V0,Vmin:Vmin,Vm:Vm,ldtresh:ldtresh}

close,unit
free_lun,unit

the_end:
return,full_st

END