Learn R Programming

RCMIP5 (version 1.0)

makeMonthlyStat: Compute monthly statistic of a variable

Description

We frequently want to summarize CMIP5 data by month, e.g. to understand how air temperature varies over the year for a particular data range. This function does that for monthly data. The default statistic is mean, but any summary function that returns a numeric result can be used.

Usage

makeMonthlyStat(x, verbose = FALSE, parallel = FALSE, FUN = mean, ...)

Arguments

x
A cmip5data object
verbose
logical. Print info as we go?
parallel
logical. Parallelize if possible?
FUN
function. Function to apply across months of year
...
Other arguments passed on to FUN

Value

  • A cmip5data object, whose val field is the monthly mean of the variable. A numYears field is also added recording the number of years averaged for each month.

Details

If a Z dimension is present, the stat function is calculated for all combinations of these. No status bar is printed when processing in parallel, but progress is logged to a file (call with verbose=T) that can be monitored.

If the user requests parallel processing (via parallel=T) makeMonthlyStat (i) attempts to load the doParallel package, and (ii) registers it as a parallel backend unless the user has already done this (e.g. set up a virtual cluster with particular, desired characteristics). In that case, makeMonthlyStat respects the existing cluster.

See Also

makeAnnualStat makeZStat makeGlobalStat

Examples

Run this code
d <- cmip5data(1970:1975)   # sample data
makeMonthlyStat(d)
summary(makeMonthlyStat(d))
library(doParallel)
registerDoParallel()
summary(makeMonthlyStat(d, verbose=TRUE, parallel=TRUE))
summary(makeMonthlyStat(d, FUN=sd))

Run the code above in your browser using DataLab