climatology: Compute a grid climatology

Description Usage Arguments Details Value Parallel Processing Author(s) See Also Examples

View source: R/climatology.R

Description

Calculates the climatology (i.e., complete temporal aggregation, typically the mean) of the input grid.

Usage

1
2
3
climatology(grid, clim.fun = list(FUN = "mean", na.rm = TRUE),
  by.member = TRUE, parallel = FALSE, max.ncores = 16,
  ncores = NULL)

Arguments

grid

Input grid

clim.fun

Function to compute the climatology. This is specified as a list, indicating the name of the aggregation function in first place (as character), and other optional arguments to be passed to the aggregation function. Default to mean (i.e., clim.fun = list(FUN="mean",na.rm = TRUE)).

by.member

Logical. In case of multimember grids, should the climatology be computed sepparately for each member (by.member=TRUE), or a single climatology calculated from the ensemble mean (by.member=FALSE)?. Default to TRUE.

parallel

Logical. Should parallel execution be used?

max.ncores

Integer. Upper bound for user-defined number of cores.

ncores

Integer number of cores used in parallel computation. Self-selected number of cores is used when ncpus = NULL (the default), or when maxcores exceeds the default ncores value.

Details

Two attributes are appended to the grid:

Value

A grid corresponding to the climatology. See details.

Parallel Processing

Parallel processing is enabled using the parallel package. Parallelization is undertaken by a FORK-type parallel socket cluster formed by ncores. If ncores is not specified (default), ncores will be one less than the autodetected number of cores. The maximum number of cores used for parallel processing can be set with the max.ncores argument, although this will be reset to the auto-detected number of cores minus 1 if this number is exceeded. Note that not all code, but just some critical loops within the function are parallelized.

In practice, parallelization does not always result in smaller execution times, due to the parallel overhead. However, parallel computing may potentially provide a significant speedup for the particular case of large multimember datasets or large grids.

Parallel computing is currently not available for Windows machines.

Author(s)

J. Bedia

See Also

plotClimatology, for plotting climatologies. persistence, for a special case in which the temporal autocorrelation function is applied.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Station data:
# Mean surface temperature
data("VALUE_Iberia_tas")
st_mean_clim <- climatology(VALUE_Iberia_tas)
str(st_mean_clim)
plotClimatology(st_mean_clim, backdrop.theme = "coastline")
# Standard deviation of surface temperature
st_sd_clim <- climatology(VALUE_Iberia_tas, clim.fun = list(FUN = sd, na.rm = TRUE))
plotClimatology(st_sd_clim, backdrop.theme = "coastline")

# July surface temp forecast climatology
data("CFS_Iberia_tas")
# Aggregate all members before computing the climatology
t_mean.clim <- climatology(CFS_Iberia_tas,
                           by.member = FALSE)
# Note the new attributes, and that time dimension is preserved as a singleton
str(t_mean.clim$Data)
str(t_mean.clim$Dates)
# Compute a climatology for each member sepparately
t_mean_9mem.clim <- climatology(CFS_Iberia_tas,
                                by.member = TRUE)
str(t_mean_9mem.clim$Data)
# 9 different climatologies, one for each member

SantanderMetGroup/transformeR documentation built on March 14, 2020, 9:15 a.m.