PRO read_rico_sondes_1p ; places the name soundings at 1 mb res, puts them in an idlsave file RESTORE,filename='/Users/pz/rico/rico_sonde_leg2.idlsave' ;p,z,t,rh,dates,nsonde,surfp RESTORE,filename='/Users/pz/rico/rico_wind_leg2.idlsave' ;p2,z,u,v,speed,dir print,'NOW INTERPOLATE TO 1 MB' ; interpolate to 1 mb pressure resolution pgrid=1010.-findgen(1010) ;p MUST be monotonically increasing for interpol to work. ; reverse all arrays pgrid=reverse(pgrid) p=reverse(p,2) & t=reverse(t,2) rh=reverse(rh,2) & z=reverse(z,2) u=reverse(u,2) & v=reverse(v,2) p2=reverse(p2,2) s=size(t) & nsonde=s[1] & ntop=1010 tnew=fltarr(nsonde,ntop)-999. & rhnew=fltarr(nsonde,ntop)+999. znew=fltarr(nsonde,ntop)-999. & zgrid=fltarr(ntop) unew=tnew & vnew=unew FOR i=0,nsonde-1 DO begin ; p[i,*] MUST be monotonically increasing for interpol to work dp=p[i,*]-shift(p[i,*],1) good=where(dp gt 0.0 and p[i,*] gt 0.0 and t[i,*] lt 40. $ and rh[i,*] gt 0.0 and rh[i,*] lt 120. and t[i,*] gt -100. ) check_p=p[i,*] good2=where(pgrid ge min(check_p[where(check_p gt 0.0)]) and $ pgrid le max(check_p[where(check_p gt 0.0)])) tnew[i,good2]=interpol(t[i,good],p[i,good],pgrid[good2]) rhnew[i,good2]=interpol(rh[i,good],p[i,good],pgrid[good2]) znew[i,good2]=interpol(z[i,good],p[i,good],pgrid[good2]) check_p=p2[i,*] test=where(check_p gt 0.0,count) if count gt 0 then begin good2=where(pgrid ge min(check_p[where(check_p gt 0.0)]) and $ pgrid le max(check_p[where(check_p gt 0.0)])) unew[i,good2]= $ interpol(u[i,good],p2[i,good],pgrid[good2]) vnew[i,good2]= $ interpol(v[i,good],p2[i,good],pgrid[good2]) endif ENDFOR ;reverse the order again pgrid=reverse(pgrid) tnew=reverse(tnew,2) & rhnew=reverse(rhnew,2) znew=reverse(znew,2) unew=reverse(unew,2) & vnew=reverse(vnew,2) print,'dun with interpolating to 1 mb res.' ; find the mean altitude at each pgrid value FOR i=0,1009 do begin goodz=where(znew[*,i] ne -999.0,count_good) if (count_good gt 0.) then zgrid[i]=mean(znew[goodz,i]) ENDFOR SAVE,filename='/Users/pz/rico/rico_sonde_1p_leg2.idlsave',$ pgrid,zgrid,tnew,rhnew,dates,nsonde,znew,unew,vnew,surfp print,'dun' END