makeZStat: Compute Z-dimension statistic of a variable
Description
Some CMIP5 data are four-dimensional: in addition to longitude, latitude,
and time, they include a Z dimension (typically encoded in the NetCDF file as
'depth' or 'lev'). This function computes a summary statistic for all Z values.
The default statistic is mean, but any summary
function that returns a numeric result (including weighted.mean, if you
want to apply weights) can be used.
A cmip5data object, whose val field is the mean of the
variable across Zs A numZs field is also added
recording the number of Z values averaged for each year, and x's original
Z field is removed.