;Title: acse_readhatproirt ;Purpose: Read HATPRO IRT files ; ;Inputs: sarg: date/time string, YYYYMMDDHH ; earg: data/time string, YYYYMMDDHH ;Outputs: time: time of day from start day [hours] ; tir: IR brightness temperature [K] ;Keywords: directory: directory containing data ; ;I/O: ;Author: Matthew Shupe ;Date: 7/15/08, Adapted 7/8/14 ;--------------------------------------------------- pro acse_readhatproirt,sarg,earg,time,tir,directory=directory if keyword_set(directory) then cd,directory,current=orig_dir ;Determine the files to open if strmid(sarg,6,2) ne strmid(earg,6,2) then begin sjd=julday(strmid(sarg,4,2),strmid(sarg,6,2),strmid(sarg,0,4)) ejd=julday(strmid(earg,4,2),strmid(earg,6,2),strmid(earg,0,4)) numa=ejd-sjd+1 darg=strarr(numa) for i=0,numa-1 do begin caldat,sjd+i,mo,da,yr if mo lt 10 then mo='0'+strtrim(mo,2) else mo=strtrim(mo,2) if da lt 10 then da='0'+strtrim(da,2) else da=strtrim(da,2) yr=strmid(yr,2,2) darg[i]=yr+mo+da endfor endif else begin darg=strmid(sarg,2,6) numa=n_elements(darg) endelse ;Initialize arrays st5=strarr(5) st96=strarr(96) jnk=' ' time=fltarr(45000*numa) tir=fltarr(45000*numa) ;Loop over all daily arguments ind=0L for d=0,numa-1 do begin ;Get the list of files for the daily argument arg=darg[d]+'*IRT.ASC' file=findfile(arg,count=numf) ;Loop over all files in the day for f=0,numf-1 do begin print,'Reading ',file[f] openr,lun,/get_lun,file[f] for i=0,7 do readf,lun,jnk while not eof(lun) do begin readf,lun,jnk st10=strsplit(jnk,', ',/extract) time[ind]=float(st10[3])+float(st10[4])/60.+float(st10[5])/3600.+24.*d tir[ind]=float(st10[7]) ind=ind+1 endwhile free_lun,lun endfor endfor if ind gt 0 then begin time=time[0:ind-1] tir=tir[0:ind-1] endif else begin time=findgen(24) tir=time*0-999 endelse ;Trim data to the hour range requested shr=fix(strmid(sarg,8,2)) ehr=fix(strmid(earg,8,2)) wh=where(time ge shr and time le ehr+24.0*(numa-1),nm) if nm gt 0 then begin time=time[wh] tir=tir[wh] endif if keyword_set(directory) then cd, orig_dir end