From a2a2e1d1573ccb0dd1175a7abbf8325292520ef0 Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 1 Mar 2021 19:12:54 +0100 Subject: [PATCH] Add parameters ncores --- R/SelectPeriodOnData.R | 2 +- R/TotalSpellTimeExceedingThreshold.R | 7 +++++-- man/TotalSpellTimeExceedingThreshold.Rd | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/R/SelectPeriodOnData.R b/R/SelectPeriodOnData.R index 529f787..f9dda6b 100644 --- a/R/SelectPeriodOnData.R +++ b/R/SelectPeriodOnData.R @@ -116,7 +116,7 @@ SelectPeriodOnData <- function(data, dates, start, end, dim(result) <- length(result) names(dim(result)) <- names(dim(x)) return(result) - }, ncores = ncores)$output1 + }, output_dims = time_dim, ncores = ncores)$output1 } else { res <- Apply(list(data, res), target_dims = time_dim, fun = function(x, y) { diff --git a/R/TotalSpellTimeExceedingThreshold.R b/R/TotalSpellTimeExceedingThreshold.R index 45c3203..5997a96 100644 --- a/R/TotalSpellTimeExceedingThreshold.R +++ b/R/TotalSpellTimeExceedingThreshold.R @@ -95,6 +95,7 @@ CST_TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '> #' #'@return A multidimensional array with named dimensions. #' +#'@details This function considers NA values as the end of the spell. For a different behaviour consider to modify the 'data' input by substituting NA values by values exceeding the threshold. #'@import multiApply #'@examples #'data <- array(rnorm(120), c(member = 1, sdate = 2, time = 20, lat = 4)) @@ -149,11 +150,13 @@ TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '>', d ncores = ncores)$output1 } else if (time_dim %in% names(dim(threshold))) { total <- Apply(list(data, threshold), target_dims = list(time_dim, time_dim), - fun = .totalspellthres, spell = spell, op = op)$output1 + fun = .totalspellthres, spell = spell, op = op, + ncores = ncores)$output1 } else { total <- Apply(list(data, threshold), target_dims = list(time_dim, NULL), - fun = .totalspellthres, spell = spell, op = op)$output1 + fun = .totalspellthres, spell = spell, op = op, + ncores = ncores)$output1 } return(total) } diff --git a/man/TotalSpellTimeExceedingThreshold.Rd b/man/TotalSpellTimeExceedingThreshold.Rd index 39ba110..79f3e5d 100644 --- a/man/TotalSpellTimeExceedingThreshold.Rd +++ b/man/TotalSpellTimeExceedingThreshold.Rd @@ -45,6 +45,9 @@ This function allows to compute indicators widely used in Climate Services, such \code{WSDI}{Warm Spell Duration Index that count the total number of days with at least 6 consecutive days when the daily temperature maximum exceeds its 90th percentile.}} This function requires the data and the threshold to be in the same units. The 90th percentile can be translate into absolute values given a reference dataset using function \code{Threshold} or the data can be transform into probabilites by using function \code{AbsToProbs}. See section @examples. } +\details{ +This function considers NA values as the end of the spell. For a different behaviour consider to modify the 'data' input by substituting NA values by values exceeding the threshold. +} \examples{ data <- array(rnorm(120), c(member = 1, sdate = 2, time = 20, lat = 4)) threshold <- array(rnorm(4), c(lat = 4)) -- GitLab