pro CLD_read, filename ;------------------------------------------------------------------------------- ;Procedure for reading the 10-sec lidar CLD files. ;Outputs: time: time axis ; base: matrix of up to 10 cloud bases (sized to max # of layers) ; top: matrix of up to 10 cloud tops (sized to max # of layers) ; depol: matrix of up to 10 integrated depolarization ratios (") ;Matthew Shupe, 5-24-99 ;-------------------------------------------------------------------------------- openr,lun,filename,/get_lun print,filename ba=fltarr(1,12) to=ba de=ba str=' ' temp1=0. temp2=0. temp3=0.D temp4=0. temp5=0. ;Get the first chunk of data and set up the variables readf,lun,str date=strmid(str,5,2)+strmid(str,8,2)+strmid(str,2,2) dai=strmid(str,8,2) hr=strmid(str,11,2) mi=strmid(str,14,2) se=strmid(str,17,2) numlay=fix(strmid(str,22,2)) if numlay gt 12 then begin print,numlay+' layers is larger than matrix size 12' return endif ti=float(hr)+(float(mi)*60.+se)/3600. ind=-1 for i=1,numlay do begin readf,lun,temp1,temp2,temp3,temp4,temp5 if (temp1 ne temp2) and (temp5 ge 0) then begin ind=ind+1 ba[0,i-1]=temp1 to[0,i-1]=temp2 de[0,i-1]=temp5 endif endfor maxlay=ind+1 ;Start filling the data matrices ;-------------------------------- time=ti lastti=ti base=ba top=to depol=de ;Now read in the rest of the file ;-------------------------------- while (not eof(lun)) do begin readf,lun,str da=strmid(str,8,2) hr=strmid(str,11,2) if da ne dai then hr=strtrim(string(24+fix(hr)),2) mi=strmid(str,14,2) se=strmid(str,17,2) numlay=fix(strmid(str,22,2)) if numlay gt 12 then begin print,numlay+' layers is larger than matrix size 12' return endif ti=float(hr)+(float(mi)*60.+se)/3600. ;if there is a larger than 10-sec gap but smaller than 30-sec gap ;then fill with the last good data ;--------------------------------------- if (ti gt lastti+10./3600.) and (ti le lastti+30./3600.) then begin while (ti gt lastti+10./3600.) do begin lastti=lastti+10./3600. time=[time,lastti] base=[base,ba] ;fltarr(1,12)] top=[top,to] ;fltarr(1,12)] depol=[depol,de] ;fltarr(1,12)] endwhile endif ;if there is a gap larger than 30-sec then fill with zeroed data ;---------------------------------------------------------------- if (ti gt lastti+30./3600.) then begin while (ti gt lastti+10./3600.) do begin lastti=lastti+10./3600. time=[time,lastti] base=[base,fltarr(1,12)] top=[top,fltarr(1,12)] depol=[depol,fltarr(1,12)] endwhile endif ;Read in the data and filter out the bad data (0 thickness layers and neg depol) ;------------------------------------------------------------------------------- ba=fltarr(1,12) to=ba & de=ba ind=-1 for i=1,numlay do begin readf,lun,temp1,temp2,temp3,temp4,temp5 if (temp1 ne temp2) and (temp5 ge 0) then begin ind=ind+1 ba[0,ind]=temp1 to[0,ind]=temp2 de[0,ind]=temp5 endif endfor numlay=ind+1 ;the actual # of layers if numlay gt maxlay then maxlay=numlay time=[time,ti] base=[base,ba] top=[top,to] depol=[depol,de] lastti=ti endwhile free_lun,lun base=base[*,0:maxlay-1]/1000. top=top[*,0:maxlay-1]/1000. depol=depol[*,0:maxlay-1] save,time,depol,base,top,filename=date+'.CLD10sec.dat' end