From 6ac9d9ec30f9cf994a85dbb2a975faf3f3bb6620 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 3 Feb 2021 15:29:08 +0100 Subject: [PATCH] Fixing master branch --- NAMESPACE | 1 + R/SelectPeriodOnData.R | 4 ---- R/TotalTimeExceedingThreshold.R | 11 ---------- man/CST_SelectPeriodOnData.Rd | 37 +++++++++++++++++++++++++++++++++ man/SelectPeriodOnData.Rd | 6 ++++-- 5 files changed, 42 insertions(+), 17 deletions(-) delete mode 100644 R/TotalTimeExceedingThreshold.R create mode 100644 man/CST_SelectPeriodOnData.Rd diff --git a/NAMESPACE b/NAMESPACE index 80f1ec6..65c34f0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand export(CST_PeriodAccumulation) +export(CST_SelectPeriodOnData) export(PeriodAccumulation) export(SelectPeriodOnData) export(SelectPeriodOnDates) diff --git a/R/SelectPeriodOnData.R b/R/SelectPeriodOnData.R index 8cec416..529f787 100644 --- a/R/SelectPeriodOnData.R +++ b/R/SelectPeriodOnData.R @@ -23,8 +23,6 @@ #' seq(as.Date("01-05-2002", format = "%d-%m-%Y"), #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) #'Period <- CST_SelectPeriodOnData(exp, start = list(21, 6), end = list(21, 9)) -#'all.equal(exp$data[1,1,52:144,1], Period$data[,1,1,1]) -#'all.equal(exp$data[1,2,52:144,1], Period$data[,1,2,1]) #'@export CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'ftime', ncores = NULL) { if (!inherits(data, 's2dv_cube')) { @@ -85,8 +83,6 @@ CST_SelectPeriodOnData <- function(data, start, end, time_dim = 'ftime', ncores #' as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day')) #'dim(Dates) <- c(ftime = 214, sdate = 3) #'Period <- SelectPeriodOnData(data, Dates, start = list(21, 6), end = list(21, 9)) -#'all.equal(data[1,1,52:144,1], res[,1,1,1]) -#'all.equal(data[1,2,52:144,1], res[,1,2,1]) #' #'@export SelectPeriodOnData <- function(data, dates, start, end, diff --git a/R/TotalTimeExceedingThreshold.R b/R/TotalTimeExceedingThreshold.R deleted file mode 100644 index 2e41273..0000000 --- a/R/TotalTimeExceedingThreshold.R +++ /dev/null @@ -1,11 +0,0 @@ -#' Total Time Exceeding Threshold on 's2dv_cube' objects -#' -#'TotalTimeExceedingThreshold computes the total time (e.g. days) above/below a given threshold for a given period. -#'The threshold can be a fixed value (e.g. 35°C) or a percentile corresponding to a fixed value. -#'Providing daily temperature maximum data, the following indicators can be obtained by using this function: -#'\itemize{ -#' \item\code{SU35}{Number of Heat Stress Days - 35°C in summer: The total count of days when daily maximum temperatures exceed 35°C in the seven months into the future.} -#' \item\code{SU36}{Number of Heat Stress Days - 36°C in summer: The total count of days when daily maximum temperatures exceed 36°C from June 21st to September 21st.} - - - diff --git a/man/CST_SelectPeriodOnData.Rd b/man/CST_SelectPeriodOnData.Rd new file mode 100644 index 0000000..2bac418 --- /dev/null +++ b/man/CST_SelectPeriodOnData.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/SelectPeriodOnData.R +\name{CST_SelectPeriodOnData} +\alias{CST_SelectPeriodOnData} +\title{Select a period on Data on 's2dv_cube' objects} +\usage{ +CST_SelectPeriodOnData(data, start, end, time_dim = "ftime", ncores = NULL) +} +\arguments{ +\item{data}{an 's2dv_cube' object as provided function \code{CST_Load} in package CSTools.} + +\item{start}{a parameter to defined the initial date of the period to select from the data by providing a list of two elements: the initial date of the period and the initial month of the period.} + +\item{end}{a parameter to defined the final date of the period to select from the data by providing a list of two elements: the final day of the period and the final month of the period.} + +\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 dimension name matching the dimensions provided in the object \code{data$data} can be specified.} + +\item{ncores}{an integer indicating the number of cores to use in parallel computation.} +} +\value{ +A 's2dv_cube' object containing the subset of the object \code{data$data} during the period requested from \code{start} to \code{end}. +} +\description{ +Auxiliary function to subset data for a specific period. +} +\examples{ +exp <- CSTools::lonlat_prec +exp$data <- array(rnorm(5 * 3 * 214 * 2), + c(memb = 5, sdate = 3, ftime = 214, lon = 2)) +exp$Dates[[1]] <- 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')) +Period <- CST_SelectPeriodOnData(exp, start = list(21, 6), end = list(21, 9)) +} diff --git a/man/SelectPeriodOnData.Rd b/man/SelectPeriodOnData.Rd index 7c83f69..dabb190 100644 --- a/man/SelectPeriodOnData.Rd +++ b/man/SelectPeriodOnData.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/SelectPeriodOnData.R \name{SelectPeriodOnData} \alias{SelectPeriodOnData} -\title{Select a period on Dates} +\title{Select a period on Data on multidimensional array objects} \usage{ SelectPeriodOnData(data, dates, start, end, time_dim = "ftime", ncores = NULL) } @@ -34,5 +34,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')) -Period <- SelectPeriodOnDates(Dates, start = list(21, 6), end = list(21, 9)) +dim(Dates) <- c(ftime = 214, sdate = 3) +Period <- SelectPeriodOnData(data, Dates, start = list(21, 6), end = list(21, 9)) + } -- GitLab