FUNCTION dustem_read_calor_lv,file,silent=silent,help=help ;+ ; NAME: ; dustem_read_calor_lv ; ; PURPOSE: ; reads .DAT files relating to grain heat capacities for the LV ; fortran version ; ; CATEGORY: ; DustEMWrap, Distributed, LowLevel, Initialization ; ; CALLING SEQUENCE: ; dustem_read_calor_lv,dir,st ; ; INPUTS: ; file : input file to be read ; ; 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_calor_lv' full_st=0. goto,the_end ENDIF st='' Nmax=10000L sts=strarr(Nmax) openr,unit,file,/get_lun ;==read comments str='' & first_char='#' WHILE first_char EQ '#' DO BEGIN readf,unit,str first_char=strmid(str,0,1) ENDWHILE ;read number of sizes Nsizes=fix(str) ;Get sizes readf,unit,st sizes=float(str_sep(strcompress(strtrim(st,2)),' ')) Ncol=Nsizes ;==read comments ;str='' & first_char='#' ;WHILE first_char EQ '#' DO BEGIN ; readf,unit,str ; first_char=strmid(str,0,1) ;ENDWHILE readf,unit,Nlines ;== read Calor nlines=0L first_char=' ' WHILE not eof(unit) and first_char NE '#' DO BEGIN readf,unit,st sts(nlines)=st nlines=nlines+1 first_char=strmid(st,0,1) ENDWHILE close,unit free_lun,unit calor_str=sts(0:nlines-1) Nlines=n_elements(calor_str) calor_values=fltarr(Nlines,Ncol) logT_values=fltarr(Nlines) FOR i=0L,Nlines-1 DO BEGIN vs=str_sep(strcompress(strtrim(calor_str(i),2)),' ') logT_values(i)=vs(0) calor_values(i,*)=vs(1:*) ENDFOR ;== Make output structure cmd='one_st={' FOR i=0L,Ncol-1 DO BEGIN cmd=cmd+'v'+strtrim(i+1,2)+':'+'0.' IF i NE Ncol-1 THEN BEGIN cmd=cmd+',' ENDIF ELSE BEGIN cmd=cmd+'}' ENDELSE ENDFOR toto=execute(cmd) calor_st=replicate(one_st,Nlines) ;=== fill in the qabs structure FOR j=0L,Ncol-1 DO BEGIN calor_st.(j)=reform(calor_values(*,j)) ENDFOR full_st={file:file,Nsizes:Nsizes,sizes:sizes,logT:logT_values,Calor:calor_st} the_end: return,full_st END