climdexGrid: ETCCDI Climate Changes Indices in Climate4R

View source: R/climdexGrid.R

climdexGridR Documentation

ETCCDI Climate Changes Indices in Climate4R

Description

Calculation of the 27 core indices of the Expert Team on Climate Change Detection and Indices (ETCCDI). The function is a wrapper of the package climdex.pcic for its seamless integration with climate4R objects.

Usage

climdexGrid(
  index.code,
  tn = NULL,
  tx = NULL,
  pr = NULL,
  input.arg.list = list(),
  index.arg.list = list(),
  cal = "365_day",
  parallel = FALSE,
  max.ncores = 16,
  ncores = NULL
)

Arguments

index.code

Character string, indicating the specific code of the index according to the ETCCDI definitions (see Details).

tn

A climate4R dataset of daily minimum temperature (degrees C)

tx

A climate4R dataset of daily maximum temperature (degrees C)

pr

A climate4R dataset of daily precipitation (mm)

input.arg.list

Optional. A list of arguments internally passed to climdexInput.raw from package climdex.pcic

index.arg.list

Optional (but depending on the specific index might be necessary). A list of specific arguments for the target index. See Details.

cal

A calendar definition. Default to 365-day calendar. This argument is passed to as.PCICt, whose help documentation contains further details.

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

climdexShow will display on screen a full list of ETCCDI Core indices and their codes. The names of the internal functions calculating each index is also displayed, whose help files can aid in the definition of index-specific arguments.

Baseline period By default, the function will use as baseline period the full period of years encompassed by the input grid(s). This is used, for instance, for calculating the relevant percentiles in some indices etc. To use a specific baseline period use the "base.range" argument in the input.arg.list internally passed to climdexInput.raw.

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

Examples

## Not run: 
require(climate4R.climdex)
require(visualizeR)
data("tasmin.eobs")
## FROST DAYS (Annual count of days when TN < 0 degC)
fd.grid <- climdexGrid(tn = tasmin.eobs, index.code = "FD")
spatialPlot(climatology(fd.grid), at = seq(0,165,10),
            main = "Mean annual number of frost days (1991-2010)")


# The following example will compute the CWD index
# (maximum number of consecutive days with RR ≥ 1mm)
# for the homogeneized VALUE dataset of stations over Europe
# (See Gutiérrez et al. 2018 DOI:10.1002/joc.5462 for details on this dataset)
library(loadeR)
library(transformeR)
library(visualizeR)
destfile = "/tmp/VALUE_ECA_86_v2.tar.gz"
# (~8Mb download, change destfile at your convenience)
download.file("http://meteo.unican.es/work/loadeR/data/VALUE_ECA_86_v2.tar.gz", destfile = destfile)
untar(destfile, exdir = "/tmp")
station.data <- loadStationData(dataset = "/tmp/VALUE_ECA_86_v2",
                                var = "precip",
                                years = 1981:2000)
cwd <- climdexGrid(index.code = "CWD", pr = station.data)
spatialPlot(climatology(cwd), backdrop.theme = "countries",
            main = "Mean number of consecutive annual wet days (1981-2000)")

## End(Not run)


SantanderMetGroup/climate4R.climdex documentation built on July 3, 2023, 10:54 a.m.