The maximum number of spell days for a defined threshold during a period.
The function accepts daily data and returns the number of maximum spell
days exceeding (or not exceeding) the threshold for the defined period.
The threshold provided must be in the same units as the variable units,
i.e. to use a percentile as a scalar, the function Threshold or
QThreshold may be needed.
MaxSpellTimeExceedingThreshold(
data,
threshold,
op = ">",
dates = NULL,
start = NULL,
end = NULL,
na.rm = FALSE,
time_dim = "time",
ncores = NULL
)An 's2dv_cube' object containing the maximum number of days that correspond to a spell within a defined threshold, and corresponding to the period defined by the dimensions start and end.
An 's2dv_cube' object as provided function CST_Start or
CST_Load in package CSTools.
If only one threshold is used, it can be an 's2dv_cube' object or a multidimensional array with named dimensions. It must be in the same units and with the common dimensions of the same length as parameter 'data'. It can also be a vector with the same length of 'time_dim' from 'data' or a scalar. If we want to use two thresholds: it can be a vector of two scalars, a list of two vectors with the same length of 'time_dim' from 'data' or a list of two multidimensional arrays with the common dimensions of the same length as parameter 'data'. If two thresholds are used, parameter 'op' must be also a vector of two elements.
An operator '>' (by default), '<', '>=' or '<='. If two thresholds are used it has to be a vector of a pair of two logical operators: c('<', '>'), c('<', '>='), c('<=', '>'), c('<=', '>='), c('>', '<'), c('>', '<='), c('>=', '<'),c('>=', '<=')).
A multidimensional array of dates with named dimensions matching the temporal dimensions on parameter 'data'. By default it is NULL, to select a period this parameter must be provided.
An optional parameter to define the initial date of the period
to select from the data by providing a list of two elements: the initial
date of the period and the initial month of the period. By default it is set
to NULL and the indicator is computed using all the data provided in
data.
An optional parameter to defined the final date of the period to
select from the data by providing a list of two elements: the final day of
the period and the final month of the period. By default it is set to NULL
and the indicator is computed using all the data provided in data.
A logical value indicating whether to ignore NA values (TRUE) or not (FALSE).
A character string indicating the name of the dimension to compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.
An integer indicating the number of cores to use in parallel computation.
dims <- c(time = 12, syear = 3, ensemble = 1, lat = 5, lon = 2)
tas <- array(rnorm(360, 27.73, 5.26), dim = dims)
res <- MaxSpellTimeExceedingThreshold(
data = tas,
threshold = list(rep(c(27,28), times = 6),
rep(c(28,24), times = 6)),
op = c('>','<'),
time_dim = "time"
)
Run the code above in your browser using DataLab