This function does time averaging while applying a mask. The syntax is:
maskexpr- the mask expression; when evaluated at a fixed time, it must give a single value
expr- the expression to be averaged
timexpr1,2  - the limits of the time averaging domain
avefunction, except for the masking. Using
tmaveis much more efficient than using
maskexprat each fixed time.
maskexprmust yeild a single value. If this value is the undefined/missing data value, then
exprfor that time is not included in the average.
maskexpris not the undefined data value, it is used as the weight for
exprin the average. So if you define
maskexpraccordingly, you can use the
tmavefunction to do weighted time averaging.
tmaveis setting up
expris a grid with X and/or Y and/or Z varying, then
maskexpr*MUST* refer to either a defined variable or a file with only time varying. In general, you have to set up
slpover some time range but only when
sstover some region is above some value. You can do this by:
set x 1 set y 1 set t 1 last define sstmask = aave(sst,lon=-180,lon=-90,lat=-20,lat=20) define sstmask = const(maskout(sstmask,sstmask-25.0),1)
sstmask is a time series where the value is 1 when
sst areal average is above 25 and undefined when the
value is below 25.
maskout set the values
below 25 to missing;
const set the non-missing
values to 1. We can now do our
set lon -180 -90 set lat -20 20 set t 1 d tmave(sstmask,slp,t=1,t=last)
dset maskfilename xdef 1 linear 1 1 ydef 1 linear 1 1 zdef 1 linear 1 1 tdef 100 linear ....