pro tenmininterp, ltime,rtime,bht,tht,rbase,rtop ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- ;Title: tenmininterp.pro ; ;Purpose: To interpolate the radar cloudboundary data (bht,tht) ; from the radar time axis (rtime) to a ten-minute average ; time axis (ltime). The output cloudboundaries are in ; rbase and rtop. ; ;Options: The "option" variable can be set to point to a certain ; type of average: ; option=0 --> More complex average which finds all ; clouds in a 10-min section and averages the ; heights for those clouds remaining longer than ; 5 minutes. ; option=1 --> Grabs one beam of radar data every ; 10-min. ; ;Calls: closest.pro ; ;Author: Matthew Shupe ;Date: 9/24/99 ;Modified: 9/24/99 ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- option=1 ;---------------------------------------------------- ; Option=0 code. More complex averaging ;---------------------------------------------------- if option eq 0 then begin ;Set up output variables rbase=fltarr(n_elements(ltime),10) rtop=rbase ;Create a 10-min average for each ltime time for b=0,n_elements(ltime)-1 do begin ;Grab 10-min chunk of radar data starting at the lidar time ;---------------------------------------------------------- chunk=where(rtime ge ltime[b] and rtime lt ltime[b]+1/6.,nchunk) ;If there is sufficient radar data, get chunk's averages ;------------------------------------------------------- if nchunk lt 30 then begin rbase[b,*]=fltarr(10)*0-999. rtop[b,*]=rbase[b,*] endif else begin ;Find first cloud data in chunk ;----------------------------------- bcld=fltarr(10)*0. & tcld=bcld & numcld=bcld & ithiscld=bcld ilastcld=indgen(10) first=0. & i=0. while (first eq 0) and (i le nchunk/2) do begin vwh=where(bht[chunk[i],*] gt 0,numv) if numv gt 0 then begin first=1 for ii=0,numv-1 do begin bcld[ii]=bht[chunk[i],vwh[ii]] tcld[ii]=tht[chunk[i],vwh[ii]] numcld[ii]=1 endfor lastcld=bcld endif i=i+1 endwhile numlay=numv ;If first = 0 at this point then no need to average ; anything because there is no significant data. ;--------------------------------------------------- if first eq 0 then begin rbase[b,*]=fltarr(10)*0 rtop[b,*]=rbase[b,*] goto, flag1 endif ;Now find the rest of the cloud data ;---------------------------------------- for j=i,nchunk-1 do begin vwh=where(bht[chunk[j],*] gt 0,numv) if numv gt 0 then begin for jj=0,numv-1 do begin fwh=where(abs(lastcld-bht[chunk[j],vwh[jj]]) le .270) if fwh[0] ne -1 then begin bcld[ilastcld[fwh[0]]]=bcld[ilastcld[fwh[0]]] + bht[chunk[j],vwh[jj]] tcld[ilastcld[fwh[0]]]=tcld[ilastcld[fwh[0]]] + tht[chunk[j],vwh[jj]] numcld[ilastcld[fwh[0]]]=numcld[ilastcld[fwh[0]]]+1 ithiscld[jj]=ilastcld[fwh[0]] endif else begin numlay=numlay+1<10 bcld[numlay-1]=bht[chunk[j],vwh[jj]] tcld[numlay-1]=tht[chunk[j],vwh[jj]] numcld[numlay-1]=1 ithiscld[jj]=numlay-1 endelse endfor ilastcld=ithiscld lastcld=bht[chunk[j],*] endif endfor ;Now fill the output values pwh=where(numcld ge 30,nump) if nump gt 0 then begin bases=bcld[pwh]/numcld[pwh] tops=tcld[pwh]/numcld[pwh] rbase[b,*]=[bases[sort(bases)],fltarr(10-nump)*0.] rtop[b,*]=[tops[sort(tops)],fltarr(10-nump)*0.] endif flag1:; endelse endfor ;ltime endif ;option0 ;--------------------------------------------------------------------- ;-------------------------------------------------------------------- ; Option=1, Less complex averaging ;-------------------------------------------------------------------- if option eq 1 then begin rbase=fltarr(n_elements(ltime),10) rtop=rbase for i=0,n_elements(ltime)-1 do begin ;Grab beam every 10 minutes iti=closest(rtime,ltime[i],0) rbase[i,*]=bht[iti,*] rtop[i,*]=tht[iti,*] endfor endif ;option1 ;--------------------------------------------------------------------- end ;proc