Learn R Programming

ClimProjDiags (version 0.3.3)

Threshold: Daily thresholds based on quantiles for n-dimensional arrays

Description

This function computes the threshold based on a quantile value for each day of the year of the daily data input.

Usage

Threshold(
  data,
  dates = NULL,
  calendar = NULL,
  base.range = NULL,
  qtiles = 0.9,
  ncores = NULL,
  na.rm = FALSE
)

Value

An array with similar dimensions as the data input, but without 'time' dimension, and a new 'jdays' dimension.

Arguments

data

A numeric n-dimensional array containing daily data.

dates

A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' is considered.

calendar

A character indicating the calendar type.

base.range

The years used for computing the threshold.

qtiles

Numeric vector with values between 0 and 1 indicating the quantiles to be computed.

ncores

The number of cores to be used when computing the threshold.

na.rm

A logical value. If TRUE, any NA and NaN's are removed before the quantiles are computed (default as FALSE).

Examples

Run this code
##Example synthetic data:
data <- 1:(2 * 3 * 372 * 1)
dim(data) <- c(time = 372, lon = 2, lat = 3, model = 1)
time <- as.POSIXct(paste(sort(rep(1900:1911, 31)), 1, 1:31, sep = "-"), 
                  tz = "CET")
metadata <- list(time = list(standard_name = 'time', long_name = 'time',  
                calendar = 'noleap', 
                units = 'days since 1970-01-01 00:00:00', prec = 'double', 
                dim = list(list(name = 'time', unlim = FALSE))))
attr(time, "variables") <- metadata
attr(data, 'Variables')$dat1$time <- time

a <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, 
              ncores = NULL)
str(a)

Run the code above in your browser using DataLab