Hi Nicolas,
First, for the commands you're showing, I'm not sure why you'd need
the loops; isn't it the same if you just do this?
plot/vs/i=`imin`:`imax`/j=`jmin`:`jmax`
precipitation[d=1],height[d=2]
For the averaging problem, my first thought was the @WEQ
transformation,
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/XPRESSIONS#_VPINDEXENTRY_532
but that would be for picking out data from an XYZ grid at the
different heights.
You could use masks; something along these lines, (this is untested,
so commands may have typos - to give you the idea)
yes? let mask1 = if height gt 0 and height le 20
then 1
yes? let mask2 = if height gt 20 and height le 40 then 1
yes? let mask3 = if height gt 40 and height le 80 then 1
yes? let precip1 = precipitation[d=1,gxy=height]*
mask1
yes? let precip2 = precipitation[d=1,gxy=height]*
mask2
yes? let precip3 = precipitation[d=1,gxy=height]*
mask3
yes? let p_ave_1 = precip1[x=@ave,y=@ave]
yes? let p_ave_2 = precip2[x=@ave,y=@ave]
yes? let p_ave_3 = precip3[x=@ave,y=@ave]
then the precip variables each contain all the precip values where
height is in each of those ranges, and are missing everywhere else.
The p_ave variables are scalars, the average value of each. Now how
to associate those with the heights?
yes? define axis/z/edges/units=meters zheight =
{0,20,40,80}
yes? let/units=meters zz = z[gz=zheight]
yes? let precip_ave = {`p_ave_1`, `p_ave_2`, `p_ave_3`}
yes?
let/units="`precip,return=units`"/title="Precipitation averaged
in z" \
precip_ave_z = reshape(precip_ave, zz)
yes? plot/vs/thick precip_ave_z, zz
or a color ribbon plot, colored by the average precipitation values:
yes? plot/vs/thick/ribbon precip_ave_z, zz,
precip_ave_z
-Ansley
On 11/26/2014 6:15 PM, Nicolas Freychet
wrote:
Hello,
I have 2 datasets: one with precipitation, one with topography
(both are X/Y spatial). I would like to plot the Precipitation
vs the Height.
I can do that with something like:
repeat/range=imin:imax/name=it ( ;\
repeat/range=jmin:jmax/name=jt ( ;\
plot/vs
precipitation[d=1,i=`it`,j=`jt`],height[d=2,i=`it`,j=`jt`] ))
But I'd also like to average all precipitation that are at the
same height instead of plotting them grid point by grid point.
So I guess I first have to regrid all precipitation on an axis
that depends of the height, and then average over the height.
But I don't know how to do that.
Thanks
Nicolas
|