diff --git a/NAMESPACE b/NAMESPACE index 80f1ec626b0f5352041b5a97cf65fc7dd2ee8a0e..65c34f0352e9b40ac738e36d4101fcf05a6ce550 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 8cec416124582c8304609f18b730694a8f5dce6f..529f7875746a521e8aee7763ca8f22584d34a63b 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 2e41273d1212395ef6fc17421cd1f4d15336e239..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..2bac4182945cc2a22df20757ab1114193d932672 --- /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 7c83f69830088c1948bfb5f152869b0b772fdbb9..dabb190a10ecb7bf7f85176eddf5483657e00761 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)) + }