pro CLD_read2, filename,ltime,ldepol,ltop,lbase,maxlay ;------------------------------------------------------------------------------- ;Procedure for reading the 10-min lidar CLD files. ;Outputs: ltime: time axis (10-min) [decimal hour] ; lbase: cloud bases [km] ; ltop: cloud tops [km] ; ldepol: integrated depolarization ratios ; maxlay: maximum # of layers in file ;Matthew Shupe, 5-24-99 ;-------------------------------------------------------------------------------- ;First create a 10-minute time axis and output variables ;-------------------------------------------------------- ltime=findgen(144)*1/6. ctime=fix(ltime*100) lbase=fltarr(144,12)*0-999. ltop=lbase ldepol=lbase openr,lun,filename,/get_lun print,filename ba=fltarr(1,12)*0 & 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) da=strmid(str,8,2) hr=strmid(str,11,2) mi=strmid(str,14,2) se=strmid(str,17,2) if (hr eq '23') and (strmid(mi,0,1) eq '5') then begin da=strtrim(float(da)+1.,2) hr='00' mi='00' se='00' endif 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.+ float(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/1000. ;put into km to[0,i-1]=temp2/1000. de[0,i-1]=temp5 endif endfor maxlay=ind+1 ;Start filling the data matrices ;-------------------------------- iwhere=closest(ctime,fix(ti*100),0) lbase[iwhere[0],*]=ba ltop[iwhere[0],*]=to ldepol[iwhere[0],*]=de ;Now read in the rest of the file ;-------------------------------- while (not eof(lun)) do begin readf,lun,str dai=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.+float(se))/3600. ;Read in data and filter out bad data (0 thickness layers and neg depol) ;------------------------------------------------------------------------ ba=fltarr(1,12)*0. 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/1000. ;puts into km to[0,ind]=temp2/1000. de[0,ind]=temp5 endif endfor numlay=ind+1 ;the actual # of layers if numlay gt maxlay then maxlay=numlay ;Fill output matrices ;--------------------- iwhere=closest(ctime,fix(ti*100),0) lbase[iwhere[0],*]=ba ltop[iwhere[0],*]=to ldepol[iwhere[0],*]=de endwhile free_lun,lun ;Modify the heights to account for the 10m offset between the lidar and the surface wh=where(lbase gt 0,nm) if nm gt 0 then begin lbase[wh]=lbase[wh]+0.01 ltop[wh]=ltop[wh]+0.01 endif end