makeZStat: Compute Z-dimension statistic of a variable

Description Usage Arguments Value Note See Also Examples

View source: R/makeZStat.R

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.

Usage

1
makeZStat(x, verbose = FALSE, sortData = FALSE, FUN = mean, ...)

Arguments

x

A cmip5data object

verbose

logical. Print info as we go?

sortData

logical. Sort x and area before computing?

FUN

function. Function to apply across Zs

...

Other arguments passed on to FUN

Value

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.

Note

If x is not in a needed order (for example, FUN uses weights in a different order), be sure to specify sortData=TRUE.

See Also

makeAnnualStat makeGlobalStat makeMonthlyStat

Examples

1
2
3
d <- cmip5data(1970:1975, Z=TRUE)   # sample data
makeZStat(d)
summary(makeZStat(d, FUN=sd))

RCMIP5 documentation built on May 1, 2019, 6:28 p.m.