;------------------------------------------------------- ;Title: acse_readsnake.pro ;Purpose: Program to read sea snake ; ;Input: sarg: date/time string, YYYYMMDDHH ; earg: data/time string, YYYYMMDDHH ;Output: time: time axis, decimal hours ; ;Keywords: directory: directory containing the data ; default is current working directory ;Author: Matthew Shupe ;Date: 7/7/2014 ;------------------------------------------------------- pro acse_readsnake,sarg,earg,time,temp,directory=directory if keyword_set(directory) then cd,directory,current=orig_dir base_date=julday(1,1,1970,0,0,0) base=jul_to_dt(base_date) !dt_base=base ;---------------------------------- ;Determine a list of files to read ;---------------------------------- sjd=julday(strmid(sarg,4,2),strmid(sarg,6,2),strmid(sarg,0,4))-julday(1,1,strmid(sarg,0,4))+1 if strmid(sarg,6,2) ne strmid(earg,6,2) then begin ejd=julday(strmid(earg,4,2),strmid(earg,6,2),strmid(earg,0,4))-julday(1,1,strmid(earg,0,4))+1 if ejd lt sjd then begin print,'acse_readsnake: cannot go across a new year.' stop endif numa=ejd-sjd+1 darg=strarr(numa) for i=0,numa-1 do begin darg[i]=strmid(sarg,1,3)+strtrim(sjd+i,2) endfor endif else begin darg=strmid(sarg,1,3)+strtrim(sjd,2) numa=n_elements(darg) endelse ;----------------------- ;Read in the daily files ;----------------------- time=fltarr(numa*24*61.)*0-999. temp=time jnk=' ' st2=strarr(9) ind=0L for d=0,numa-1 do begin farg='sea'+darg[d]+'*_raw*' file=findfile(farg,count=numf) file=file[sort(long(strmid(file,3,8)))] for f=0,numf-1 do begin print,"Reading ",file[f] openr,lun,/get_lun,file[f] hr=float(strmid(file[f],9,2)) readf,lun,jnk while not eof(lun) do begin readf,lun,jnk st2=strsplit(jnk,' ,',/extract) time[ind]=hr+float(strmid(st2[0],0,2))/60.+d*24.0 temp[ind]=st2[4] ind=ind+1 endwhile free_lun,lun endfor endfor if ind gt 0 then begin time=time[0:ind-1] temp=temp[0:ind-1] ;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] temp=temp[wh] endif endif else begin time=findgen(1440)/1440*24. temp=time*0-999. endelse if keyword_set(directory) then cd,orig_dir end ;prog