makeGlobalStat: Compute global statistic of a variable

Description Usage Arguments Details Value Note See Also Examples

View source: R/makeGlobalStat.R

Description

Calculates a global summary for CMIP5 data, usually weighted by the grid cell areas used by each particular model. If no area weighting is supplied, one is computed based on the lon/lat values of x. The default statistic is weighted.mean, but any summary function that returns a numeric result can be used.

Usage

1
2
makeGlobalStat(x, area = NULL, verbose = FALSE, sortData = FALSE,
  FUN = cmip5.weighted.mean, ...)

Arguments

x

A cmip5data object

area

An area cmip5data object

verbose

logical. Print info as we go?

sortData

logical. Sort x and area before computing?

FUN

function. Function to apply across grid

...

Other arguments passed on to FUN

Details

The stat function is calculated for all combinations of lon, lat, and Z (if present). This function is more complicated than the other make...Stat functions, because it provides explicit support for area-weighted functions. We expect that weighted.mean and a weighted sum will be the most frequent calculations needed. Note that the base R weighted.mean function doesn't work well for CMIP5 data, and so cmip5.weighted.mean is used as a default function. Any other user-supplied stat function must follow the weighted.mean syntax, in particular accepting parameters 'x' (data) and 'w' (weights) of equal size, as well as dots(...).

Value

A cmip5data object, in which the val dimensions are the same as the caller for Z (if present) and time, but lon and lat are reduced to 1 (i.e. no dimensionality). A numCells field is also added, recording the number of cells in the spatial grid.

Note

If x and optional area are not in the same order, make sure to specify sortData=TRUE.

See Also

makeAnnualStat makeZStat makeMonthlyStat cmip5.weighted.mean

Examples

1
2
3
d <- cmip5data(1970:1975)   # sample data
makeGlobalStat(d)
summary(makeGlobalStat(d))

Example output

CMIP5: var, model experiment,  x  x 0 x 72, 1970 to 1975, from 1 ensemble 
CMIP5 data (spatial summary of 21 cells) 
Variable: var (unit) from model model
Data range: 1 to 1 Mean: 1
Experiment: experiment - 1 ensemble(s)
Spatial dimensions: lon [] lat [] Z [0] 
Time dimension: mon [72] days since 1970-01-01 
Size: 0.0 MB
Provenance has 4 entries

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