;Title: acse_readceilo.pro ;Purpose: Read the ceilometer data from ACSE ; ;Inputs: sarg: date/time string, YYYYMMDDHH ; earg: data/time string, YYYYMMDDHH ;Outputs: time: decimal hour of day relative to the first day. ; detstat: ceilometer detection status: 0 - clear, 1-3 - number of cloud bases, 4 - use vertical visibility ; cbase1: 1st cloud base height [m]. Available for detstat=[1,2,3] ; cbase2: 2nd cloud base height [m]. Available for detstat=[1,2] ; cbase3: 3rd cloud base height [m]. Available for detstat=3 ; vertvis: vertical visibility [m]. Available for detstat=4 ; highsig: altitude of highest signal [m]. Available for detstat=4 ;Keywords: ; directory: optionally specify a directory that contains the data. ; jtime: decimal year day ; ;I/O: acse_readceilo,.... ; ;Notes: Ceilometer raw file naming convention: CYMMDDHH.DAT ; where C is a specified character, Y is the year ; files are typically daily, unless the software has been restarted ;------------------------------------------------------------------------------ pro acse_readceilo,sarg,earg,time,detstat,cbase1,cbase2,cbase3,vertvis,highsig,directory=directory,jtime=jtime if keyword_set(directory) then cd,directory,current=orig_dir ;Determine the files to open sjd=julday(strmid(sarg,4,2),strmid(sarg,6,2),strmid(sarg,0,4)) 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)) 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(strtrim(yr,2),3,1) darg[i]=yr+mo+da endfor endif else begin darg=strmid(sarg,3,5) numa=n_elements(darg) endelse sjd=sjd-julday(1,1,2014)+1 ;Initialize variables ind=0L num=numa*10000 detstat=intarr(num)*0-1 cbase1=intarr(num)*0 cbase2=intarr(num)*0 cbase3=intarr(num)*0 vertvis=intarr(num)*0 highsig=intarr(num)*0 year=intarr(num) mon=intarr(num) day=intarr(num) time=fltarr(num) ;Open files, read, concatenate data jnk=' ' str=' ' dt1=' ' & dt2=' ' & dt3=' ' & dt4=' ' & dt5=' ' & dt6=' ' & dt7=' ' & dt8=' ' & dt9=' ' ;Loop over all daily arguments for d=0,numa-1 do begin ;Get the list of files for the daily argument arg='*'+darg[d]+'*.DAT' 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] readf,lun,jnk readf,lun,jnk while not eof(lun) do begin readf,lun,str,format="(a20)" if strmid(str,0,2) eq '-F' then goto,flag if strmid(str,0,2) ne '-2' then begin print,'off' stop endif readf,lun,jnk readf,lun,dt1,dt2,dt3,dt4,dt5,dt6,dt7,dt8,dt9,format="(a2,a1,a5,a1,a5,a1,a5,a1,a12)" for i=0,4 do readf,lun,jnk ;Store data detstat[ind]=fix(strmid(dt1,0,1)) case detstat[ind] of 1: cbase1[ind]=fix(dt3) 2: begin cbase1[ind]=fix(dt3) cbase2[ind]=fix(dt5) end 3: begin cbase1[ind]=fix(dt3) cbase2[ind]=fix(dt5) cbase3[ind]=fix(dt7) end 4: begin vertvis[ind]=fix(dt3) highsig[ind]=fix(dt5) end else: endcase time[ind]=float(strmid(str,12,2))+float(strmid(str,15,2))/60.+float(strmid(str,18,2))/3600.+24.*d ind=ind+1 endwhile flag: free_lun,lun endfor endfor if ind gt 0 then begin detstat=detstat[0:ind-1] cbase1=float(cbase1[0:ind-1])/1000. cbase2=float(cbase2[0:ind-1])/1000. cbase3=float(cbase3[0:ind-1])/1000. highsig=float(highsig[0:ind-1])/1000. vertvis=float(vertvis[0:ind-1])/1000. time=time[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] detstat=detstat[wh] cbase1=cbase1[wh] cbase2=cbase2[wh] cbase3=cbase3[wh] vertvis=vertvis[wh] highsig=highsig[wh] endif endif else begin time=findgen(1440)/1440*24. cbase1=time*0-999 cbase2=cbase1 cbase3=cbase1 vertvis=cbase1 highsig=cbase1 detstat=time*0-1 endelse ;make julian time jtime=floor(sjd)+time/24.0 if keyword_set(directory) then cd,orig_dir end