From 07c245d7833d73acd7526d66a60e7b720d68003c Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Fri, 13 Oct 2023 10:15:07 +0200 Subject: [PATCH] Change default time_dim from ftime to time and correct unit tests with it --- R/AbsToProbs.R | 20 ++--- R/AccumulationExceedingThreshold.R | 14 ++-- R/MergeRefToExp.R | 26 +++---- R/PeriodAccumulation.R | 14 ++-- R/QThreshold.R | 10 +-- R/SelectPeriodOnData.R | 16 ++-- R/SelectPeriodOnDates.R | 6 +- R/Threshold.R | 8 +- R/TotalSpellTimeExceedingThreshold.R | 16 ++-- R/TotalTimeExceedingThreshold.R | 16 ++-- R/WindCapacityFactor.R | 8 +- R/WindPowerDensity.R | 8 +- man/AbsToProbs.Rd | 10 +-- man/AccumulationExceedingThreshold.Rd | 6 +- man/CST_AbsToProbs.Rd | 10 +-- man/CST_AccumulationExceedingThreshold.Rd | 8 +- man/CST_MergeRefToExp.Rd | 12 +-- man/CST_PeriodAccumulation.Rd | 10 +-- man/CST_QThreshold.Rd | 10 +-- man/CST_SelectPeriodOnData.Rd | 8 +- man/CST_Threshold.Rd | 8 +- man/CST_TotalSpellTimeExceedingThreshold.Rd | 8 +- man/CST_TotalTimeExceedingThreshold.Rd | 8 +- man/CST_WindCapacityFactor.Rd | 8 +- man/CST_WindPowerDensity.Rd | 8 +- man/MergeRefToExp.Rd | 14 ++-- man/PeriodAccumulation.Rd | 4 +- man/SelectPeriodOnData.Rd | 8 +- man/SelectPeriodOnDates.Rd | 6 +- man/TotalSpellTimeExceedingThreshold.Rd | 8 +- man/TotalTimeExceedingThreshold.Rd | 8 +- tests/testthat/test-AbsToProbs.R | 6 +- .../test-AccumulationExceedingThreshold.R | 58 +++++++-------- tests/testthat/test-MergeRefToExp.R | 74 +++++++++---------- tests/testthat/test-PeriodAccumulation.R | 12 +-- tests/testthat/test-PeriodMax.R | 2 +- tests/testthat/test-PeriodMean.R | 2 +- tests/testthat/test-PeriodMin.R | 2 +- tests/testthat/test-PeriodVariance.R | 6 +- tests/testthat/test-QThreshold.R | 46 ++++++------ tests/testthat/test-SelectPeriod.R | 62 ++++++++-------- tests/testthat/test-Threshold.R | 18 ++--- .../test-TotalSpellTimeExceedingThreshold.R | 54 +++++++------- .../test-TotalTimeExceedingThreshold.R | 54 +++++++------- tests/testthat/test-WindCapacityFactor.R | 8 +- tests/testthat/test-WindPowerDensity.R | 8 +- 46 files changed, 368 insertions(+), 368 deletions(-) diff --git a/R/AbsToProbs.R b/R/AbsToProbs.R index e086e6e..247ba38 100644 --- a/R/AbsToProbs.R +++ b/R/AbsToProbs.R @@ -17,7 +17,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the temporal -#' dimension. By default, it is set to 'ftime'. More than one dimension name +#' dimension. By default, it is set to 'time'. More than one dimension name #' matching the dimensions provided in the object \code{data$data} can be #' specified. This dimension is required to subset the data in a requested #' period. @@ -33,24 +33,24 @@ #'@examples #'exp <- NULL #'exp$data <- array(rnorm(216), dim = c(dataset = 1, member = 2, sdate = 3, -#' ftime = 9, lat = 2, lon = 2)) +#' time = 9, lat = 2, lon = 2)) #'class(exp) <- 's2dv_cube' #'exp_probs <- CST_AbsToProbs(exp) #'exp$data <- array(rnorm(5 * 3 * 214 * 2), -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) +#'dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) #'exp_probs <- CST_AbsToProbs(data = exp, start = list(21, 4), end = list(21, 6)) #'@import multiApply #'@importFrom stats ecdf #'@export CST_AbsToProbs <- function(data, start = NULL, end = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', sdate_dim = 'sdate', ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -102,7 +102,7 @@ CST_AbsToProbs <- function(data, start = NULL, end = NULL, #' 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 \code{data}. #'@param time_dim A character string indicating the name of the temporal -#' dimension. By default, it is set to 'ftime'. More than one dimension name +#' dimension. By default, it is set to 'time'. More than one dimension name #' matching the dimensions provided in the object \code{data$data} can be #' specified. This dimension is required to subset the data in a requested #' period. @@ -118,17 +118,17 @@ CST_AbsToProbs <- function(data, start = NULL, end = NULL, #' #'@examples #'exp <- array(rnorm(216), dim = c(dataset = 1, member = 2, sdate = 3, -#' ftime = 9, lat = 2, lon = 2)) +#' time = 9, lat = 2, lon = 2)) #'exp_probs <- AbsToProbs(exp) #'data <- array(rnorm(5 * 3 * 61 * 1), -#' c(member = 5, sdate = 3, ftime = 61, lon = 1)) +#' c(member = 5, sdate = 3, time = 61, lon = 1)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-06-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-06-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-06-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(ftime = 61, sdate = 3) +#'dim(Dates) <- c(time = 61, sdate = 3) #'exp_probs <- AbsToProbs(data, dates = Dates, start = list(21, 4), #' end = list(21, 6)) #' @@ -136,7 +136,7 @@ CST_AbsToProbs <- function(data, start = NULL, end = NULL, #'@importFrom stats ecdf #'@export AbsToProbs <- function(data, dates = NULL, start = NULL, end = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', sdate_dim = 'sdate', ncores = NULL) { # data if (!is.numeric(data)) { diff --git a/R/AccumulationExceedingThreshold.R b/R/AccumulationExceedingThreshold.R index 083b76c..eecded6 100644 --- a/R/AccumulationExceedingThreshold.R +++ b/R/AccumulationExceedingThreshold.R @@ -40,7 +40,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param na.rm A logical value indicating whether to ignore NA values (TRUE) #' or not (FALSE). @@ -59,7 +59,7 @@ #'@examples #'exp <- NULL #'exp$data <- array(abs(rnorm(5 * 3 * 214 * 2)*100), -#' c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'class(exp) <- 's2dv_cube' #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), @@ -67,7 +67,7 @@ #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #'exp$attrs$Dates <- Dates #'AT <- CST_AccumulationExceedingThreshold(data = exp, threshold = 100, #' start = list(21, 4), @@ -77,7 +77,7 @@ #'@importFrom ClimProjDiags Subset #'@export CST_AccumulationExceedingThreshold <- function(data, threshold, op = '>', diff = FALSE, - start = NULL, end = NULL, time_dim = 'ftime', + start = NULL, end = NULL, time_dim = 'time', na.rm = FALSE, ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -184,7 +184,7 @@ CST_AccumulationExceedingThreshold <- function(data, threshold, op = '>', diff = #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param na.rm A logical value indicating whether to ignore NA values (TRUE) #' or not (FALSE). @@ -198,14 +198,14 @@ CST_AccumulationExceedingThreshold <- function(data, threshold, op = '>', diff = #'@examples #'# Assuming data is already (tasmax + tasmin)/2 - 10 #'data <- array(rnorm(5 * 3 * 214 * 2, mean = 25, sd = 3), -#' c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'GDD <- AccumulationExceedingThreshold(data, threshold = 0, start = list(1, 4), #' end = list(31, 10)) #'@import multiApply #'@export AccumulationExceedingThreshold <- function(data, threshold, op = '>', diff = FALSE, dates = NULL, start = NULL, end = NULL, - time_dim = 'ftime', na.rm = FALSE, + time_dim = 'time', na.rm = FALSE, ncores = NULL) { # data if (is.null(data)) { diff --git a/R/MergeRefToExp.R b/R/MergeRefToExp.R index f5d9069..56c3c3d 100644 --- a/R/MergeRefToExp.R +++ b/R/MergeRefToExp.R @@ -42,7 +42,7 @@ #' the final month of the period. #'@param time_dim A character string indicating the name of the temporal #' dimension that will be used to combine the two arrays. By default, it is set -#' to 'ftime'. Also, it will be used to subset the data in a requested +#' to 'time'. Also, it will be used to subset the data in a requested #' period. #'@param memb_dim A character string indicating the name of the member #' dimension. If the data are not ensemble ones, set as NULL. The default @@ -75,16 +75,16 @@ #' as.Date("01-12-1993","%d-%m-%Y", tz = 'UTC'), "day"), #' seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'), #' as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day")) -#'dim(data_dates) <- c(ftime = 154, sdate = 2) +#'dim(data_dates) <- c(time = 154, sdate = 2) #'data <- NULL -#'data$data <- array(1:(2*154*2), c(ftime = 154, sdate = 2, member = 2)) +#'data$data <- array(1:(2*154*2), c(time = 154, sdate = 2, member = 2)) #'data$attrs$Dates<- data_dates #'class(data) <- 's2dv_cube' #'ref_dates <- seq(as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'), #' as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day") -#'dim(ref_dates) <- c(ftime = 350, sdate = 2) +#'dim(ref_dates) <- c(time = 350, sdate = 2) #'ref <- NULL -#'ref$data <- array(1001:1700, c(ftime = 350, sdate = 2)) +#'ref$data <- array(1001:1700, c(time = 350, sdate = 2)) #'ref$attrs$Dates <- ref_dates #'class(ref) <- 's2dv_cube' #'new_data <- CST_MergeRefToExp(data1 = ref, data2 = data, @@ -94,7 +94,7 @@ #'@export CST_MergeRefToExp <- function(data1, data2, start1 = NULL, end1 = NULL, start2 = NULL, end2 = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', ncores = NULL) { # Check 's2dv_cube' if (!inherits(data1, 's2dv_cube')) { @@ -271,7 +271,7 @@ CST_MergeRefToExp <- function(data1, data2, start1 = NULL, end1 = NULL, #' included in the 'dates2' array. #'@param time_dim A character string indicating the name of the temporal #' dimension that will be used to combine the two arrays. By default, it is set -#' to 'ftime'. Also, it will be used to subset the data in a requested +#' to 'time'. Also, it will be used to subset the data in a requested #' period. #'@param memb_dim A character string indicating the name of the member #' dimension. If the 'data1' and 'data2' have no member dimension, set it as @@ -302,22 +302,22 @@ CST_MergeRefToExp <- function(data1, data2, start1 = NULL, end1 = NULL, #' as.Date("01-12-1993","%d-%m-%Y", tz = 'UTC'), "day"), #' seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'), #' as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day")) -#'dim(data_dates) <- c(ftime = 154, sdate = 2) +#'dim(data_dates) <- c(time = 154, sdate = 2) #'ref_dates <- seq(as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'), #' as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day") -#'dim(ref_dates) <- c(ftime = 350, sdate = 2) -#'ref <- array(1001:1700, c(ftime = 350, sdate = 2)) -#'data <- array(1:(2*154*2), c(ftime = 154, sdate = 2, member = 2)) +#'dim(ref_dates) <- c(time = 350, sdate = 2) +#'ref <- array(1001:1700, c(time = 350, sdate = 2)) +#'data <- array(1:(2*154*2), c(time = 154, sdate = 2, member = 2)) #'new_data <- MergeRefToExp(data1 = ref, dates1 = ref_dates, start1 = list(21, 6), #' end1 = list(30, 6), data2 = data, dates2 = data_dates, #' start2 = list(1, 7), end = list(21, 9), -#' time_dim = 'ftime') +#' time_dim = 'time') #' #'@import multiApply #'@export MergeRefToExp <- function(data1, data2, dates1 = NULL, dates2 = NULL, start1 = NULL, end1 = NULL, start2 = NULL, end2 = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', ncores = NULL) { # Input checks ## data1 and data2 diff --git a/R/PeriodAccumulation.R b/R/PeriodAccumulation.R index 3b0d33d..b8dcf9a 100644 --- a/R/PeriodAccumulation.R +++ b/R/PeriodAccumulation.R @@ -22,7 +22,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. More than one +#' compute the indicator. By default, it is set to 'time'. More than one #' dimension name matching the dimensions provided in the object #' \code{data$data} can be specified. #'@param na.rm A logical value indicating whether to ignore NA values (TRUE) or @@ -42,18 +42,18 @@ #'@examples #'exp <- NULL #'exp$data <- array(rnorm(216)*200, dim = c(dataset = 1, member = 2, sdate = 3, -#' ftime = 9, lat = 2, lon = 2)) +#' time = 9, lat = 2, lon = 2)) #'class(exp) <- 's2dv_cube' #'TP <- CST_PeriodAccumulation(exp) #'exp$data <- array(rnorm(5 * 3 * 214 * 2), -#' c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #'exp$attrs$Dates <- Dates #'SprR <- CST_PeriodAccumulation(exp, start = list(21, 4), end = list(21, 6)) #'dim(SprR$data) @@ -66,7 +66,7 @@ #'@importFrom ClimProjDiags Subset #'@export CST_PeriodAccumulation <- function(data, start = NULL, end = NULL, - time_dim = 'ftime', na.rm = FALSE, + time_dim = 'time', na.rm = FALSE, ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -150,8 +150,8 @@ CST_PeriodAccumulation <- function(data, start = NULL, end = NULL, #' #'@examples #'exp <- array(rnorm(216)*200, dim = c(dataset = 1, member = 2, sdate = 3, -#' ftime = 9, lat = 2, lon = 2)) -#'TP <- PeriodAccumulation(exp, time_dim = 'ftime') +#' time = 9, lat = 2, lon = 2)) +#'TP <- PeriodAccumulation(exp, time_dim = 'time') #'data <- array(rnorm(5 * 3 * 214 * 2), #' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), diff --git a/R/QThreshold.R b/R/QThreshold.R index c5089df..4686cb3 100644 --- a/R/QThreshold.R +++ b/R/QThreshold.R @@ -37,7 +37,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the temporal -#' dimension. By default, it is set to 'ftime'. More than one dimension name +#' dimension. By default, it is set to 'time'. More than one dimension name #' matching the dimensions provided in the object \code{data$data} can be #' specified. This dimension is required to subset the data in a requested #' period. @@ -54,19 +54,19 @@ #'@examples #'threshold <- 26 #'exp <- NULL -#'exp$data <- array(abs(rnorm(112)*26), dim = c(member = 7, sdate = 8, ftime = 2)) +#'exp$data <- array(abs(rnorm(112)*26), dim = c(member = 7, sdate = 8, time = 2)) #'class(exp) <- 's2dv_cube' #'exp_probs <- CST_QThreshold(exp, threshold) #' #'exp$data <- array(abs(rnorm(5 * 3 * 214 * 2)*50), -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +#'dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) #'class(exp) <- 's2dv_cube' #'exp_probs <- CST_QThreshold(exp, threshold, start = list(21, 4), #' end = list(21, 6)) @@ -74,7 +74,7 @@ #'@import multiApply #'@export CST_QThreshold <- function(data, threshold, start = NULL, end = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', sdate_dim = 'sdate', ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { diff --git a/R/SelectPeriodOnData.R b/R/SelectPeriodOnData.R index 94bcfe9..016133b 100644 --- a/R/SelectPeriodOnData.R +++ b/R/SelectPeriodOnData.R @@ -11,7 +11,7 @@ #' the data by providing a list of two elements: the final day of the period #' and the final month of the period. #'@param time_dim A character string indicating the name of the dimension to -#' compute select the dates. By default, it is set to 'ftime'. More than one +#' compute select the dates. By default, it is set to 'time'. More than one #' dimension name matching the dimensions provided in the object #' \code{data$data} can be specified. #'@param ncores An integer indicating the number of cores to use in parallel @@ -23,19 +23,19 @@ #'@examples #'exp <- NULL #'exp$data <- array(rnorm(5 * 3 * 214 * 2), -#' c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) +#'dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) #'class(exp) <- 's2dv_cube' #'Period <- CST_SelectPeriodOnData(exp, start = list(21, 6), end = list(21, 9)) #'@import multiApply #'@export -CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'ftime', +CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'time', ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -79,7 +79,7 @@ CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'ftime', #' to select from the data. The first element is the final day of the period #' and the second element is the final month of the period. #'@param time_dim A character string indicating the name of the dimension to -#' compute select the dates. By default, it is set to 'ftime'. Parameters +#' compute select the dates. By default, it is set to 'time'. Parameters #' 'data' and 'dates' #'@param ncores An integer indicating the number of cores to use in parallel #' computation. @@ -90,19 +90,19 @@ CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'ftime', #' #'@examples #'data <- array(rnorm(5 * 3 * 214 * 2), -#' c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(memb = 5, sdate = 3, time = 214, lon = 2)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(ftime = 214, sdate = 3) +#'dim(Dates) <- c(time = 214, sdate = 3) #'Period <- SelectPeriodOnData(data, Dates, start = list(21, 6), end = list(21, 9)) #'@import multiApply #'@export SelectPeriodOnData <- function(data, dates, start, end, - time_dim = 'ftime', ncores = NULL) { + time_dim = 'time', ncores = NULL) { if (is.null(dim(dates))) { dim(dates) <- length(dates) names(dim(dates)) <- time_dim diff --git a/R/SelectPeriodOnDates.R b/R/SelectPeriodOnDates.R index fcb1a4c..0919c5d 100644 --- a/R/SelectPeriodOnDates.R +++ b/R/SelectPeriodOnDates.R @@ -10,7 +10,7 @@ #' select from the data by providing a list of two elements: the final day of #' the period and the final month of the period. #'@param time_dim A character string indicating the name of the dimension to -#' compute select the dates. By default, it is set to 'ftime'. More than one +#' compute select the dates. By default, it is set to 'time'. More than one #' dimension name matching the dimensions provided in the object #' \code{data$data} can be specified. #'@param ncores An integer indicating the number of cores to use in parallel @@ -28,11 +28,11 @@ #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(ftime = 214, sdate = 3) +#'dim(Dates) <- c(time = 214, sdate = 3) #'Period <- SelectPeriodOnDates(Dates, start = list(21, 6), end = list(21, 9)) #'@export SelectPeriodOnDates <- function(dates, start, end, - time_dim = 'ftime', ncores = NULL) { + time_dim = 'time', ncores = NULL) { if (is.null(dim(dates))) { dim(dates) <- length(dates) names(dim(dates)) <- time_dim diff --git a/R/Threshold.R b/R/Threshold.R index 73e3715..9efaebd 100644 --- a/R/Threshold.R +++ b/R/Threshold.R @@ -19,7 +19,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the temporal -#' dimension. By default, it is set to 'ftime'. More than one dimension name +#' dimension. By default, it is set to 'time'. More than one dimension name #' matching the dimensions provided in the object \code{data$data} can be #' specified. This dimension is required to subset the data in a requested #' period. @@ -40,21 +40,21 @@ #'threshold <- 0.9 #'exp <- NULL #'exp$data <- array(rnorm(5 * 3 * 214 * 2), -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +#'dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) #'class(exp) <- 's2dv_cube' #'exp_probs <- CST_Threshold(exp, threshold, start = list(21, 4), end = list(21, 6)) #' #'@import multiApply #'@export CST_Threshold <- function(data, threshold, start = NULL, end = NULL, - time_dim = 'ftime', memb_dim = 'member', + time_dim = 'time', memb_dim = 'member', sdate_dim = 'sdate', na.rm = FALSE, ncores = NULL) { # Check 's2dv_cube' diff --git a/R/TotalSpellTimeExceedingThreshold.R b/R/TotalSpellTimeExceedingThreshold.R index 38a3ff4..b7e33cf 100644 --- a/R/TotalSpellTimeExceedingThreshold.R +++ b/R/TotalSpellTimeExceedingThreshold.R @@ -42,7 +42,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param ncores An integer indicating the number of cores to use in parallel #' computation. @@ -59,14 +59,14 @@ #'@examples #'exp <- NULL #'exp$data <- array(rnorm(5 * 3 * 214 * 2)*23, -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +#'dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) #'class(exp) <- 's2dv_cube' #'TTSET <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = 23, spell = 3, #' start = list(21, 4), @@ -77,7 +77,7 @@ #'@export CST_TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '>', start = NULL, end = NULL, - time_dim = 'ftime', + time_dim = 'time', ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -188,7 +188,7 @@ CST_TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '> #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param ncores An integer indicating the number of cores to use in parallel #' computation. @@ -203,14 +203,14 @@ CST_TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '> #'values by values exceeding the threshold. #'@examples -#'data <- array(1:100, c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#'data <- array(1:100, c(member = 5, sdate = 3, time = 214, lon = 2)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #' #'threshold <- array(1:4, c(lat = 4)) #'total <- TotalSpellTimeExceedingThreshold(data, threshold, dates = Dates, @@ -221,7 +221,7 @@ CST_TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '> #'@export TotalSpellTimeExceedingThreshold <- function(data, threshold, spell, op = '>', dates = NULL, start = NULL, end = NULL, - time_dim = 'ftime', ncores = NULL) { + time_dim = 'time', ncores = NULL) { # data if (is.null(data)) { stop("Parameter 'data' cannot be NULL.") diff --git a/R/TotalTimeExceedingThreshold.R b/R/TotalTimeExceedingThreshold.R index 94d2c53..4d46260 100644 --- a/R/TotalTimeExceedingThreshold.R +++ b/R/TotalTimeExceedingThreshold.R @@ -45,7 +45,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param na.rm A logical value indicating whether to ignore NA values (TRUE) or #' not (FALSE). @@ -65,14 +65,14 @@ #'@examples #'exp <- NULL #'exp$data <- array(rnorm(5 * 3 * 214 * 2)*23, -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +#'dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) #'class(exp) <- 's2dv_cube' #'DOT <- CST_TotalTimeExceedingThreshold(exp, threshold = 23, start = list(21, 4), #' end = list(21, 6)) @@ -82,7 +82,7 @@ #'@export CST_TotalTimeExceedingThreshold <- function(data, threshold, op = '>', start = NULL, end = NULL, - time_dim = 'ftime', + time_dim = 'time', na.rm = FALSE, ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { @@ -194,7 +194,7 @@ CST_TotalTimeExceedingThreshold <- function(data, threshold, op = '>', #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. It can only +#' compute the indicator. By default, it is set to 'time'. It can only #' indicate one time dimension. #'@param na.rm A logical value indicating whether to ignore NA values (TRUE) or #' not (FALSE). @@ -208,14 +208,14 @@ CST_TotalTimeExceedingThreshold <- function(data, threshold, op = '>', #' #'@examples #'data <- array(rnorm(5 * 3 * 214 * 2)*23, -#' c(member = 5, sdate = 3, ftime = 214, lon = 2)) +#' c(member = 5, sdate = 3, time = 214, lon = 2)) #'Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), #' as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2001", format = "%d-%m-%Y"), #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #'DOT <- TotalTimeExceedingThreshold(data, threshold = 23, dates = Dates, #' start = list(21, 4), end = list(21, 6)) #' @@ -223,7 +223,7 @@ CST_TotalTimeExceedingThreshold <- function(data, threshold, op = '>', #'@export TotalTimeExceedingThreshold <- function(data, threshold, op = '>', dates = NULL, start = NULL, end = NULL, - time_dim = 'ftime', na.rm = FALSE, + time_dim = 'time', na.rm = FALSE, ncores = NULL) { # data if (is.null(data)) { diff --git a/R/WindCapacityFactor.R b/R/WindCapacityFactor.R index 76092dd..dc12fb4 100644 --- a/R/WindCapacityFactor.R +++ b/R/WindCapacityFactor.R @@ -32,7 +32,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. More than one +#' compute the indicator. By default, it is set to 'time'. More than one #' dimension name matching the dimensions provided in the object #' \code{data$data} can be specified. #'@param ncores An integer indicating the number of cores to use in parallel @@ -42,7 +42,7 @@ #'@examples #'wind <- NULL #'wind$data <- array(rweibull(n = 100, shape = 2, scale = 6), -#' c(member = 5, sdate = 3, ftime = 214, lon = 2, lat = 5)) +#' c(member = 5, sdate = 3, time = 214, lon = 2, lat = 5)) #'wind$coords <- list(lat = c(40, 41), lon = 1:5) #'variable <- list(varName = 'sfcWind', #' metadata = list(sfcWind = list(level = 'Surface'))) @@ -54,7 +54,7 @@ #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #'wind$attrs$Dates <- Dates #'class(wind) <- 's2dv_cube' #'WCF <- CST_WindCapacityFactor(wind, IEC_class = "III", @@ -62,7 +62,7 @@ #' #'@export CST_WindCapacityFactor <- function(wind, IEC_class = c("I", "I/II", "II", "II/III", "III"), - start = NULL, end = NULL, time_dim = 'ftime', + start = NULL, end = NULL, time_dim = 'time', ncores = NULL) { # Check 's2dv_cube' if (!inherits(wind, 's2dv_cube')) { diff --git a/R/WindPowerDensity.R b/R/WindPowerDensity.R index 3944e3d..3dc835a 100644 --- a/R/WindPowerDensity.R +++ b/R/WindPowerDensity.R @@ -21,7 +21,7 @@ #' 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 \code{data}. #'@param time_dim A character string indicating the name of the dimension to -#' compute the indicator. By default, it is set to 'ftime'. More than one +#' compute the indicator. By default, it is set to 'time'. More than one #' dimension name matching the dimensions provided in the object #' \code{data$data} can be specified. #'@param ncores An integer indicating the number of cores to use in parallel @@ -32,7 +32,7 @@ #'@examples #'wind <- NULL #'wind$data <- array(rweibull(n = 100, shape = 2, scale = 6), -#' c(member = 5, sdate = 3, ftime = 214, lon = 2, lat = 5)) +#' c(member = 5, sdate = 3, time = 214, lon = 2, lat = 5)) #'wind$coords <- list(lat = c(40, 41), lon = 1:5) #'variable <- list(varName = 'sfcWind', #' metadata = list(sfcWind = list(level = 'Surface'))) @@ -44,7 +44,7 @@ #' as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) -#'dim(Dates) <- c(sdate = 3, ftime = 214) +#'dim(Dates) <- c(sdate = 3, time = 214) #'wind$attrs$Dates <- Dates #'class(wind) <- 's2dv_cube' #'WPD <- CST_WindPowerDensity(wind, start = list(21, 4), @@ -52,7 +52,7 @@ #' #'@export CST_WindPowerDensity <- function(wind, ro = 1.225, start = NULL, end = NULL, - time_dim = 'ftime', ncores = NULL) { + time_dim = 'time', ncores = NULL) { # Check 's2dv_cube' if (!inherits(wind, 's2dv_cube')) { stop("Parameter 'wind' must be of the class 's2dv_cube'.") diff --git a/man/AbsToProbs.Rd b/man/AbsToProbs.Rd index 7717c91..a4e99ba 100644 --- a/man/AbsToProbs.Rd +++ b/man/AbsToProbs.Rd @@ -9,7 +9,7 @@ AbsToProbs( dates = NULL, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", sdate_dim = "sdate", ncores = NULL @@ -36,7 +36,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the temporal -dimension. By default, it is set to 'ftime'. More than one dimension name +dimension. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified. This dimension is required to subset the data in a requested period.} @@ -62,17 +62,17 @@ Distribution Function excluding the corresponding initialization. } \examples{ exp <- array(rnorm(216), dim = c(dataset = 1, member = 2, sdate = 3, - ftime = 9, lat = 2, lon = 2)) + time = 9, lat = 2, lon = 2)) exp_probs <- AbsToProbs(exp) data <- array(rnorm(5 * 3 * 61 * 1), - c(member = 5, sdate = 3, ftime = 61, lon = 1)) + c(member = 5, sdate = 3, time = 61, lon = 1)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-06-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-06-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-06-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(ftime = 61, sdate = 3) +dim(Dates) <- c(time = 61, sdate = 3) exp_probs <- AbsToProbs(data, dates = Dates, start = list(21, 4), end = list(21, 6)) diff --git a/man/AccumulationExceedingThreshold.Rd b/man/AccumulationExceedingThreshold.Rd index 0f9a64a..cf6c8df 100644 --- a/man/AccumulationExceedingThreshold.Rd +++ b/man/AccumulationExceedingThreshold.Rd @@ -12,7 +12,7 @@ AccumulationExceedingThreshold( dates = NULL, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", na.rm = FALSE, ncores = NULL ) @@ -55,7 +55,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{na.rm}{A logical value indicating whether to ignore NA values (TRUE) @@ -85,7 +85,7 @@ function: \examples{ # Assuming data is already (tasmax + tasmin)/2 - 10 data <- array(rnorm(5 * 3 * 214 * 2, mean = 25, sd = 3), - c(memb = 5, sdate = 3, ftime = 214, lon = 2)) + c(memb = 5, sdate = 3, time = 214, lon = 2)) GDD <- AccumulationExceedingThreshold(data, threshold = 0, start = list(1, 4), end = list(31, 10)) } diff --git a/man/CST_AbsToProbs.Rd b/man/CST_AbsToProbs.Rd index 055bf6b..ef8f42d 100644 --- a/man/CST_AbsToProbs.Rd +++ b/man/CST_AbsToProbs.Rd @@ -8,7 +8,7 @@ CST_AbsToProbs( data, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", sdate_dim = "sdate", ncores = NULL @@ -30,7 +30,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the temporal -dimension. By default, it is set to 'ftime'. More than one dimension name +dimension. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified. This dimension is required to subset the data in a requested period.} @@ -56,17 +56,17 @@ Distribution Function excluding the corresponding initialization. \examples{ exp <- NULL exp$data <- array(rnorm(216), dim = c(dataset = 1, member = 2, sdate = 3, - ftime = 9, lat = 2, lon = 2)) + time = 9, lat = 2, lon = 2)) class(exp) <- 's2dv_cube' exp_probs <- CST_AbsToProbs(exp) exp$data <- array(rnorm(5 * 3 * 214 * 2), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) +dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) exp_probs <- CST_AbsToProbs(data = exp, start = list(21, 4), end = list(21, 6)) } diff --git a/man/CST_AccumulationExceedingThreshold.Rd b/man/CST_AccumulationExceedingThreshold.Rd index ff02e4c..2bdee76 100644 --- a/man/CST_AccumulationExceedingThreshold.Rd +++ b/man/CST_AccumulationExceedingThreshold.Rd @@ -11,7 +11,7 @@ CST_AccumulationExceedingThreshold( diff = FALSE, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", na.rm = FALSE, ncores = NULL ) @@ -51,7 +51,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{na.rm}{A logical value indicating whether to ignore NA values (TRUE) @@ -86,7 +86,7 @@ function: \examples{ exp <- NULL exp$data <- array(abs(rnorm(5 * 3 * 214 * 2)*100), - c(memb = 5, sdate = 3, ftime = 214, lon = 2)) + c(memb = 5, sdate = 3, time = 214, lon = 2)) class(exp) <- 's2dv_cube' Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), @@ -94,7 +94,7 @@ Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) exp$attrs$Dates <- Dates AT <- CST_AccumulationExceedingThreshold(data = exp, threshold = 100, start = list(21, 4), diff --git a/man/CST_MergeRefToExp.Rd b/man/CST_MergeRefToExp.Rd index a49c9dc..9832912 100644 --- a/man/CST_MergeRefToExp.Rd +++ b/man/CST_MergeRefToExp.Rd @@ -11,7 +11,7 @@ CST_MergeRefToExp( end1 = NULL, start2 = NULL, end2 = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", ncores = NULL ) @@ -49,7 +49,7 @@ the final month of the period.} \item{time_dim}{A character string indicating the name of the temporal dimension that will be used to combine the two arrays. By default, it is set -to 'ftime'. Also, it will be used to subset the data in a requested +to 'time'. Also, it will be used to subset the data in a requested period.} \item{memb_dim}{A character string indicating the name of the member @@ -98,16 +98,16 @@ data_dates <- c(seq(as.Date("01-07-1993", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1993","\%d-\%m-\%Y", tz = 'UTC'), "day"), seq(as.Date("01-07-1994", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1994","\%d-\%m-\%Y", tz = 'UTC'), "day")) -dim(data_dates) <- c(ftime = 154, sdate = 2) +dim(data_dates) <- c(time = 154, sdate = 2) data <- NULL -data$data <- array(1:(2*154*2), c(ftime = 154, sdate = 2, member = 2)) +data$data <- array(1:(2*154*2), c(time = 154, sdate = 2, member = 2)) data$attrs$Dates<- data_dates class(data) <- 's2dv_cube' ref_dates <- seq(as.Date("01-01-1993", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1994","\%d-\%m-\%Y", tz = 'UTC'), "day") -dim(ref_dates) <- c(ftime = 350, sdate = 2) +dim(ref_dates) <- c(time = 350, sdate = 2) ref <- NULL -ref$data <- array(1001:1700, c(ftime = 350, sdate = 2)) +ref$data <- array(1001:1700, c(time = 350, sdate = 2)) ref$attrs$Dates <- ref_dates class(ref) <- 's2dv_cube' new_data <- CST_MergeRefToExp(data1 = ref, data2 = data, diff --git a/man/CST_PeriodAccumulation.Rd b/man/CST_PeriodAccumulation.Rd index 77f4a38..2c8fb5a 100644 --- a/man/CST_PeriodAccumulation.Rd +++ b/man/CST_PeriodAccumulation.Rd @@ -8,7 +8,7 @@ CST_PeriodAccumulation( data, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", na.rm = FALSE, ncores = NULL ) @@ -29,7 +29,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. More than one +compute the indicator. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified.} @@ -63,18 +63,18 @@ by using this function: \examples{ exp <- NULL exp$data <- array(rnorm(216)*200, dim = c(dataset = 1, member = 2, sdate = 3, - ftime = 9, lat = 2, lon = 2)) + time = 9, lat = 2, lon = 2)) class(exp) <- 's2dv_cube' TP <- CST_PeriodAccumulation(exp) exp$data <- array(rnorm(5 * 3 * 214 * 2), - c(memb = 5, sdate = 3, ftime = 214, lon = 2)) + c(memb = 5, sdate = 3, time = 214, lon = 2)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) exp$attrs$Dates <- Dates SprR <- CST_PeriodAccumulation(exp, start = list(21, 4), end = list(21, 6)) dim(SprR$data) diff --git a/man/CST_QThreshold.Rd b/man/CST_QThreshold.Rd index 5a68bc3..b168375 100644 --- a/man/CST_QThreshold.Rd +++ b/man/CST_QThreshold.Rd @@ -9,7 +9,7 @@ CST_QThreshold( threshold, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", sdate_dim = "sdate", ncores = NULL @@ -35,7 +35,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the temporal -dimension. By default, it is set to 'ftime'. More than one dimension name +dimension. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified. This dimension is required to subset the data in a requested period.} @@ -80,19 +80,19 @@ and memb_dim parameters: \examples{ threshold <- 26 exp <- NULL -exp$data <- array(abs(rnorm(112)*26), dim = c(member = 7, sdate = 8, ftime = 2)) +exp$data <- array(abs(rnorm(112)*26), dim = c(member = 7, sdate = 8, time = 2)) class(exp) <- 's2dv_cube' exp_probs <- CST_QThreshold(exp, threshold) exp$data <- array(abs(rnorm(5 * 3 * 214 * 2)*50), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) class(exp) <- 's2dv_cube' exp_probs <- CST_QThreshold(exp, threshold, start = list(21, 4), end = list(21, 6)) diff --git a/man/CST_SelectPeriodOnData.Rd b/man/CST_SelectPeriodOnData.Rd index 22b2a9c..5f12633 100644 --- a/man/CST_SelectPeriodOnData.Rd +++ b/man/CST_SelectPeriodOnData.Rd @@ -4,7 +4,7 @@ \alias{CST_SelectPeriodOnData} \title{Select a period on Data on 's2dv_cube' objects} \usage{ -CST_SelectPeriodOnData(data, start, end, time_dim = "ftime", ncores = NULL) +CST_SelectPeriodOnData(data, start, end, time_dim = "time", ncores = NULL) } \arguments{ \item{data}{An 's2dv_cube' object as provided function \code{CST_Load} in @@ -19,7 +19,7 @@ the data by providing a list of two elements: the final day of the period and the final month of the period.} \item{time_dim}{A character string indicating the name of the dimension to -compute select the dates. By default, it is set to 'ftime'. More than one +compute select the dates. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified.} @@ -36,14 +36,14 @@ Auxiliary function to subset data for a specific period. \examples{ exp <- NULL exp$data <- array(rnorm(5 * 3 * 214 * 2), - c(memb = 5, sdate = 3, ftime = 214, lon = 2)) + c(memb = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) +dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) class(exp) <- 's2dv_cube' Period <- CST_SelectPeriodOnData(exp, start = list(21, 6), end = list(21, 9)) } diff --git a/man/CST_Threshold.Rd b/man/CST_Threshold.Rd index e513ec0..2b4ea2f 100644 --- a/man/CST_Threshold.Rd +++ b/man/CST_Threshold.Rd @@ -9,7 +9,7 @@ CST_Threshold( threshold, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", sdate_dim = "sdate", na.rm = FALSE, @@ -35,7 +35,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the temporal -dimension. By default, it is set to 'ftime'. More than one dimension name +dimension. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified. This dimension is required to subset the data in a requested period.} @@ -67,14 +67,14 @@ given a dataset. threshold <- 0.9 exp <- NULL exp$data <- array(rnorm(5 * 3 * 214 * 2), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) class(exp) <- 's2dv_cube' exp_probs <- CST_Threshold(exp, threshold, start = list(21, 4), end = list(21, 6)) diff --git a/man/CST_TotalSpellTimeExceedingThreshold.Rd b/man/CST_TotalSpellTimeExceedingThreshold.Rd index 0715414..940478f 100644 --- a/man/CST_TotalSpellTimeExceedingThreshold.Rd +++ b/man/CST_TotalSpellTimeExceedingThreshold.Rd @@ -11,7 +11,7 @@ CST_TotalSpellTimeExceedingThreshold( op = ">", start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", ncores = NULL ) } @@ -48,7 +48,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{ncores}{An integer indicating the number of cores to use in parallel @@ -83,14 +83,14 @@ by using function \code{AbsToProbs}. See section @examples. \examples{ exp <- NULL exp$data <- array(rnorm(5 * 3 * 214 * 2)*23, - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) class(exp) <- 's2dv_cube' TTSET <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = 23, spell = 3, start = list(21, 4), diff --git a/man/CST_TotalTimeExceedingThreshold.Rd b/man/CST_TotalTimeExceedingThreshold.Rd index 4a1f736..cd99163 100644 --- a/man/CST_TotalTimeExceedingThreshold.Rd +++ b/man/CST_TotalTimeExceedingThreshold.Rd @@ -10,7 +10,7 @@ CST_TotalTimeExceedingThreshold( op = ">", start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", na.rm = FALSE, ncores = NULL ) @@ -46,7 +46,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{na.rm}{A logical value indicating whether to ignore NA values (TRUE) or @@ -90,14 +90,14 @@ indices for heat stress can be obtained by using this function: \examples{ exp <- NULL exp$data <- array(rnorm(5 * 3 * 214 * 2)*23, - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) exp$attrs$Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(exp$attrs$Dates) <- c(sdate = 3, ftime = 214) +dim(exp$attrs$Dates) <- c(sdate = 3, time = 214) class(exp) <- 's2dv_cube' DOT <- CST_TotalTimeExceedingThreshold(exp, threshold = 23, start = list(21, 4), end = list(21, 6)) diff --git a/man/CST_WindCapacityFactor.Rd b/man/CST_WindCapacityFactor.Rd index 84c057d..cea2b06 100644 --- a/man/CST_WindCapacityFactor.Rd +++ b/man/CST_WindCapacityFactor.Rd @@ -9,7 +9,7 @@ CST_WindCapacityFactor( IEC_class = c("I", "I/II", "II", "II/III", "III"), start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", ncores = NULL ) } @@ -35,7 +35,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. More than one +compute the indicator. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified.} @@ -60,7 +60,7 @@ below). \examples{ wind <- NULL wind$data <- array(rweibull(n = 100, shape = 2, scale = 6), - c(member = 5, sdate = 3, ftime = 214, lon = 2, lat = 5)) + c(member = 5, sdate = 3, time = 214, lon = 2, lat = 5)) wind$coords <- list(lat = c(40, 41), lon = 1:5) variable <- list(varName = 'sfcWind', metadata = list(sfcWind = list(level = 'Surface'))) @@ -72,7 +72,7 @@ Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) wind$attrs$Dates <- Dates class(wind) <- 's2dv_cube' WCF <- CST_WindCapacityFactor(wind, IEC_class = "III", diff --git a/man/CST_WindPowerDensity.Rd b/man/CST_WindPowerDensity.Rd index 4b04aed..d37fd9d 100644 --- a/man/CST_WindPowerDensity.Rd +++ b/man/CST_WindPowerDensity.Rd @@ -9,7 +9,7 @@ CST_WindPowerDensity( ro = 1.225, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", ncores = NULL ) } @@ -33,7 +33,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. More than one +compute the indicator. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified.} @@ -53,7 +53,7 @@ it will give inaccurate results if used with period means. \examples{ wind <- NULL wind$data <- array(rweibull(n = 100, shape = 2, scale = 6), - c(member = 5, sdate = 3, ftime = 214, lon = 2, lat = 5)) + c(member = 5, sdate = 3, time = 214, lon = 2, lat = 5)) wind$coords <- list(lat = c(40, 41), lon = 1:5) variable <- list(varName = 'sfcWind', metadata = list(sfcWind = list(level = 'Surface'))) @@ -65,7 +65,7 @@ Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) wind$attrs$Dates <- Dates class(wind) <- 's2dv_cube' WPD <- CST_WindPowerDensity(wind, start = list(21, 4), diff --git a/man/MergeRefToExp.Rd b/man/MergeRefToExp.Rd index 33b5d42..81cda03 100644 --- a/man/MergeRefToExp.Rd +++ b/man/MergeRefToExp.Rd @@ -13,7 +13,7 @@ MergeRefToExp( end1 = NULL, start2 = NULL, end2 = NULL, - time_dim = "ftime", + time_dim = "time", memb_dim = "member", ncores = NULL ) @@ -57,7 +57,7 @@ included in the 'dates2' array.} \item{time_dim}{A character string indicating the name of the temporal dimension that will be used to combine the two arrays. By default, it is set -to 'ftime'. Also, it will be used to subset the data in a requested +to 'time'. Also, it will be used to subset the data in a requested period.} \item{memb_dim}{A character string indicating the name of the member @@ -103,16 +103,16 @@ data_dates <- c(seq(as.Date("01-07-1993", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1993","\%d-\%m-\%Y", tz = 'UTC'), "day"), seq(as.Date("01-07-1994", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1994","\%d-\%m-\%Y", tz = 'UTC'), "day")) -dim(data_dates) <- c(ftime = 154, sdate = 2) +dim(data_dates) <- c(time = 154, sdate = 2) ref_dates <- seq(as.Date("01-01-1993", "\%d-\%m-\%Y", tz = 'UTC'), as.Date("01-12-1994","\%d-\%m-\%Y", tz = 'UTC'), "day") -dim(ref_dates) <- c(ftime = 350, sdate = 2) -ref <- array(1001:1700, c(ftime = 350, sdate = 2)) -data <- array(1:(2*154*2), c(ftime = 154, sdate = 2, member = 2)) +dim(ref_dates) <- c(time = 350, sdate = 2) +ref <- array(1001:1700, c(time = 350, sdate = 2)) +data <- array(1:(2*154*2), c(time = 154, sdate = 2, member = 2)) new_data <- MergeRefToExp(data1 = ref, dates1 = ref_dates, start1 = list(21, 6), end1 = list(30, 6), data2 = data, dates2 = data_dates, start2 = list(1, 7), end = list(21, 9), - time_dim = 'ftime') + time_dim = 'time') } \references{ diff --git a/man/PeriodAccumulation.Rd b/man/PeriodAccumulation.Rd index 614b65c..e9ee608 100644 --- a/man/PeriodAccumulation.Rd +++ b/man/PeriodAccumulation.Rd @@ -60,8 +60,8 @@ by using this function: } \examples{ exp <- array(rnorm(216)*200, dim = c(dataset = 1, member = 2, sdate = 3, - ftime = 9, lat = 2, lon = 2)) -TP <- PeriodAccumulation(exp, time_dim = 'ftime') + time = 9, lat = 2, lon = 2)) +TP <- PeriodAccumulation(exp, time_dim = 'time') data <- array(rnorm(5 * 3 * 214 * 2), c(memb = 5, sdate = 3, time = 214, lon = 2)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), diff --git a/man/SelectPeriodOnData.Rd b/man/SelectPeriodOnData.Rd index caaa0fb..2c6181f 100644 --- a/man/SelectPeriodOnData.Rd +++ b/man/SelectPeriodOnData.Rd @@ -4,7 +4,7 @@ \alias{SelectPeriodOnData} \title{Select a period on Data on multidimensional array objects} \usage{ -SelectPeriodOnData(data, dates, start, end, time_dim = "ftime", ncores = NULL) +SelectPeriodOnData(data, dates, start, end, time_dim = "time", ncores = NULL) } \arguments{ \item{data}{A multidimensional array with named dimensions with at least the @@ -24,7 +24,7 @@ to select from the data. The first element is the final day of the period and the second element is the final month of the period.} \item{time_dim}{A character string indicating the name of the dimension to -compute select the dates. By default, it is set to 'ftime'. Parameters +compute select the dates. By default, it is set to 'time'. Parameters 'data' and 'dates'} \item{ncores}{An integer indicating the number of cores to use in parallel @@ -40,13 +40,13 @@ Auxiliary function to subset data for a specific period. } \examples{ data <- array(rnorm(5 * 3 * 214 * 2), - c(memb = 5, sdate = 3, ftime = 214, lon = 2)) + c(memb = 5, sdate = 3, time = 214, lon = 2)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(ftime = 214, sdate = 3) +dim(Dates) <- c(time = 214, sdate = 3) Period <- SelectPeriodOnData(data, Dates, start = list(21, 6), end = list(21, 9)) } diff --git a/man/SelectPeriodOnDates.Rd b/man/SelectPeriodOnDates.Rd index 386fb92..49ecd9b 100644 --- a/man/SelectPeriodOnDates.Rd +++ b/man/SelectPeriodOnDates.Rd @@ -4,7 +4,7 @@ \alias{SelectPeriodOnDates} \title{Select a period on Dates} \usage{ -SelectPeriodOnDates(dates, start, end, time_dim = "ftime", ncores = NULL) +SelectPeriodOnDates(dates, start, end, time_dim = "time", ncores = NULL) } \arguments{ \item{dates}{An array of dates with named dimensions.} @@ -18,7 +18,7 @@ select from the data by providing a list of two elements: the final day of the period and the final month of the period.} \item{time_dim}{A character string indicating the name of the dimension to -compute select the dates. By default, it is set to 'ftime'. More than one +compute select the dates. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object \code{data$data} can be specified.} @@ -39,6 +39,6 @@ Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(ftime = 214, sdate = 3) +dim(Dates) <- c(time = 214, sdate = 3) Period <- SelectPeriodOnDates(Dates, start = list(21, 6), end = list(21, 9)) } diff --git a/man/TotalSpellTimeExceedingThreshold.Rd b/man/TotalSpellTimeExceedingThreshold.Rd index 10124de..ea1a6ab 100644 --- a/man/TotalSpellTimeExceedingThreshold.Rd +++ b/man/TotalSpellTimeExceedingThreshold.Rd @@ -12,7 +12,7 @@ TotalSpellTimeExceedingThreshold( dates = NULL, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", ncores = NULL ) } @@ -52,7 +52,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{ncores}{An integer indicating the number of cores to use in parallel @@ -86,14 +86,14 @@ different behaviour consider to modify the 'data' input by substituting NA values by values exceeding the threshold. } \examples{ -data <- array(1:100, c(member = 5, sdate = 3, ftime = 214, lon = 2)) +data <- array(1:100, c(member = 5, sdate = 3, time = 214, lon = 2)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) threshold <- array(1:4, c(lat = 4)) total <- TotalSpellTimeExceedingThreshold(data, threshold, dates = Dates, diff --git a/man/TotalTimeExceedingThreshold.Rd b/man/TotalTimeExceedingThreshold.Rd index 4dc00d0..31f3161 100644 --- a/man/TotalTimeExceedingThreshold.Rd +++ b/man/TotalTimeExceedingThreshold.Rd @@ -11,7 +11,7 @@ TotalTimeExceedingThreshold( dates = NULL, start = NULL, end = NULL, - time_dim = "ftime", + time_dim = "time", na.rm = FALSE, ncores = NULL ) @@ -50,7 +50,7 @@ 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 \code{data}.} \item{time_dim}{A character string indicating the name of the dimension to -compute the indicator. By default, it is set to 'ftime'. It can only +compute the indicator. By default, it is set to 'time'. It can only indicate one time dimension.} \item{na.rm}{A logical value indicating whether to ignore NA values (TRUE) or @@ -88,14 +88,14 @@ indices for heat stress can be obtained by using this function: } \examples{ data <- array(rnorm(5 * 3 * 214 * 2)*23, - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) Dates <- c(seq(as.Date("01-05-2000", format = "\%d-\%m-\%Y"), as.Date("30-11-2000", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "\%d-\%m-\%Y"), as.Date("30-11-2001", format = "\%d-\%m-\%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "\%d-\%m-\%Y"), as.Date("30-11-2002", format = "\%d-\%m-\%Y"), by = 'day')) -dim(Dates) <- c(sdate = 3, ftime = 214) +dim(Dates) <- c(sdate = 3, time = 214) DOT <- TotalTimeExceedingThreshold(data, threshold = 23, dates = Dates, start = list(21, 4), end = list(21, 6)) diff --git a/tests/testthat/test-AbsToProbs.R b/tests/testthat/test-AbsToProbs.R index c2cdc9f..c5693df 100644 --- a/tests/testthat/test-AbsToProbs.R +++ b/tests/testthat/test-AbsToProbs.R @@ -2,7 +2,7 @@ # dat1 dat1 <- NULL dat1$data <- array(rnorm(5 * 2 * 61 * 1), - c(member = 5, sdate = 2, ftime = 61, lon = 1)) + c(member = 5, sdate = 2, time = 61, lon = 1)) Dates1 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-06-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), @@ -11,7 +11,7 @@ dat1$attrs$Dates <- Dates1 class(dat1) <- 's2dv_cube' # dat2 Dates2 <- Dates1 -dim(Dates2) <- c(ftime = 61, sdate = 2) +dim(Dates2) <- c(time = 61, sdate = 2) ############################################## test_that("1. Sanity checks", { @@ -53,7 +53,7 @@ test_that("1. Sanity checks", { expect_equal( dim(AbsToProbs(data = dat1$data, dates = Dates2, start = list(21, 4), end = list(21, 6))), - c(member = 5, sdate = 2, ftime = 52, lon = 1) + c(member = 5, sdate = 2, time = 52, lon = 1) ) expect_equal( AbsToProbs(1), diff --git a/tests/testthat/test-AccumulationExceedingThreshold.R b/tests/testthat/test-AccumulationExceedingThreshold.R index baa2c50..2b55776 100644 --- a/tests/testthat/test-AccumulationExceedingThreshold.R +++ b/tests/testthat/test-AccumulationExceedingThreshold.R @@ -6,32 +6,32 @@ library(CSTools) dat1 <- 1:20 # dat2 -dat2_1 <- array(1:40, c(x = 2, ftime = 20)) -thres2_1 <- array(10, dim = c(member = 1, ftime = 1)) -dat2_3 <- array(1:20, c(ftime = 5, sdate = 2, lat = 2)) -thres2_3 <- array(1:5, c(ftime = 5)) -dat2_4 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat2_1 <- array(1:40, c(x = 2, time = 20)) +thres2_1 <- array(10, dim = c(member = 1, time = 1)) +dat2_3 <- array(1:20, c(time = 5, sdate = 2, lat = 2)) +thres2_3 <- array(1:5, c(time = 5)) +dat2_4 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) thres2_4 <- array(1:2, c(lat = 2)) # dat3 -dat3_1 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) -dat3_2 <- array(1:40, c(x = 2, ftime = 20)) +dat3_1 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) +dat3_2 <- array(1:40, c(x = 2, time = 20)) # dat4 set.seed(1) -dat4 <- array(rnorm(60, 23), c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat4 <- array(rnorm(60, 23), c(time = 5, fyear = 3, sdate = 2, lat = 2)) set.seed(1) -thres4_1 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2, lat = 2)) +thres4_1 <- array(rnorm(20, 20), c(time = 5, sdate = 2, lat = 2)) set.seed(2) -thres4_2 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2, lat = 2)) +thres4_2 <- array(rnorm(20, 25), c(time = 5, sdate = 2, lat = 2)) set.seed(1) -thres4_3 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2)) +thres4_3 <- array(rnorm(20, 20), c(time = 5, sdate = 2)) set.seed(2) -thres4_4 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2)) +thres4_4 <- array(rnorm(20, 25), c(time = 5, sdate = 2)) set.seed(1) -thres4_5 <- array(rnorm(5, 20), c(ftime = 5)) +thres4_5 <- array(rnorm(5, 20), c(time = 5)) set.seed(2) -thres4_6 <- array(rnorm(5, 25), c(ftime = 5)) +thres4_6 <- array(rnorm(5, 25), c(time = 5)) set.seed(1) thres4_7 <- rnorm(5, 20) set.seed(2) @@ -144,19 +144,19 @@ test_that("2. Output checks", { 155 ) expect_equal( - AccumulationExceedingThreshold(dat2_1, 10, time_dim = 'ftime'), + AccumulationExceedingThreshold(dat2_1, 10, time_dim = 'time'), array(c(375, 390), c(x = 2)) ) expect_equal( - AccumulationExceedingThreshold(dat2_1, thres2_1, time_dim = 'ftime'), + AccumulationExceedingThreshold(dat2_1, thres2_1, time_dim = 'time'), array(c(375, 390), c(x = 2)) ) expect_equal( AccumulationExceedingThreshold(dat2_1, thres2_1, time_dim = 'x'), - array(c(rep(0,5), seq(23, 79, 4)), c(ftime = 20)) + array(c(rep(0,5), seq(23, 79, 4)), c(time = 20)) ) expect_equal( - AccumulationExceedingThreshold(dat2_1, 10, time_dim = 'ftime'), + AccumulationExceedingThreshold(dat2_1, 10, time_dim = 'time'), array(c(375, 390), c(x = 2)) ) # dimensions @@ -169,7 +169,7 @@ test_that("2. Output checks", { c(sdate = 2, lat = 2) ) expect_equal( - dim(AccumulationExceedingThreshold(dat2_4, thres2_4, time_dim = 'ftime')), + dim(AccumulationExceedingThreshold(dat2_4, thres2_4, time_dim = 'time')), c(fyear = 3, sdate = 2, lat = 2) ) @@ -191,11 +191,11 @@ test_that("3. Output checks", { array(c(rep(0,10),55,171), dim = c(fyear = 3, sdate = 2, lat = 2)) ) expect_equal( - AccumulationExceedingThreshold(dat3_2, c(46, 35), op = c("<", ">"), time_dim = 'ftime'), + AccumulationExceedingThreshold(dat3_2, c(46, 35), op = c("<", ">"), time_dim = 'time'), array(c(76, 114), c(x = 2)) ) expect_equal( - AccumulationExceedingThreshold(dat3_2, c(7,11), op = c('>=', '<='), time_dim = 'ftime'), + AccumulationExceedingThreshold(dat3_2, c(7,11), op = c('>=', '<='), time_dim = 'time'), array(c(27, 18), c(x = 2)) ) expect_equal( @@ -219,17 +219,17 @@ test_that("4. Output checks", { tolerance = 0.0001 ) expect_equal( - as.vector(AccumulationExceedingThreshold(dat4, list(thres4_3, thres4_4), c(">", "<="), time_dim = 'ftime'))[1:5], + as.vector(AccumulationExceedingThreshold(dat4, list(thres4_3, thres4_4), c(">", "<="), time_dim = 'time'))[1:5], c(91.05107, 115.67568, 69.89353, 117.29783, 115.40615), tolerance = 0.0001 ) expect_equal( - as.vector(AccumulationExceedingThreshold(dat4, list(thres4_6, thres4_5), op = c("<", ">="), time_dim = 'ftime'))[1:5], + as.vector(AccumulationExceedingThreshold(dat4, list(thres4_6, thres4_5), op = c("<", ">="), time_dim = 'time'))[1:5], c(91.05107, 115.67568, 69.89353, 117.29783, 94.39550), tolerance = 0.0001 ) expect_equal( - as.vector(AccumulationExceedingThreshold(dat4, list(thres4_7, thres4_8), op = c('>=', '<='), time_dim = 'ftime'))[4:10], + as.vector(AccumulationExceedingThreshold(dat4, list(thres4_7, thres4_8), op = c('>=', '<='), time_dim = 'time'))[4:10], c(117.29783, 94.39550, 113.25711, 90.85402, 91.89458, 115.14699, 116.19438), tolerance = 0.0001 ) @@ -249,7 +249,7 @@ test_that("5. Seasonal forecasts", { ) # GDD - exp <- array(NA, dim = c(member = 6, sdate = 3, ftime = 214, lat = 4, lon = 4)) + exp <- array(NA, dim = c(member = 6, sdate = 3, time = 214, lat = 4, lon = 4)) exp1 <- drop(CSTools::lonlat_prec$data) * 86400000 exp[, , 1:31, , ] <- exp1 + 10; exp[, , 32:62, , ] <- exp1 + 11 exp[, , 63:93, , ] <- exp1 + 12; exp[, , 94:124, , ] <- exp1 + 13 @@ -262,8 +262,8 @@ test_that("5. Seasonal forecasts", { as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) - dim(Dates) <- c(sdate = 3, ftime = 214) - GDD <- AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'ftime', + dim(Dates) <- c(sdate = 3, time = 214) + GDD <- AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'time', start = list(1, 4), end = list(31, 10), na.rm = TRUE) expect_equal( @@ -275,11 +275,11 @@ test_that("5. Seasonal forecasts", { c(member = 6, sdate = 3, lat = 4, lon = 4) ) expect_error( - AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, start = list(1, 4), end = list(31, 10), time_dim = 'time'), + AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, start = list(1, 4), end = list(31, 10), time_dim = 'ftime'), "Parameter 'time_dim' is not found in 'data' dimension." ) expect_equal( - !any(is.na(AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'ftime',start = list(1, 4), end = list(31, 10)))), + !any(is.na(AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'time',start = list(1, 4), end = list(31, 10)))), !any(is.na(c(1, 1))) ) diff --git a/tests/testthat/test-MergeRefToExp.R b/tests/testthat/test-MergeRefToExp.R index 57cd425..bce5827 100644 --- a/tests/testthat/test-MergeRefToExp.R +++ b/tests/testthat/test-MergeRefToExp.R @@ -5,18 +5,18 @@ dates_data1 <- c(seq(as.Date("11-07-1993", "%d-%m-%Y", tz = 'UTC'), as.Date("20-07-1993","%d-%m-%Y", tz = 'UTC'), "day"), seq(as.Date("11-07-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("20-07-1994","%d-%m-%Y", tz = 'UTC'), "day")) -dim(dates_data1) <- c(ftime = 10, sdate = 2) +dim(dates_data1) <- c(time = 10, sdate = 2) cube1 <- NULL -cube1$data <- array(1:(2*10*2), c(ftime = 10, sdate = 2, member = 2)) +cube1$data <- array(1:(2*10*2), c(time = 10, sdate = 2, member = 2)) cube1$attrs$Dates <- dates_data1 class(cube1) <- 's2dv_cube' ref_dates1 <- c(seq(as.Date("01-07-1993", "%d-%m-%Y", tz = 'UTC'), as.Date("10-07-1993","%d-%m-%Y", tz = 'UTC'), "day"), seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("10-07-1994","%d-%m-%Y", tz = 'UTC'), "day")) -dim(ref_dates1) <- c(ftime = 10, sdate = 2) +dim(ref_dates1) <- c(time = 10, sdate = 2) cube_ref <- NULL -cube_ref$data <- array(1001:1020, c(ftime = 10, sdate = 2)) +cube_ref$data <- array(1001:1020, c(time = 10, sdate = 2)) cube_ref$attrs$Dates <- ref_dates1 class(cube_ref) <- 's2dv_cube' start1 <- list(3, 7) @@ -25,13 +25,13 @@ start2 <- list(11, 7) end2 <- list(15, 7) # dat1 -ref1 <- array(1001:1020, c(ftime = 10, sdate = 2, member = 1)) -data1 <- array(1:40, c(ftime = 10, sdate = 2, member = 2)) +ref1 <- array(1001:1020, c(time = 10, sdate = 2, member = 1)) +data1 <- array(1:40, c(time = 10, sdate = 2, member = 2)) # dat2 -ref2 <- array(1001:1015, c(ftime = 5, sdate = 1, member = 3)) -data2 <- array(1:6, c(ftime = 3, sdate = 1, member = 2)) +ref2 <- array(1001:1015, c(time = 5, sdate = 1, member = 3)) +data2 <- array(1:6, c(time = 3, sdate = 1, member = 2)) ########################################################################### test_that("1. Input checks", { @@ -59,7 +59,7 @@ test_that("1. Input checks", { "Parameter 'time_dim' must be a character string." ) expect_error( - MergeRefToExp(data1 = ref1, data2 = data1, time_dim = 'time'), + MergeRefToExp(data1 = ref1, data2 = data1, time_dim = 'ftime'), paste0("Parameter 'time_dim' is not found in 'data1' or 'data2' dimension ", "names.") ) @@ -69,29 +69,29 @@ test_that("1. Input checks", { "Parameter 'memb_dim' must be a character string." ) expect_error( - MergeRefToExp(data1 = ref1, data2 = data1, memb_dim = 'time'), + MergeRefToExp(data1 = ref1, data2 = data1, memb_dim = 'ensemble'), paste0("Parameter 'memb_dim' is not found in 'data1' or 'data2' dimension. ", "Set it to NULL if there is no member dimension.") ) # common dimensions expect_error( - MergeRefToExp(data1 = array(1:12, c(sdate = 2, ftime = 2, dat = 3)), - data2 = array(1:16, c(sdate = 2, ftime = 2, var = 4)), + MergeRefToExp(data1 = array(1:12, c(sdate = 2, time = 2, dat = 3)), + data2 = array(1:16, c(sdate = 2, time = 2, var = 4)), memb_dim = NULL), paste0("Parameter 'data1' and 'data2' must have same length of ", "all dimensions except 'memb_dim'.") ) expect_error( - MergeRefToExp(data1 = array(1:12, c(sdate = 2, ftime = 2, dat = 1)), - data2 = array(1:16, c(sdate = 2, ftime = 2)), + MergeRefToExp(data1 = array(1:12, c(sdate = 2, time = 2, dat = 1)), + data2 = array(1:16, c(sdate = 2, time = 2)), memb_dim = NULL), paste0("Parameter 'data1' and 'data2' must have same length of ", "all dimensions except 'memb_dim'.") ) # dates expect_warning( - MergeRefToExp(data1 = array(1:4, c(sdate = 2, ftime = 2, lat = 1)), - data2 = array(1:16, c(sdate = 2, ftime = 2, lat = 1)), + MergeRefToExp(data1 = array(1:4, c(sdate = 2, time = 2, lat = 1)), + data2 = array(1:16, c(sdate = 2, time = 2, lat = 1)), memb_dim = NULL, start1 = list(1, 1), end1 = list(3, 1), start2 = NULL, end2 = NULL), paste0("Parameter 'dates' is NULL and the average of the ", @@ -134,7 +134,7 @@ test_that("2. Output checks: CST_MergeRefToExp", { ) # Dates expect_equal( - dim(res1$data)[c('ftime', 'sdate')], + dim(res1$data)[c('time', 'sdate')], dim(res1$attrs$Dates) ) # data @@ -149,28 +149,28 @@ test_that("2. Output checks: CST_MergeRefToExp", { test_that("3. Output checks: MergeRefToExp", { # Minimum dimensions expect_equal( - MergeRefToExp(data1 = array(1:2, c(ftime = 2)), - data2 = array(1, c(ftime = 1)), memb_dim = NULL), - array(c(1,2,1), dim = c(ftime = 3)) + MergeRefToExp(data1 = array(1:2, c(time = 2)), + data2 = array(1, c(time = 1)), memb_dim = NULL), + array(c(1,2,1), dim = c(time = 3)) ) # res2 res2 <- MergeRefToExp(data1 = ref1, data2 = data1) ## dims expect_equal( dim(res2), - c(ftime = 20, sdate = 2, member = 2) + c(time = 20, sdate = 2, member = 2) ) ## data expect_equal( res2[,1,], - array(c(1001:1010, 1:10, 1001:1010, 21:30), dim = c(ftime = 20, member = 2)) + array(c(1001:1010, 1:10, 1001:1010, 21:30), dim = c(time = 20, member = 2)) ) # res3: multiple different members res3 <- MergeRefToExp(data1 = ref2, data2 = data2) ## dims expect_equal( dim(res3), - c(ftime = 8, sdate = 1, member = 6) + c(time = 8, sdate = 1, member = 6) ) expect_equal( as.vector(res3[1:5, 1, ]), @@ -190,16 +190,16 @@ test_that("3. Output checks: Dates", { seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day")) - dim(data_dates) <- c(ftime = 154, sdate = 2) + dim(data_dates) <- c(time = 154, sdate = 2) ref_dates <- seq(as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'), as.Date("01-12-1994", "%d-%m-%Y", tz = 'UTC'), "day") - dim(ref_dates) <- c(ftime = 350, sdate = 2) + dim(ref_dates) <- c(time = 350, sdate = 2) ref <- NULL - ref$data <- array(1001:1700, c(ftime = 350, sdate = 2)) + ref$data <- array(1001:1700, c(time = 350, sdate = 2)) ref$attrs$Dates <- ref_dates class(ref) <- 's2dv_cube' data <- NULL - data$data <- array(1:(2 * 154 * 2), c(ftime = 154, sdate = 2, member= 2)) + data$data <- array(1:(2 * 154 * 2), c(time = 154, sdate = 2, member= 2)) data$attrs$Dates <- data_dates class(data) <- 's2dv_cube' @@ -211,7 +211,7 @@ test_that("3. Output checks: Dates", { ) output <- array(c(1172:1181, 1:83, 1537:1546, 155:237, 1172:1181, 309:391, - 1537:1546, 463:545), c(ftime = 93, sdate = 2, member = 2)) + 1537:1546, 463:545), c(time = 93, sdate = 2, member = 2)) expect_equal( CST_MergeRefToExp(data1 = ref, data2 = data, start1 = list(21, 6), @@ -227,16 +227,16 @@ test_that("3. Output checks: Dates", { as.Date("01-06-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("01-07-1994","%d-%m-%Y", tz = 'UTC')) - dim(data_dates) <- c(ftime = 2, sdate = 2) + dim(data_dates) <- c(time = 2, sdate = 2) ref_dates <- c(as.Date("01-05-1993", "%d-%m-%Y", tz = 'UTC'), as.Date("01-05-1994", "%d-%m-%Y", tz = 'UTC')) - dim(ref_dates) <- c(ftime = 1, sdate = 2) + dim(ref_dates) <- c(time = 1, sdate = 2) ref <- NULL - ref$data <- array(1:2, c(ftime = 1, sdate = 2)) + ref$data <- array(1:2, c(time = 1, sdate = 2)) ref$attrs$Dates <- ref_dates class(ref) <- 's2dv_cube' data <- NULL - data$data <- array(1:(2 * 3 * 2), c(ftime = 2, sdate = 2, member = 3)) + data$data <- array(1:(2 * 3 * 2), c(time = 2, sdate = 2, member = 3)) data$attrs$Dates <- data_dates class(data) <- 's2dv_cube' @@ -246,7 +246,7 @@ test_that("3. Output checks: Dates", { as.Date("01-05-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("01-06-1994", "%d-%m-%Y", tz = 'UTC'), as.Date("01-07-1994","%d-%m-%Y", tz = 'UTC')) - dim(res_dates) <- c(ftime = 3, sdate = 2) + dim(res_dates) <- c(time = 3, sdate = 2) expect_equal( CST_MergeRefToExp(data1 = ref, data2 = data, start1 = list(1, 5), @@ -257,7 +257,7 @@ test_that("3. Output checks: Dates", { output <- abind::abind(t(matrix(rep(1:2, 3), ncol = 2, nrow = 3, byrow = T)), data$data, along = 1) - names(dim(output)) <- c('ftime', 'sdate', 'member') + names(dim(output)) <- c('time', 'sdate', 'member') expect_equal( CST_MergeRefToExp(data1 = ref, data2 = data, start1 = list(1, 5), @@ -280,15 +280,15 @@ test_that("4. Test Seasonal", { tz = 'UTC'), "day"), "%Y-%m-%d")) } dates <- as.Date(dates, tz = 'UTC') - dim.dates <- c(ftime = 215, sweek = 1, sday = 1, + dim.dates <- c(time = 215, sweek = 1, sday = 1, sdate = (hcst.endyear - hcst.inityear) + 1) dim(dates) <- dim.dates ref <- NULL - ref$data <- array(1:(215*25), c(ftime = 215, sdate = 25)) + ref$data <- array(1:(215*25), c(time = 215, sdate = 25)) ref$attrs$Dates <- dates class(ref) <- 's2dv_cube' data <- NULL - data$data <- array(1:(215*25*3), c(ftime = 215, sdate = 25, member=3)) + data$data <- array(1:(215*25*3), c(time = 215, sdate = 25, member=3)) data$attrs$Dates <- dates class(data) <- 's2dv_cube' diff --git a/tests/testthat/test-PeriodAccumulation.R b/tests/testthat/test-PeriodAccumulation.R index 6898a93..441b021 100644 --- a/tests/testthat/test-PeriodAccumulation.R +++ b/tests/testthat/test-PeriodAccumulation.R @@ -27,14 +27,14 @@ test_that("1. Sanity Checks", { PeriodAccumulation(1:10), 55 ) - data <- array(1:24, c(sdate = 2, ftime = 3, lon = 4)) + data <- array(1:24, c(sdate = 2, time = 3, lon = 4)) expect_equal( PeriodAccumulation(data), array(c(9, 12, 27, 30, 45, 48, 63, 66), c(sdate = 2, lon = 4)) ) # Test dates warning expect_warning( - PeriodAccumulation(array(1:10, c(ftime = 10)), + PeriodAccumulation(array(1:10, c(time = 10)), dates = seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("10-05-2000", format = "%d-%m-%Y"), by = 'day'), start = list(05, 02), end = list(05, 09)), @@ -43,7 +43,7 @@ test_that("1. Sanity Checks", { ) # start and end when dates is not provided expect_warning( - PeriodAccumulation(array(1:10, c(ftime = 10)), + PeriodAccumulation(array(1:10, c(time = 10)), start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -55,7 +55,7 @@ test_that("1. Sanity Checks", { test_that("2. Seasonal", { exp <- NULL exp$data <- array(1:(1 * 3 * 214 * 2), - c(memb = 1, sdate = 3, ftime = 214, lon = 2)) + c(memb = 1, sdate = 3, time = 214, lon = 2)) exp$dims <- dim(exp$data) exp$attrs$Dates <- c(seq(as.Date("01-04-2000", format = "%d-%m-%Y"), as.Date("31-10-2000", format = "%d-%m-%Y"), by = 'day'), @@ -63,7 +63,7 @@ test_that("2. Seasonal", { as.Date("31-10-2001", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-04-2002", format = "%d-%m-%Y"), as.Date("31-10-2002", format = "%d-%m-%Y"), by = 'day')) - dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) + dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) class(exp) <- 's2dv_cube' output <- exp output$data <- array(c(sum(exp$data[1,1,21:82,1]), sum(exp$data[1,2,21:82,1]), @@ -132,4 +132,4 @@ test_that("3. Subset Dates and check time_bounds", { all(lubridate::day(res$attrs$time_bounds$end) == 20), TRUE ) -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-PeriodMax.R b/tests/testthat/test-PeriodMax.R index 97907e6..1d7437a 100644 --- a/tests/testthat/test-PeriodMax.R +++ b/tests/testthat/test-PeriodMax.R @@ -17,7 +17,7 @@ test_that("1. Sanity Checks", { "Parameter 'time_dim' must be a character string." ) expect_error( - PeriodMax(array(1:10, dim = c(ftime = 10)), time_dim = 'time'), + PeriodMax(array(1:10, dim = c(time = 10)), time_dim = 'ftime'), "Parameter 'time_dim' is not found in 'data' dimension." ) suppressWarnings( diff --git a/tests/testthat/test-PeriodMean.R b/tests/testthat/test-PeriodMean.R index f51f7a1..9f8c4cf 100644 --- a/tests/testthat/test-PeriodMean.R +++ b/tests/testthat/test-PeriodMean.R @@ -23,7 +23,7 @@ test_that("1. Sanity Checks", { "Parameter 'time_dim' must be a character string." ) expect_error( - PeriodMean(array(1:10, dim = c(ftime = 10)), time_dim = 'time'), + PeriodMean(array(1:10, dim = c(time = 10)), time_dim = 'ftime'), "Parameter 'time_dim' is not found in 'data' dimension." ) expect_error( diff --git a/tests/testthat/test-PeriodMin.R b/tests/testthat/test-PeriodMin.R index 5ed6c1f..fb97fc2 100644 --- a/tests/testthat/test-PeriodMin.R +++ b/tests/testthat/test-PeriodMin.R @@ -23,7 +23,7 @@ test_that("1. Sanity Checks", { "Parameter 'time_dim' must be a character string." ) expect_error( - PeriodMin(array(1:10, dim = c(ftime = 10)), time_dim = 'time'), + PeriodMin(array(1:10, dim = c(time = 10)), time_dim = 'ftime'), "Parameter 'time_dim' is not found in 'data' dimension." ) expect_error( diff --git a/tests/testthat/test-PeriodVariance.R b/tests/testthat/test-PeriodVariance.R index e525644..e1de032 100644 --- a/tests/testthat/test-PeriodVariance.R +++ b/tests/testthat/test-PeriodVariance.R @@ -21,7 +21,7 @@ test_that("1. Sanity Checks", { "Parameter 'time_dim' must be a character string." ) expect_error( - PeriodVariance(array(1:10, dim = c(ftime = 10)), time_dim = 'time'), + PeriodVariance(array(1:10, dim = c(time = 10)), time_dim = 'ftime'), "Parameter 'time_dim' is not found in 'data' dimension." ) expect_error( @@ -62,7 +62,7 @@ test_that("1. Sanity Checks", { test_that("2. Seasonal", { exp <- NULL exp$data <- array(1:(1 * 3 * 214 * 2), - c(memb = 1, sdate = 3, ftime = 214, lon = 2)) + c(memb = 1, sdate = 3, time = 214, lon = 2)) exp$dims <- dim(exp$data) exp$attrs$Dates <- c(seq(as.Date("01-04-2000", format = "%d-%m-%Y"), as.Date("31-10-2000", format = "%d-%m-%Y"), by = 'day'), @@ -70,7 +70,7 @@ test_that("2. Seasonal", { as.Date("31-10-2001", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-04-2002", format = "%d-%m-%Y"), as.Date("31-10-2002", format = "%d-%m-%Y"), by = 'day')) - dim(exp$attrs$Dates) <- c(ftime = 214, sdate = 3) + dim(exp$attrs$Dates) <- c(time = 214, sdate = 3) class(exp) <- 's2dv_cube' output <- exp output$data <- array(c(var(exp$data[1,1,21:82,1]), var(exp$data[1,2,21:82,1]), diff --git a/tests/testthat/test-QThreshold.R b/tests/testthat/test-QThreshold.R index 57883b1..4d7fc59 100644 --- a/tests/testthat/test-QThreshold.R +++ b/tests/testthat/test-QThreshold.R @@ -4,15 +4,15 @@ library(CSTools) # dat1 threshold <- 26 dat1 <- array(abs(rnorm(5 * 3 * 214 * 2)*50), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), - as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), - seq(as.Date("01-05-2001", format = "%d-%m-%Y"), - as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), - seq(as.Date("01-05-2002", format = "%d-%m-%Y"), - as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) + as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), + seq(as.Date("01-05-2001", format = "%d-%m-%Y"), + as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'), + seq(as.Date("01-05-2002", format = "%d-%m-%Y"), + as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) dates1 <- dates0 -dim(dates1) <- c(sdate = 3, ftime = 214) +dim(dates1) <- c(sdate = 3, time = 214) ############################################## test_that("1. Sanity checks", { @@ -56,23 +56,23 @@ test_that("1. Sanity checks", { dim(QThreshold(data, threshold)), c(sdate = 20, x = 2) ) - data <- array(1:40, c(x = 2, ftime = 20)) + data <- array(1:40, c(x = 2, time = 20)) expect_error( QThreshold(data, threshold), "Could not find dimension 'sdate' in 1th object provided in 'data'." ) expect_equal( - dim(QThreshold(data, threshold, sdate_dim = 'ftime')), - c(ftime = 20, x = 2) + dim(QThreshold(data, threshold, sdate_dim = 'time')), + c(time = 20, x = 2) ) - dim(threshold) <- c(member = 1, ftime = 1) + dim(threshold) <- c(member = 1, time = 1) expect_equal( - dim(QThreshold(data, threshold, sdate_dim = 'ftime')), - c(ftime = 20, x = 2) + dim(QThreshold(data, threshold, sdate_dim = 'time')), + c(time = 20, x = 2) ) expect_equal( - dim(QThreshold(data, threshold, memb_dim = 'x', sdate_dim = 'ftime')), - c(ftime = 20, x = 2) + dim(QThreshold(data, threshold, memb_dim = 'x', sdate_dim = 'time')), + c(time = 20, x = 2) ) expect_error( QThreshold(data, threshold, sdate_dim = 'x', ncores = 'Z'), @@ -104,21 +104,21 @@ test_that("1. Sanity checks", { # test different common dimensions - exp <- array(1:61, dim = c(ftime = 61, sdate = 3)) - threshold <- array(1:61, dim = c(ftime = 61)) + exp <- array(1:61, dim = c(time = 61, sdate = 3)) + threshold <- array(1:61, dim = c(time = 61)) Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-06-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), as.Date("30-06-2001", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-06-2002", format = "%d-%m-%Y"), by = 'day')) - dim(Dates) <- c(ftime = 61, sdate = 3, syear = 1) + dim(Dates) <- c(time = 61, sdate = 3, syear = 1) res <- QThreshold(data = exp, dates = Dates, start = list(21, 4), end = list(21, 6), threshold = threshold, - time_dim = 'ftime', sdate_dim = 'sdate') + time_dim = 'time', sdate_dim = 'sdate') expect_equal( dim(res), - c(sdate = 3, ftime = 52) + c(sdate = 3, time = 52) ) # test start and end expect_warning( @@ -130,11 +130,11 @@ test_that("1. Sanity checks", { expect_equal( dim(QThreshold(dat1, threshold = 26, dates = dates1, start = list(21, 4), end = list(21, 6))), - c(sdate = 3, member = 5, ftime = 52, lon = 2) + c(sdate = 3, member = 5, time = 52, lon = 2) ) # start and end when dates is not provided expect_warning( - QThreshold(array(1:61, dim = c(ftime = 61, sdate = 3)), threshold = 25, + QThreshold(array(1:61, dim = c(time = 61, sdate = 3)), threshold = 25, start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -164,7 +164,7 @@ test_that("2. Seasonal forecasts", { obs1_percentile <- QThreshold(obs1, threshold = 35), "'x' must have 1 or more non-missing values" ) - obs2 <- obs[,,,2,,] # one ftime + obs2 <- obs[,,,2,,] # one time obs2_percentile <- QThreshold(obs2, threshold = 35) expect_equal( dim(obs2), diff --git a/tests/testthat/test-SelectPeriod.R b/tests/testthat/test-SelectPeriod.R index deb8656..93fc6eb 100644 --- a/tests/testthat/test-SelectPeriod.R +++ b/tests/testthat/test-SelectPeriod.R @@ -42,19 +42,19 @@ test_that("2. Output checks", { ) # test different common dimensions - exp <- array(1:61, dim = c(ftime = 61)) + exp <- array(1:61, dim = c(time = 61)) Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-06-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), as.Date("30-06-2001", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-06-2002", format = "%d-%m-%Y"), by = 'day')) - dim(Dates) <- c(ftime = 61, sdate = 3) + dim(Dates) <- c(time = 61, sdate = 3) res <- SelectPeriodOnData(data = exp, dates = Dates, start = list(21, 4), end = list(21, 6)) expect_equal( dim(res), - c(ftime = 52) + c(time = 52) ) }) @@ -65,7 +65,7 @@ test_that("3. Decadal", { # decadal: 1 sdate several consequtive years: dates <- seq(as.Date("01-01-2000", "%d-%m-%Y", tz = 'UTC'), as.Date("31-12-2005","%d-%m-%Y", tz = 'UTC'), "day") - dim(dates) <- c(ftime = length(dates)) + dim(dates) <- c(time = length(dates)) # No dims -> test .position output <- c( seq(as.Date("2000-02-01", "%Y-%m-%d"), as.Date("2000-02-10", "%Y-%m-%d"), 'day'), @@ -74,20 +74,20 @@ test_that("3. Decadal", { seq(as.Date("2003-02-01", "%Y-%m-%d"), as.Date("2003-02-10", "%Y-%m-%d"), 'day'), seq(as.Date("2004-02-01", "%Y-%m-%d"), as.Date("2004-02-10", "%Y-%m-%d"), 'day'), seq(as.Date("2005-02-01", "%Y-%m-%d"), as.Date("2005-02-10", "%Y-%m-%d"), 'day')) - dim(output) <- c(ftime = 60) + dim(output) <- c(time = 60) expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 2)), output ) data <- array(1:(length(dates)*3), - c(memb = 1, ftime = length(dates), lon = 3)) + c(memb = 1, time = length(dates), lon = 3)) expect_equal( SelectPeriodOnData(data, dates, start = list(1, 2), end = list(10, 2)), array(c(c(32:41, 398:407, 763:772, 1128:1137, 1493:1502, 1859:1868), c(32:41, 398:407, 763:772, 1128:1137, 1493:1502, 1859:1868) + 2192, c(32:41, 398:407, 763:772, 1128:1137, 1493:1502, 1859:1868) + 2 * 2192), - c(memb = 1, ftime = 60, lon = 3)) + c(memb = 1, time = 60, lon = 3)) ) output2 <- c( @@ -97,7 +97,7 @@ test_that("3. Decadal", { seq(as.Date("2003-02-01", "%Y-%m-%d"), as.Date("2003-04-10", "%Y-%m-%d"), 'day'), seq(as.Date("2004-02-01", "%Y-%m-%d"), as.Date("2004-04-10", "%Y-%m-%d"), 'day'), seq(as.Date("2005-02-01", "%Y-%m-%d"), as.Date("2005-04-10", "%Y-%m-%d"), 'day')) - dim(output2) <- c(ftime = 416) + dim(output2) <- c(time = 416) expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 4)), output2 @@ -108,11 +108,11 @@ test_that("3. Decadal", { array(c(c(32:101, 398:466, 763:831, 1128:1196, 1493:1562, 1859:1927), c(32:101, 398:466, 763:831, 1128:1196, 1493:1562, 1859:1927) + 2192, c(32:101, 398:466, 763:831, 1128:1196, 1493:1562, 1859:1927) + 2 * 2192), - c(memb = 1, ftime = 416, lon = 3)) + c(memb = 1, time = 416, lon = 3)) ) # 1 dim -> test Apply - dim(dates) <- c(ftime = length(dates)) + dim(dates) <- c(time = length(dates)) expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 2)), output @@ -125,50 +125,50 @@ test_that("3. Decadal", { # decadal: 5 sdates several consequtive years dates <- rep(seq(as.Date("01-01-2000", "%d-%m-%Y", tz = 'UTC'), as.Date("31-12-2005","%d-%m-%Y", tz = 'UTC'), "day"), 5) - dim(dates) <- c(ftime = 2192, sdate = 5) + dim(dates) <- c(time = 2192, sdate = 5) output3 <- rep(output, 5) - dim(output3) <- c(ftime = 60, sdate = 5) + dim(output3) <- c(time = 60, sdate = 5) expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 2)), output3) data <- array(1:(length(dates)*3), - c(memb = 1, sdate = 5, ftime = length(dates)/5, lon = 3)) + c(memb = 1, sdate = 5, time = length(dates)/5, lon = 3)) expect_equal( #To be extended for all sdate dimensions: SelectPeriodOnData(data, dates, start = list(1, 2), end = list(10, 2))[1,1, ,1], c(1:10 * 5 + 151, 1:10 * 5 + 1981, 1:10 * 5 + 3806, 1:10 * 5 + 5631, 1:10 * 5 + 7456, 1:10 * 5 + 9286) ) output4 <- rep(output2, 5) - dim(output4) <- c(ftime = 416, sdate = 5) + dim(output4) <- c(time = 416, sdate = 5) expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 4)), output4 ) - expect_equal( #To be extended for all ftime dimensions: + expect_equal( #To be extended for all time dimensions: SelectPeriodOnData(data, dates, start = list(1, 2), end = list(10, 4))[1, ,1,1], 156:160 ) - # Multiple dims: sdate, fyear, ftime + # Multiple dims: sdate, fyear, time dates <- CSTools::SplitDim(dates, indices = dates[,1], - split_dim = 'ftime', freq = 'year') + split_dim = 'time', freq = 'year') dates <- as.POSIXct(dates * 24 * 3600, origin = '1970-01-01', tz = 'UTC') - output5 <- CSTools::SplitDim(output3, indices = output3[,1], split_dim = 'ftime' , freq = 'year') + output5 <- CSTools::SplitDim(output3, indices = output3[,1], split_dim = 'time' , freq = 'year') output5 <- as.POSIXct(output5 * 24 * 3600, origin = '1970-01-01', tz = 'UTC') expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 2)), output5 ) data <- array(1:(366*6*5*3), - c(memb = 1, sdate = 5, year = 6, ftime = 366, lon = 3)) + c(memb = 1, sdate = 5, year = 6, time = 366, lon = 3)) expect_equal( SelectPeriodOnData(data, dates, start = list(1, 2), end = list(10, 2)), - InsertDim(Reorder(data[, , , 32:41, ], c('sdate', 'year', 'ftime', 'lon')), + InsertDim(Reorder(data[, , , 32:41, ], c('sdate', 'year', 'time', 'lon')), len = 1, pos = 1, name = 'memb') ) - output6 <- CSTools::SplitDim(output4, indices = output4[,1], split_dim = 'ftime' , freq = 'year') + output6 <- CSTools::SplitDim(output4, indices = output4[,1], split_dim = 'time' , freq = 'year') output6 <- as.POSIXct(output6 * 24 * 3600, origin = '1970-01-01', tz = 'UTC') expect_equal( SelectPeriodOnDates(dates, start = list(1, 2), end = list(10, 4)), @@ -177,13 +177,13 @@ test_that("3. Decadal", { # expect_equal( # to be fixed: # SelectPeriodOnData(data, dates, start = list(1, 2), end = list(10, 4)), # (931:935), outer(seq(931, 3001, 30), 0:4, '+') - # InsertDim(Reorder(data[,,,32:41,], c('ftime', 'sdate', 'year', 'lon')), + # InsertDim(Reorder(data[,,,32:41,], c('time', 'sdate', 'year', 'lon')), # len = 1, pos = 2, name = 'memb')) }) ############################################## test_that("4. Seasonal", { - # 1 start month, select the required 'ftime' of each 'sdate' in-between the entire timeseries + # 1 start month, select the required 'time' of each 'sdate' in-between the entire timeseries dates <- c(seq(as.Date("01-04-2000", format = "%d-%m-%Y"), as.Date("31-10-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-04-2001", format = "%d-%m-%Y"), @@ -192,7 +192,7 @@ test_that("4. Seasonal", { as.Date("31-10-2002", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-04-2003", format = "%d-%m-%Y"), as.Date("31-10-2003", format = "%d-%m-%Y"), by = 'day')) - dim(dates) <- c(ftime = 214, sdate = 4) + dim(dates) <- c(time = 214, sdate = 4) output <- c(seq(as.Date("21-04-2000", format = "%d-%m-%Y"), as.Date("21-06-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("21-04-2001", format = "%d-%m-%Y"), @@ -201,7 +201,7 @@ test_that("4. Seasonal", { as.Date("21-06-2002", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("21-04-2003", format = "%d-%m-%Y"), as.Date("21-06-2003", format = "%d-%m-%Y"), by = 'day')) - dim(output) <- c(ftime = 62, sdate = 4) + dim(output) <- c(time = 62, sdate = 4) expect_equal( SelectPeriodOnDates(dates, start = list(21, 4), end = list(21, 6)), output @@ -209,8 +209,8 @@ test_that("4. Seasonal", { # following the above case, and select the data data <- array(1:(5 * 4 * 214 * 2), - c(memb = 5, sdate = 4, ftime = 214, lon = 2)) - dim(dates) <- c(ftime = 214, sdate = 4) + c(memb = 5, sdate = 4, time = 214, lon = 2)) + dim(dates) <- c(time = 214, sdate = 4) expect_equal( SelectPeriodOnData(data, dates, start = list(21, 4), end = list(21, 6))[1,1, ,1], @@ -220,7 +220,7 @@ test_that("4. Seasonal", { # when selecting the days across two years dates <- seq(as.Date("2000-01-01", "%Y-%m-%d"), as.Date("2003-12-31", "%Y-%m-%d"), 'day') - dim(dates) <- c(ftime = 1461) + dim(dates) <- c(time = 1461) output1 <- c(seq(as.Date("01-01-2000", format = "%d-%m-%Y"), as.Date("31-01-2000", format = "%d-%m-%Y"), by = 'day'), @@ -232,7 +232,7 @@ test_that("4. Seasonal", { as.Date("31-01-2003", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-12-2003", format = "%d-%m-%Y"), as.Date("31-12-2003", format = "%d-%m-%Y"), by = 'day')) - dim(output1) <- c(ftime = 31 * 8) + dim(output1) <- c(time = 31 * 8) expect_equal( SelectPeriodOnDates(dates, start = list(1, 12), end = list(31, 1)), @@ -241,12 +241,12 @@ test_that("4. Seasonal", { # following the above case, and select the data data1 <- array(1:(length(dates) * 2), - c(memb = 1, ftime = length(dates), lon = 2)) + c(memb = 1, time = length(dates), lon = 2)) expect_equal( SelectPeriodOnData(data1, dates, start = list(1, 12), end = list(31, 1)), array(c(c(1:31, 336:397, 701:762, 1066:1127, 1431:1461), c(1:31, 336:397, 701:762, 1066:1127, 1431:1461) + 1461), - c(memb = 1, ftime = 31 * 8, lon = 2)) + c(memb = 1, time = 31 * 8, lon = 2)) ) }) diff --git a/tests/testthat/test-Threshold.R b/tests/testthat/test-Threshold.R index 7cb83cf..677c21e 100644 --- a/tests/testthat/test-Threshold.R +++ b/tests/testthat/test-Threshold.R @@ -4,7 +4,7 @@ library(CSTools) # dat1 threshold <- 0.9 dat1 <- array(abs(rnorm(5 * 3 * 214 * 2)*50), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), @@ -12,7 +12,7 @@ dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) dates1 <- dates0 -dim(dates1) <- c(sdate = 3, ftime = 214) +dim(dates1) <- c(sdate = 3, time = 214) ############################################## test_that("1. Sanity checks", { @@ -57,23 +57,23 @@ test_that("1. Sanity checks", { Threshold(data, threshold, memb_dim = NULL), array(c(2.8, 4.6, 3.8, 5.6), c(probs = 2, lat = 2)) ) - data <- array(1:40, c(x = 2, ftime = 20)) + data <- array(1:40, c(x = 2, time = 20)) expect_error( Threshold(data, threshold), "Could not find dimension 'sdate' in 1th object provided in 'data'." ) expect_equal( - dim(Threshold(data, threshold, sdate_dim = 'ftime', memb_dim = NULL)), + dim(Threshold(data, threshold, sdate_dim = 'time', memb_dim = NULL)), c(probs = 2, x = 2) ) # threshold with dimensions ? - dim(threshold) <- c(member = 2, ftime = 1) + dim(threshold) <- c(member = 2, time = 1) expect_equal( - dim(Threshold(data, threshold, sdate_dim = 'ftime', memb_dim = NULL)), + dim(Threshold(data, threshold, sdate_dim = 'time', memb_dim = NULL)), c(probs = 2, x = 2) ) expect_equal( - dim(Threshold(data, threshold, memb_dim = 'x', sdate_dim = 'ftime')), + dim(Threshold(data, threshold, memb_dim = 'x', sdate_dim = 'time')), c(probs = 2) ) # test start and end @@ -86,11 +86,11 @@ test_that("1. Sanity checks", { expect_equal( dim(Threshold(dat1, threshold = 0.8, dates = dates1, start = list(21, 4), end = list(21, 6))), - c(ftime = 52, lon = 2) + c(time = 52, lon = 2) ) # start and end when dates is not provided expect_warning( - Threshold(array(1:366, dim = c(ftime = 61, sdate = 3, member = 2)), + Threshold(array(1:366, dim = c(time = 61, sdate = 3, member = 2)), threshold = 0.8, start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") diff --git a/tests/testthat/test-TotalSpellTimeExceedingThreshold.R b/tests/testthat/test-TotalSpellTimeExceedingThreshold.R index b66c5ae..e65ec1e 100644 --- a/tests/testthat/test-TotalSpellTimeExceedingThreshold.R +++ b/tests/testthat/test-TotalSpellTimeExceedingThreshold.R @@ -5,36 +5,36 @@ dat <- array(1:20, dim = c(2, 10)) thres <- 10 dat1 <- array(1:20, dim = c(time = 2, lat = 10)) thres1 <- array(1:2, dim = c(time = 2)) -dat1_2 <- array(1:40, c(x = 2, ftime = 20)) -threshold1_2 <- array(rep(10, 20), dim = c(member = 1, ftime = 20)) +dat1_2 <- array(1:40, c(x = 2, time = 20)) +threshold1_2 <- array(rep(10, 20), dim = c(member = 1, time = 20)) # dat2 -dat2_1 <- array(1:40, c(x = 2, ftime = 20)) -thres2_1 <- array(10, dim = c(member = 1, ftime = 1)) -dat2_3 <- array(1:20, c(ftime = 5, sdate = 2, lat = 2)) -thres2_3 <- array(1:5, c(ftime = 5)) -dat2_4 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat2_1 <- array(1:40, c(x = 2, time = 20)) +thres2_1 <- array(10, dim = c(member = 1, time = 1)) +dat2_3 <- array(1:20, c(time = 5, sdate = 2, lat = 2)) +thres2_3 <- array(1:5, c(time = 5)) +dat2_4 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) thres2_4 <- array(1:2, c(lat = 2)) # dat3 -dat3_1 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) -dat3_2 <- array(1:40, c(x = 2, ftime = 20)) +dat3_1 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) +dat3_2 <- array(1:40, c(x = 2, time = 20)) # dat4 set.seed(1) -dat4 <- array(rnorm(60, 23), c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat4 <- array(rnorm(60, 23), c(time = 5, fyear = 3, sdate = 2, lat = 2)) set.seed(1) -thres4_1 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2, lat = 2)) +thres4_1 <- array(rnorm(20, 20), c(time = 5, sdate = 2, lat = 2)) set.seed(2) -thres4_2 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2, lat = 2)) +thres4_2 <- array(rnorm(20, 25), c(time = 5, sdate = 2, lat = 2)) set.seed(1) -thres4_3 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2)) +thres4_3 <- array(rnorm(20, 20), c(time = 5, sdate = 2)) set.seed(2) -thres4_4 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2)) +thres4_4 <- array(rnorm(20, 25), c(time = 5, sdate = 2)) set.seed(1) -thres4_5 <- array(rnorm(5, 20), c(ftime = 5)) +thres4_5 <- array(rnorm(5, 20), c(time = 5)) set.seed(2) -thres4_6 <- array(rnorm(5, 25), c(ftime = 5)) +thres4_6 <- array(rnorm(5, 25), c(time = 5)) set.seed(1) thres4_7 <- rnorm(5, 20) set.seed(2) @@ -144,7 +144,7 @@ test_that("1. Sanity checks", { ) # start and end when dates is not provided expect_warning( - TotalSpellTimeExceedingThreshold(array(1:10, c(ftime = 10)), threshold = 5, spell = 2, + TotalSpellTimeExceedingThreshold(array(1:10, c(time = 10)), threshold = 5, spell = 2, start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -172,7 +172,7 @@ test_that("2. Output checks", { ) expect_equal( TotalSpellTimeExceedingThreshold(dat2_1, thres2_1, spell = 2, time_dim = 'x'), - array(c(rep(0,5), rep(2,15)), c(ftime = 20)) + array(c(rep(0,5), rep(2,15)), c(time = 20)) ) # dimensions expect_equal( @@ -184,7 +184,7 @@ test_that("2. Output checks", { c(sdate = 2, lat = 2) ) expect_equal( - dim(TotalSpellTimeExceedingThreshold(dat2_4, thres2_4, spell = 3, time_dim = 'ftime')), + dim(TotalSpellTimeExceedingThreshold(dat2_4, thres2_4, spell = 3, time_dim = 'time')), c(fyear = 3, sdate = 2, lat = 2) ) }) @@ -206,11 +206,11 @@ test_that("3. Output checks", { array(c(rep(0,11),3), dim = c(fyear = 3, sdate = 2, lat = 2)) ) expect_equal( - TotalSpellTimeExceedingThreshold(dat3_2, c(46, 35), spell = 3, op = c("<", ">"), time_dim = 'ftime'), + TotalSpellTimeExceedingThreshold(dat3_2, c(46, 35), spell = 3, op = c("<", ">"), time_dim = 'time'), array(c(0, 3), c(x = 2)) ) expect_equal( - TotalSpellTimeExceedingThreshold(dat3_2, c(7,11), spell = 3, op = c('>=', '<='), time_dim = 'ftime'), + TotalSpellTimeExceedingThreshold(dat3_2, c(7,11), spell = 3, op = c('>=', '<='), time_dim = 'time'), array(c(3, 0), c(x = 2)) ) expect_equal( @@ -233,15 +233,15 @@ test_that("4. Output checks", { c(3, 5, 0) ) expect_equal( - as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_3, thres4_4), spell = 4, c(">", "<="), time_dim = 'ftime'))[1:5], + as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_3, thres4_4), spell = 4, c(">", "<="), time_dim = 'time'))[1:5], c(0, 5, 0, 5, 5) ) expect_equal( - as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_6, thres4_5), spell = 3, op = c("<", ">="), time_dim = 'ftime'))[1:5], + as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_6, thres4_5), spell = 3, op = c("<", ">="), time_dim = 'time'))[1:5], c(3, 5, 0, 5, 3) ) expect_equal( - as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_7, thres4_8), spell = 3, op = c('>=', '<='), time_dim = 'ftime'))[4:10], + as.vector(TotalSpellTimeExceedingThreshold(dat4, list(thres4_7, thres4_8), spell = 3, op = c('>=', '<='), time_dim = 'time'))[4:10], c(5, 3, 5, 4, 3, 5, 5) ) @@ -252,20 +252,20 @@ test_that("4. Output checks", { test_that("5. Seasonal Forecasts", { exp <- CSTools::lonlat_temp$exp exp$data <- exp$data[1,1:3,1:3,,,] - res <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = 260, spell = 2) + res <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = 260, spell = 2, time_dim = 'ftime') expect_equal( res$data[,,1,1], array(c(3,3,3,3,3,3,3,3,3), c(member = 3, sdate = 3)) ) # compare with percentile thresholdP <- Threshold(exp$data, threshold = 0.9) - WSDI <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = thresholdP, spell = 2) + WSDI <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = thresholdP, spell = 2, time_dim = 'ftime') expect_equal( WSDI$data[3,3,3,], c(rep(0, 6), rep(2, 2), 0, 2, 0, 2, rep(0, 29), 2, rep(0, 11)) ) thresholdP1 <- thresholdP[1,,] - WSDI1 <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = thresholdP1, spell = 2) + WSDI1 <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = thresholdP1, spell = 2, time_dim = 'ftime') expect_equal( WSDI1$data[3,3,3,], c(rep(0, 53))) diff --git a/tests/testthat/test-TotalTimeExceedingThreshold.R b/tests/testthat/test-TotalTimeExceedingThreshold.R index c025c3e..cba27ae 100644 --- a/tests/testthat/test-TotalTimeExceedingThreshold.R +++ b/tests/testthat/test-TotalTimeExceedingThreshold.R @@ -5,36 +5,36 @@ dat <- array(1:20, dim = c(2, 10)) thres <- 10 dat1 <- array(1:20, dim = c(time = 2, lat = 10)) thres1 <- array(1:2, dim = c(time = 2)) -dat1_2 <- array(1:40, c(x = 2, ftime = 20)) -threshold1_2 <- array(rep(10, 20), dim = c(member = 1, ftime = 20)) +dat1_2 <- array(1:40, c(x = 2, time = 20)) +threshold1_2 <- array(rep(10, 20), dim = c(member = 1, time = 20)) # dat2 -dat2_1 <- array(1:40, c(x = 2, ftime = 20)) -thres2_1 <- array(10, dim = c(member = 1, ftime = 1)) -dat2_3 <- array(1:20, c(ftime = 5, sdate = 2, lat = 2)) -thres2_3 <- array(1:5, c(ftime = 5)) -dat2_4 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat2_1 <- array(1:40, c(x = 2, time = 20)) +thres2_1 <- array(10, dim = c(member = 1, time = 1)) +dat2_3 <- array(1:20, c(time = 5, sdate = 2, lat = 2)) +thres2_3 <- array(1:5, c(time = 5)) +dat2_4 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) thres2_4 <- array(1:2, c(lat = 2)) # dat3 -dat3_1 <- array(1:60, c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) -dat3_2 <- array(1:40, c(x = 2, ftime = 20)) +dat3_1 <- array(1:60, c(time = 5, fyear = 3, sdate = 2, lat = 2)) +dat3_2 <- array(1:40, c(x = 2, time = 20)) # dat4 set.seed(1) -dat4 <- array(rnorm(60, 23), c(ftime = 5, fyear = 3, sdate = 2, lat = 2)) +dat4 <- array(rnorm(60, 23), c(time = 5, fyear = 3, sdate = 2, lat = 2)) set.seed(1) -thres4_1 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2, lat = 2)) +thres4_1 <- array(rnorm(20, 20), c(time = 5, sdate = 2, lat = 2)) set.seed(2) -thres4_2 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2, lat = 2)) +thres4_2 <- array(rnorm(20, 25), c(time = 5, sdate = 2, lat = 2)) set.seed(1) -thres4_3 <- array(rnorm(20, 20), c(ftime = 5, sdate = 2)) +thres4_3 <- array(rnorm(20, 20), c(time = 5, sdate = 2)) set.seed(2) -thres4_4 <- array(rnorm(20, 25), c(ftime = 5, sdate = 2)) +thres4_4 <- array(rnorm(20, 25), c(time = 5, sdate = 2)) set.seed(1) -thres4_5 <- array(rnorm(5, 20), c(ftime = 5)) +thres4_5 <- array(rnorm(5, 20), c(time = 5)) set.seed(2) -thres4_6 <- array(rnorm(5, 25), c(ftime = 5)) +thres4_6 <- array(rnorm(5, 25), c(time = 5)) set.seed(1) thres4_7 <- rnorm(5, 20) set.seed(2) @@ -136,7 +136,7 @@ test_that("1. Sanity checks", { ) # start and end when dates is not provided expect_warning( - TotalTimeExceedingThreshold(array(1:10, c(ftime = 10)), threshold = 5, + TotalTimeExceedingThreshold(array(1:10, c(time = 10)), threshold = 5, start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -165,7 +165,7 @@ test_that("2. Output checks", { ) expect_equal( TotalTimeExceedingThreshold(dat2_1, thres2_1, time_dim = 'x'), - array(c(rep(0,5), rep(2,15)), c(ftime = 20)) + array(c(rep(0,5), rep(2,15)), c(time = 20)) ) # dimensions expect_equal( @@ -177,7 +177,7 @@ test_that("2. Output checks", { c(sdate = 2, lat = 2) ) expect_equal( - dim(TotalTimeExceedingThreshold(dat2_4, thres2_4, time_dim = 'ftime')), + dim(TotalTimeExceedingThreshold(dat2_4, thres2_4, time_dim = 'time')), c(fyear = 3, sdate = 2, lat = 2) ) }) @@ -198,11 +198,11 @@ test_that("3. Output checks", { array(c(rep(0, 10), 1, 3), dim = c(fyear = 3, sdate = 2, lat = 2)) ) expect_equal( - TotalTimeExceedingThreshold(dat3_2, c(46, 35), op = c("<", ">"), time_dim = 'ftime'), + TotalTimeExceedingThreshold(dat3_2, c(46, 35), op = c("<", ">"), time_dim = 'time'), array(c(2, 3), c(x = 2)) ) expect_equal( - TotalTimeExceedingThreshold(dat3_2, c(7, 11), op = c('>=', '<='), time_dim = 'ftime'), + TotalTimeExceedingThreshold(dat3_2, c(7, 11), op = c('>=', '<='), time_dim = 'time'), array(c(3, 2), c(x = 2)) ) expect_equal( @@ -223,15 +223,15 @@ test_that("4. Output checks", { c(4, 5, 3) ) expect_equal( - as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_3, thres4_4), c(">", "<="), time_dim = 'ftime'))[1:5], + as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_3, thres4_4), c(">", "<="), time_dim = 'time'))[1:5], c(4, 5, 3, 5, 5) ) expect_equal( - as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_6, thres4_5), op = c("<", ">="), time_dim = 'ftime'))[1:5], + as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_6, thres4_5), op = c("<", ">="), time_dim = 'time'))[1:5], c(4, 5, 3, 5, 4) ) expect_equal( - as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_7, thres4_8), op = c('>=', '<='), time_dim = 'ftime'))[4:10], + as.vector(TotalTimeExceedingThreshold(dat4, list(thres4_7, thres4_8), op = c('>=', '<='), time_dim = 'time'))[4:10], c(5, 4, 5, 4, 4, 5, 5) ) }) @@ -243,17 +243,17 @@ test_that("5. Seasonal forecasts", { exp <- CSTools::lonlat_temp$exp obs <- CSTools::lonlat_temp$obs exp$data <- exp$data[1, 1:3, , , , ] - 247 - SU35_NoP <- CST_TotalTimeExceedingThreshold(exp, threshold = 35)$data + SU35_NoP <- CST_TotalTimeExceedingThreshold(exp, threshold = 35, time_dim = 'ftime')$data expect_equal( SU35_NoP[1, , 15, 3], c(0, 1, 1, 1, 0, 0) ) # convert to percentile exp_percentile <- AbsToProbs(exp$data) - obs_percentile <- drop(QThreshold(obs$data, threshold = 35)) + obs_percentile <- drop(QThreshold(obs$data, threshold = 35, time_dim = 'ftime')) data <- exp data$data <- exp_percentile - SU35_P <- CST_TotalTimeExceedingThreshold(data, threshold = obs_percentile)$data + SU35_P <- CST_TotalTimeExceedingThreshold(data, threshold = obs_percentile, time_dim = 'ftime')$data expect_equal( SU35_P[2, , 5, 5], c(3, 3, 3, 3, 3, 3) diff --git a/tests/testthat/test-WindCapacityFactor.R b/tests/testthat/test-WindCapacityFactor.R index 3afa27e..a2c3fbf 100644 --- a/tests/testthat/test-WindCapacityFactor.R +++ b/tests/testthat/test-WindCapacityFactor.R @@ -14,7 +14,7 @@ WCF <- CST_WindCapacityFactor(wind, IEC_class = "III") # dat2 dat2 <- array(abs(rnorm(5 * 3 * 214 * 2)*50), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), @@ -22,7 +22,7 @@ dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) dates2 <- dates0 -dim(dates2) <- c(sdate = 3, ftime = 214) +dim(dates2) <- c(sdate = 3, time = 214) ################################################### test_that("1. Input checks", { @@ -47,7 +47,7 @@ test_that("1. Input checks", { ) # start and end when dates is not provided expect_warning( - WindCapacityFactor(array(1:10, c(ftime = 10)), + WindCapacityFactor(array(1:10, c(time = 10)), start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -74,7 +74,7 @@ test_that("2. Output checks", { expect_equal( dim(WindCapacityFactor(wind = dat2, IEC_class = "III", dates = dates2, start = list(21, 4), end = list(21, 6))), - c(member = 5, sdate = 3, ftime = 52, lon = 2) + c(member = 5, sdate = 3, time = 52, lon = 2) ) }) diff --git a/tests/testthat/test-WindPowerDensity.R b/tests/testthat/test-WindPowerDensity.R index 999235a..e6e981e 100644 --- a/tests/testthat/test-WindPowerDensity.R +++ b/tests/testthat/test-WindPowerDensity.R @@ -13,7 +13,7 @@ class(wind) <- 's2dv_cube' # dat2 dat2 <- array(abs(rnorm(5 * 3 * 214 * 2)*50), - c(member = 5, sdate = 3, ftime = 214, lon = 2)) + c(member = 5, sdate = 3, time = 214, lon = 2)) dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'), seq(as.Date("01-05-2001", format = "%d-%m-%Y"), @@ -21,7 +21,7 @@ dates0 <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), seq(as.Date("01-05-2002", format = "%d-%m-%Y"), as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) dates2 <- dates0 -dim(dates2) <- c(sdate = 3, ftime = 214) +dim(dates2) <- c(sdate = 3, time = 214) ########################################################################### test_that("1. Input checks", { @@ -46,7 +46,7 @@ test_that("1. Input checks", { ) # start and end when dates is not provided expect_warning( - WindPowerDensity(array(1:10, c(ftime = 10)), + WindPowerDensity(array(1:10, c(time = 10)), start = list(05, 02), end = list(05, 09)), paste0("Parameter 'dates' is NULL and the average of the full data ", "provided in 'data' is computed.") @@ -73,7 +73,7 @@ test_that("2. Output checks", { expect_equal( dim(WindPowerDensity(wind = dat2, dates = dates2, start = list(21, 4), end = list(21, 6))), - c(member = 5, sdate = 3, ftime = 52, lon = 2) + c(member = 5, sdate = 3, time = 52, lon = 2) ) }) -- GitLab