diff --git a/.Rbuildignore b/.Rbuildignore index dde50c4ed94c4e248b7326787171e0c149ff9d42..fd5f70869cc2bc7216610a243704e8d049865154 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,6 @@ .*\.git$ .*\.gitignore$ +.*\.gitlab$ .*\.tar.gz$ .*\.pdf$ ./.nc$ diff --git a/DESCRIPTION b/DESCRIPTION index fa83573ecde0fa34089af0974ee6dbc1214d16c3..d0cf868e2b67b882301f94dea2a1ccd32d373670 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,11 @@ Package: ClimProjDiags Title: Set of Tools to Compute Various Climate Indices -Version: 0.3.2 +Version: 0.3.3 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), + person("Victòria", "Agudetse", , "victoria.agudetse@bsc.es", role = c("cre")), person("Nuria", "Perez-Zanon", , "nuria.perez@bsc.es", role = c("aut"), comment = c(ORCID = "0000-0001-8568-3071")), - person("An-Chi", "Ho", , "an.ho@bsc.es", role = c("cre", "ctb")), + person("An-Chi", "Ho", , "an.ho@bsc.es", role = c("ctb")), person("Nicolau", "Manubens", , "nicolau.manubens@bsc.es", role = "ctb"), person("Alasdair", "Hunter", , "alasdair.hunter@bsc.es", role = "aut"), person("Louis-Philippe", "Caron", , "louis-philippe.caron@bsc.es", role = "ctb"), @@ -21,7 +22,6 @@ Depends: Imports: multiApply (>= 2.0.0), PCICt, - plyr, stats Suggests: knitr, @@ -32,6 +32,6 @@ License: GPL-3 URL: https://earth.bsc.es/gitlab/es/ClimProjDiags BugReports: https://earth.bsc.es/gitlab/es/ClimProjDiags/-/issues Encoding: UTF-8 -RoxygenNote: 7.2.0 +RoxygenNote: 7.3.1 VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index 45f9e0544cbc424d9852267f98d9eb1b702a9cfa..3df80bb3f0a12b6641fb69107e6617ee2e5c0816 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# 0.3.3 (Release date: 2024-01-25) +- Bugfix in Subset() for drop = T, didn't have correct given output dimension therefore returned error. It happened when the output dimension is 1 and the length is > 1. + # 0.3.2 (Release date: 2023-06-01) - Remove climdex.pcic dependency diff --git a/R/AnoAgree.R b/R/AnoAgree.R index 4212039b30caf83e43d1ec57fdddb088a08d715e..fd2d1f1cc392975b144f92b19c8098e2a0155dac 100644 --- a/R/AnoAgree.R +++ b/R/AnoAgree.R @@ -1,13 +1,19 @@ -#'Percentage of anomalies which agrees with the sign of the mean anomaly for multidimensional arrays +#'Percentage of anomalies which agrees with the sign of the mean anomaly for +#'multidimensional arrays #' -#'@description This function computes the mean and the percentage of agreement between anomalies. +#'@description This function computes the mean and the percentage of agreement +#'between anomalies. #' #'@param ano A multidimensional array. #'@param membersdim The dimension in which models are stored. -#'@param na.rm A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored. +#'@param na.rm A logical indicating whether missing values should be removed. If +#' \code{na.rm} is FALSE an NA value in any of the arguments will cause a value +#' of NA to be returned, otherwise (TRUE by default) NA values are ignored. #'@param ncores The number of cores to be used when computing the agreement. #' -#'@return An array of one dimension less than the \code{ano} object, except for one dimensional arrays or vectors, for which an array of dimension 1 called 'var' is returned. +#'@return An array of one dimension less than the \code{ano} object, except for +#'one dimensional arrays or vectors, for which an array of dimension 1 called +#''var' is returned. #' #'@import multiApply #'@examples @@ -16,7 +22,8 @@ #'for(i in 1:20) { a <- c(a, rnorm(6)) } #'dim(a) <- c(lat = 2, lon = 3, var = 4, mod = 5) #' -#'agree <- AnoAgree(ano = a, membersdim = which(names(dim(a)) == 'mod'), na.rm = TRUE, ncores = NULL) +#'agree <- AnoAgree(ano = a, membersdim = which(names(dim(a)) == 'mod'), +#' na.rm = TRUE, ncores = NULL) #'print(agree) #' #'a <- rnorm(6) diff --git a/R/ArrayToList.R b/R/ArrayToList.R index e99855ea79a6ac03c596ff630f8b7157c3fb1223..a36de39393fb1691ac00b798252254a01195fed3 100644 --- a/R/ArrayToList.R +++ b/R/ArrayToList.R @@ -1,11 +1,18 @@ #' Split an array into list by a given array dimension #' -#'@description This function splits an array into a list as required by PlotLayout function from package "s2dv" when parameter 'special_args' is used. The function ArrayToList allows to add names to the elements of the list in two different levels, the 'list' or the 'sublist'. +#'@description This function splits an array into a list as required by +#'PlotLayout function from package "s2dv" when parameter 'special_args' is used. +#'The function ArrayToList allows to add names to the elements of the list in +#'two different levels, the 'list' or the 'sublist'. #' #'@param data A multidimensional array. -#'@param dim A character string indicating the name of the dimension to split or an integer indicating the position of the dimension. -#'@param level A string character 'list' or 'sublist' indicating if it should be a list or a sublist. By default it creates a list. -#'@param names A vector of character strings to name the list (if it is a single string, it would be reused) or a single character string to name the elements in the sublist. +#'@param dim A character string indicating the name of the dimension to split or +#' an integer indicating the position of the dimension. +#'@param level A string character 'list' or 'sublist' indicating if it should be +#' a list or a sublist. By default it creates a list. +#'@param names A vector of character strings to name the list (if it is a single +#' string, it would be reused) or a single character string to name the +#' elements in the sublist. #' #'@return A list of arrays of the length of the dimension set in parameter 'dim'. #' diff --git a/R/Climdex.R b/R/Climdex.R index 74da9045edfe2d33ad55a90a576805b6c7d9941c..a3e6ea758ae5d17d52d3cb618b3317492d71eb9e 100644 --- a/R/Climdex.R +++ b/R/Climdex.R @@ -23,10 +23,10 @@ #' #'@return A list of length 2: #'\itemize{ -#' \item\code{$result} {An array with the same dimensions as the input array, -#' except for the temporal dimension which is renamed to 'year', moved to the -#' first dimension position and reduce to annual resolution.} -#' \item\code{$years} {A vector of the corresponding years.} +#' \item{\code{$result}, an array with the same dimensions as the input array, +#' except for the temporal dimension which is renamed to 'year', moved +#' to the first dimension position and reduce to annual resolution.} +#' \item{\code{$years}, a vector of the corresponding years.} #'} #' #'@import multiApply diff --git a/R/CombineIndices.R b/R/CombineIndices.R index 05f04c98b02c4ce59580296ab1c56da500743405..2ae17bb02e5ebcde6c576e8ea80d995068f782ee 100644 --- a/R/CombineIndices.R +++ b/R/CombineIndices.R @@ -1,25 +1,35 @@ #'Combine weighted indices of n-dimensional arrays #' -#'@description Function to combine climate indices for multiple models through addition, subtraction, division or averaging, optionally applying weights to each index. +#'@description Function to combine climate indices for multiple models through +#'addition, subtraction, division or averaging, optionally applying weights to +#'each index. #' -#'@param indices List of n-dimensional arrays with equal dimensions to be combined. -#'@param weights Vector of weights for the indices, whose length is the same as the list of parameter \code{indices}. If not provided, a weight of 1 is assigned to each index. If \code{operation = 'mean'} the weights are normalized to sum 1 all together. -#'@param operation The operation for combining the indices, either \code{"mean"} (default), \code{"add"}, \code{"subtract"} or \code{"divide"}. +#'@param indices List of n-dimensional arrays with equal dimensions to be +#' combined. +#'@param weights Vector of weights for the indices, whose length is the same as +#' the list of parameter \code{indices}. If not provided, a weight of 1 is +#' assigned to each index. If \code{operation = 'mean'} the weights are +#' normalized to sum 1 all together. +#'@param operation The operation for combining the indices, either \code{"mean"} +#' (default), \code{"add"}, \code{"subtract"} or \code{"divide"}. #' -#'@return An array of the same dimensions as one of the elements in the parameter \code{indices}. +#'@return An array of the same dimensions as one of the elements in the +#'parameter \code{indices}. #' #'@examples #'a <- matrix(rnorm(6), 2, 3) #'b <- matrix(rnorm(6), 2, 3) #' -#'comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), operation = "add") +#'comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), +#' operation = "add") #'print(comb_ind) #' #'a <- rnorm(24) #'dim(a) <- c(lon = 2, lat = 3, mod = 4) #'b <- rnorm(24) #'dim(b) <- c(lon = 2, lat = 3, mod = 4) -#'comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), operation = "add") +#'comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), +#' operation = "add") #'print(comb_ind) #'@export CombineIndices <- function(indices, weights = NULL, operation = "mean") { diff --git a/R/DTRIndicator.R b/R/DTRIndicator.R index 7f32b9cf47ea5cfba76d19da8f5b6cbc7b499fab..0c27723f8b118a45b96167e01d01cc5b0c2f9d55 100644 --- a/R/DTRIndicator.R +++ b/R/DTRIndicator.R @@ -1,21 +1,43 @@ #'Diurnal temperature range indicator (DTR) of multidimensional arrays #' -#'@description This function computes the diurnal temperature indicator, defined as the number of days where the diurnal temperature variation exceeds the vulnerability threshold (defined as the mean(tmax -tmin) + 5 from the reference period). +#'@description This function computes the diurnal temperature indicator, defined +#'as the number of days where the diurnal temperature variation exceeds the +#'vulnerability threshold (defined as the mean(tmax -tmin) + 5 from the +#'reference period). #' -#'@param tmax A numeric multidimensional array containing daily maximum temperature. -#'@param tmin A numeric multidimensional array containing daily minimum temperature. This array must be the same dimensions as \code{tmax} parameter. -#'@param ref An output list from the \code{DTRRef} function with the same dimensions as parameters \code{tmax} and \code{tmin}, except the time dimension, containing the mean diurnal temperature variation for the reference period. -#'@param by.seasons If TRUE (by default), the DTR is computed for each season (December-January-February, March-April-May, June-July-August and September-October-November) seperately. If FALSE is specified, the montly mean DTR is computed. -#'@param dates A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'tmax' and 'tmin' are considered. -#'@param timedim An integer number indicating the position of the time dimension in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the dimension called 'time' in parameter \code{tmax} and \code{tmin} is considered as time dimension. +#'@param tmax A numeric multidimensional array containing daily maximum +#' temperature. +#'@param tmin A numeric multidimensional array containing daily minimum +#' temperature. This array must be the same dimensions as \code{tmax} +#' parameter. +#'@param ref An output list from the \code{DTRRef} function with the same +#' dimensions as parameters \code{tmax} and \code{tmin}, except the time +#' dimension, containing the mean diurnal temperature variation for the +#' reference period. +#'@param by.seasons If TRUE (by default), the DTR is computed for each season +#' (December-January-February, March-April-May, June-July-August and +#' September-October-November) seperately. If FALSE is specified, the montly +#' mean DTR is computed. +#'@param dates A vector of dates with a calendar attributes. If NULL (by +#' default), the 'time' attributes of parameter 'tmax' and 'tmin' are +#' considered. +#'@param timedim An integer number indicating the position of the time dimension +#' in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the +#' dimension called 'time' in parameter \code{tmax} and \code{tmin} is +#' considered as time dimension. #'@param calendar A character indicating the calendar type. #'@param ncores The number of cores to be used when computing the index. #' #'@return A list of length 3: #'\itemize{ -#'\item\code{$dtr.ref}{An array with the same dimensions as the input \code{data}, but with the time dimension reduce from daily to monthly or seasonal resolution depending on the selected resolution in \code{by.season}.} -#'\item\code{$year}{A vector of the corresponding years.} -#'\item\code{$season}{A vector of the seasons or months corresponding to the resolution selected in \code{by.season}}} +#' \item{\code{$dtr.ref}, an array with the same dimensions as the input +#' \code{data}, but with the time dimension reduce from daily to monthly +#' or seasonal resolution depending on the selected resolution in +#' \code{by.season}.} +#' \item{\code{$year}, a vector of the corresponding years.} +#' \item{\code{$season}, a vector of the seasons or months corresponding to the +#' resolution selected in \code{by.season}.} +#'} #' #'@import multiApply #'@examples @@ -24,12 +46,15 @@ #'dim(tmax) <- c(lon = 2, lat = 3, time = 730, model = 1) #'tmin <- (1 : (2 * 3 * 730 * 1)) - 1 #'dim(tmin) <- c(lon = 2, lat = 3, time = 730, model = 1) -#'time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", format = "%Y-%d-%m %H:%M:%S"), -#' as.POSIXct("1901-31-12 18:00:00", tz = "", format = "%Y-%d-%m %H:%M:%S"), "day") +#'time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", +#' format = "%Y-%d-%m %H:%M:%S"), +#' as.POSIXct("1901-31-12 18:00:00", tz = "", +#' format = "%Y-%d-%m %H:%M:%S"), "day") #'time <- as.POSIXct(time, tz = "CET") #'metadata <- list(time = list(standard_name = 'time', long_name = 'time', #' calendar = 'noleap', -#' units = 'days since 1970-01-01 00:00:00', prec = 'double', +#' units = 'days since 1970-01-01 00:00:00', +#' prec = 'double', #' dim = list(list(name ='time', unlim = FALSE)))) #'attr(time, "variables") <- metadata #'attr(tmax, 'Variables')$dat1$time <- time diff --git a/R/DTRRef.R b/R/DTRRef.R index f275ddca810a4446ba059370797159588df39547..fb6e964b790a8976534ef5d7ae9cf28559bfe5a8 100644 --- a/R/DTRRef.R +++ b/R/DTRRef.R @@ -1,22 +1,41 @@ #'Diurnal temperature range of multidimensional arrays #' -#'@description This function computes the mean diurnal temperature range (tmax - tmin). +#'@description This function computes the mean diurnal temperature range +#'(tmax - tmin). #' -#'@param tmax A numeric multidimensional array containing daily maximum temperature. -#'@param tmin A numeric multidimensional array containing daily minimum temperature. -#'@param by.seasons If TRUE (by default), the DTR is computed for each season (December-January-February, March-April-May, June-July-August and September-October-November) seperately. If FALSE is specified, the montly mean DTR is computed. -#'@param dates A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'tmax' and 'tmin' are considered. -#'@param timedim An integer number indicating the position of the time dimension in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the dimension called 'time' in parameter \code{tmax} and \code{tmin} is considered as time dimension. +#'@param tmax A numeric multidimensional array containing daily maximum +#' temperature. +#'@param tmin A numeric multidimensional array containing daily minimum +#' temperature. +#'@param by.seasons If TRUE (by default), the DTR is computed for each season +#' (December-January-February, March-April-May, June-July-August and +#' September-October-November) seperately. If FALSE is specified, the montly +#' mean DTR is computed. +#'@param dates A vector of dates with a calendar attributes. If NULL (by +#' default), the 'time' attributes of parameter 'tmax' and 'tmin' are +#' considered. +#'@param timedim An integer number indicating the position of the time dimension +#' in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the +#' dimension called 'time' in parameter \code{tmax} and \code{tmin} is +#' considered as time dimension. #'@param calendar A character indicating the calendar type. -#'@param na.rm A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored. +#'@param na.rm A logical indicating whether missing values should be removed. If +#' \code{na.rm} is FALSE an NA value in any of the arguments will cause a value +#' of NA to be returned, otherwise (TRUE by default) NA values are ignored. #'@param ncores The number of cores to be used when computing the index. #' #'@return A list of length 2: #'\itemize{ -#'\item\code{$dtr.ref} {An array with the same dimensions as the input \code{data}, but with the time dimension reduce from daily to monthly or seasonal resolution depending on the selected resolution in \code{by.season}.} -#'\item\code{$season} {A vector of the season or months corresponding to the resolution selected in \code{by.season}}} +#' \item{\code{$dtr.ref}, an array with the same dimensions as the input +#' \code{data}, but with the time dimension reduce from daily to monthly +#' or seasonal resolution depending on the selected resolution in +#' \code{by.season}.} +#'\item{\code{$season}, a vector of the season or months corresponding to the +#' resolution selected in \code{by.season}.} +#'} #' -#'@details The function returns a reordered array with 'time' dimension in the first position in the \code{dtr.ref} label. +#'@details The function returns a reordered array with 'time' dimension in the +#' first position in the \code{dtr.ref} label. #' #'@import multiApply #'@examples @@ -30,7 +49,8 @@ #'time <- as.POSIXct(time, tz = "CET") #'metadata <- list(time = list(standard_name = 'time', long_name = 'time', #' calendar = 'noleap', -#' units = 'days since 1970-01-01 00:00:00', prec = 'double', +#' units = 'days since 1970-01-01 00:00:00', +#' prec = 'double', #' dim = list(list(name ='time', unlim = FALSE)))) #'attr(time, "variables") <- metadata #'attr(tmax, 'Variables')$dat1$time <- time @@ -48,7 +68,8 @@ #'tmin <- (1:(2 * 3 * 365 * 1))-1 #'dim(tmin) <- c(2, 3, 365) #' -#'a <- DTRRef(tmax, tmin, by.seasons = FALSE, dates = time, timedim = 3, ncores = NULL) +#'a <- DTRRef(tmax, tmin, by.seasons = FALSE, dates = time, timedim = 3, +#' ncores = NULL) #'str(a) #'@export DTRRef <- function(tmax, tmin, by.seasons = TRUE, dates = NULL, timedim = NULL, calendar = NULL, diff --git a/R/DailyAno.R b/R/DailyAno.R index d3df4cf3aba4f7d6900e1bcbaab056925a92dbe8..f0717d0b96dccd3da407174feae499d50ca5b4d3 100644 --- a/R/DailyAno.R +++ b/R/DailyAno.R @@ -1,14 +1,20 @@ #'Daily anomalies #' -#'@description This function computes daily anomalies from a vector containing the daily time series. +#'@description This function computes daily anomalies from a vector containing +#'the daily time series. #' #'@param data A vector of daily data. -#'@param jdays A vector of the corresponding day of the year. This vector must be the same length as parameter \code{data}. -#'@param dates If \code{jdays} is not supplied, a vector of dates corresponding to the observations in \code{data} with defined calendar attributes. +#'@param jdays A vector of the corresponding day of the year. This vector must +#' be the same length as parameter \code{data}. +#'@param dates If \code{jdays} is not supplied, a vector of dates corresponding +#' to the observations in \code{data} with defined calendar attributes. #'@param calendar A character indicating the calendar type. -#'@param na.rm A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored. +#'@param na.rm A logical indicating whether missing values should be removed. If +#' \code{na.rm} is FALSE an NA value in any of the arguments will cause a value +#' of NA to be returned, otherwise (TRUE by default) NA values are ignored. #' -#'@return A vector of daily anomalies of the same length as parameter \code{data}. +#'@return A vector of daily anomalies of the same length as parameter +#'\code{data}. #' #'@examples #'# Time series in a vector example: diff --git a/R/Extremes.R b/R/Extremes.R index 149fd96c9179c3cf0d066d0977a5d4493efa7191..eab67937e459fc6387e6822237ea96d08275684f 100644 --- a/R/Extremes.R +++ b/R/Extremes.R @@ -22,10 +22,10 @@ #' #'@return A list of length 2: #'\itemize{ -#' \item\code{$output1}{An array with the same dimensions as the original -#' \code{data}, except the time dimension which is reduced to annual resolution -#' given a timeseries of maximum spell lengths for each year.} -#' \item\code{$year}{A vector indicating the corresponding years.} +#' \item{\code{$output1}, an array with the same dimensions as the original +#' \code{data}, except the time dimension which is reduced to annual +#' resolution given a timeseries of maximum spell lengths for each year.} +#' \item{\code{$year}, a vector indicating the corresponding years.} #'} #'@details This routine compares data to the thresholds using the given #'operator, generating a series of TRUE or FALSE values; these values are then @@ -45,11 +45,13 @@ #'time <- as.POSIXct(paste(sort(rep(1902:1911, 31)), 1, 1:31, sep = "-"), tz = "CET") #'metadata <- list(time = list(standard_name = 'time', long_name = 'time', #' calendar = 'noleap', -#' units = 'days since 1970-01-01 00:00:00', prec = 'double', +#' units = 'days since 1970-01-01 00:00:00', +#' prec = 'double', #' dim = list(list(name = 'time', unlim = FALSE)))) #'attr(time, "variables") <- metadata #'attr(data, 'Variables')$dat1$time <- time -#'threshold <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, ncores = NULL) +#'threshold <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, +#' ncores = NULL) #'res <- Extremes(data, threshold = threshold, op = ">", min.length = 6, #' spells.can.span.years = TRUE, max.missing.days = 5, #' ncores = NULL) diff --git a/R/Lon2Index.R b/R/Lon2Index.R index 1ab719714f75954d954e2a58cb9cea48ab9eb826..e77559587b625f149522bd60bf34e8b8122a8526 100644 --- a/R/Lon2Index.R +++ b/R/Lon2Index.R @@ -1,12 +1,16 @@ #'Obtain the index of positions for a region in longitudes #' -#'@description This auxiliary function returns the index of position of a region of longitudes in a given vector of longitudes. +#'@description This auxiliary function returns the index of position of a region +#'of longitudes in a given vector of longitudes. #' #'@param lon vector of longitudes values. -#'@param lonmin a numeric value indicating the minimum longitude of the region (understand as the left marging of the region). -#'@param lonmax a numeric value indicating the maximum longitude of the region (understand as the right mariging of the region). +#'@param lonmin a numeric value indicating the minimum longitude of the region +#' (understand as the left marging of the region). +#'@param lonmax a numeric value indicating the maximum longitude of the region +#' (understand as the right mariging of the region). #' -#'@return the index of positions of all values inside the region in the vector lon. +#'@return the index of positions of all values inside the region in the vector +#'lon. #' #'@examples #' diff --git a/R/SeasonSelect.R b/R/SeasonSelect.R index 168696b97326ccaf6d1ecb94c8a00fc0f4bedf96..6ee8fbbc72c237c95b4bcb4f50ca35460ccaee97 100644 --- a/R/SeasonSelect.R +++ b/R/SeasonSelect.R @@ -1,17 +1,29 @@ #'Selects a season from daily data for multidimensional arrays #' -#'@description This function selects the daily data corresponding to the specified season. +#'@description This function selects the daily data corresponding to the +#'specified season. #' #'@param data A numeric multidimensional array containing daily data. -#'@param season A charcater string indicating the season by the three months initials in capitals: 'DJF' for winter (summer), 'MAM' spring (autumn), 'JJA' for summer (winter) or 'SON' for autumn (spring) in the northern (southern) hemisphere. -#'@param dates A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' are considered. -#'@param timedim An integer number indicating the position of the time dimension in the parameter \code{data}. If NULL (by default), the dimension called 'time' in parameter \code{data}. +#'@param season A charcater string indicating the season by the three months +#' initials in capitals: 'DJF' for winter (summer), 'MAM' spring (autumn), +#' 'JJA' for summer (winter) or 'SON' for autumn (spring) in the northern +#' (southern) hemisphere. +#'@param dates A vector of dates with a calendar attributes. If NULL (by +#' default), the 'time' attributes of parameter 'data' are considered. +#'@param timedim An integer number indicating the position of the time dimension +#' in the parameter \code{data}. If NULL (by default), the dimension called +#' 'time' in parameter \code{data}. #'@param calendar A character indicating the calendar type. #' #'@return A list of length 2: #'\itemize{ -#'\item\code{$data} {A vector or array containing the daily values for the selected season, with the same dimensions as \code{data} input but the 'time' dimension reduce to the number of days corresponding to the selected season.} -#'\item\code{$dates} {A vector of dates reduce to the number of days corresponding to the selected season.}} +#' \item{\code{$data}, a vector or array containing the daily values for the +#' selected season, with the same dimensions as \code{data} input but the +#' 'time' dimension reduce to the number of days corresponding to the +#' selected season.} +#' \item{\code{$dates}, a vector of dates reduce to the number of days +#' corresponding to the selected season.} +#'} #' #'@import PCICt #'@examples @@ -22,7 +34,8 @@ #'time <- as.POSIXct(time, tz = "CET") #'metadata <- list(time = list(standard_name = 'time', long_name = 'time', #' calendar = 'noleap', -#' units = 'days since 1970-01-01 00:00:00', prec = 'double', +#' units = 'days since 1970-01-01 00:00:00', +#' prec = 'double', #' dim = list(list(name ='time', unlim = FALSE)))) #'attr(time, "variables") <- metadata #'attr(data, 'Variables')$dat1$time <- time diff --git a/R/SelBox.R b/R/SelBox.R index d743aef4728aef3cd1e2ddd72b1e888f2dc87da2..15ae6670463e8a17a05091edd4d411c8618252a0 100644 --- a/R/SelBox.R +++ b/R/SelBox.R @@ -1,7 +1,7 @@ #'Select spatial region from multidimensional arrays #' -#'@description Subset a spatial region from spatial data giving a vector with -#' the maximum and minimum of latitudes and longitudes of the selected region. +#'@description Subset a spatial region from spatial data giving a vector with +#'the maximum and minimum of latitudes and longitudes of the selected region. #' #'@param data An array with minimum two dimensions of latitude and longitude. #'@param lon Numeric vector of longitude locations of the cell centers of the @@ -18,16 +18,17 @@ #' #'@return A list of length 4: #'\itemize{ -#' \item\code{$data}{ -#' An array with the same dimensions as the input \code{data} array, but with -#' spatial dimension reduced to the selected \code{region}} -#' \item\code{$lat}{A vector with the new corresponding latitudes for the -#' selected \code{region}} -#' \item\code{$lon}{A vector with the new corresponding longitudes for the -#' selected \code{region}} -#' \item\code{$mask}{If parameter \code{mask} is supplied, an array with -#' reduced length of the dimensions to the selected \code{region}. Otherwise, -#' a NULL element is returned.}} +#' \item{\code{$data}, an array with the same dimensions as the input +#' \code{data} array, but with spatial dimension reduced to the selected +#' \code{region}.} +#' \item{\code{$lat}, a vector with the new corresponding latitudes for the +#' selected \code{region}.} +#' \item{\code{$lon}, a vector with the new corresponding longitudes for the +#' selected \code{region}.} +#' \item{\code{$mask}, if parameter \code{mask} is supplied, an array with +#' reduced length of the dimensions to the selected \code{region}. +#' Otherwise, a NULL element is returned.} +#'} #' #'@examples #'# Example with synthetic data: diff --git a/R/Threshold.R b/R/Threshold.R index c6f4298742096dc2fb31da533de2470b208ca9c4..7444e1ffacc2b33602b7edc38be419f273cf693f 100644 --- a/R/Threshold.R +++ b/R/Threshold.R @@ -1,16 +1,21 @@ #'Daily thresholds based on quantiles for n-dimensional arrays #' -#'This function computes the threshold based on a quantile value for each day of the year of the daily data input. +#'This function computes the threshold based on a quantile value for each day of +#'the year of the daily data input. #' #'@param data A numeric n-dimensional array containing daily data. -#'@param dates A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' is considered. +#'@param dates A vector of dates with a calendar attributes. If NULL (by +#' default), the 'time' attributes of parameter 'data' is considered. #'@param calendar A character indicating the calendar type. #'@param base.range The years used for computing the threshold. -#'@param qtiles Numeric vector with values between 0 and 1 indicating the quantiles to be computed. +#'@param qtiles Numeric vector with values between 0 and 1 indicating the +#' quantiles to be computed. #'@param ncores The number of cores to be used when computing the threshold. -#'@param na.rm A logical value. If TRUE, any NA and NaN's are removed before the quantiles are computed (default as FALSE). +#'@param na.rm A logical value. If TRUE, any NA and NaN's are removed before the +#' quantiles are computed (default as FALSE). #' -#'@return An array with similar dimensions as the \code{data} input, but without 'time' dimension, and a new 'jdays' dimension. +#'@return An array with similar dimensions as the \code{data} input, but without +#''time' dimension, and a new 'jdays' dimension. #' #'@import multiApply #'@import PCICt @@ -19,14 +24,17 @@ #'##Example synthetic data: #'data <- 1:(2 * 3 * 372 * 1) #'dim(data) <- c(time = 372, lon = 2, lat = 3, model = 1) -#'time <- as.POSIXct(paste(sort(rep(1900:1911, 31)), 1, 1:31, sep = "-"), tz = "CET") -#'metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', -#' units = 'days since 1970-01-01 00:00:00', prec = 'double', -#' dim = list(list(name = 'time', unlim = FALSE)))) +#'time <- as.POSIXct(paste(sort(rep(1900:1911, 31)), 1, 1:31, sep = "-"), +#' tz = "CET") +#'metadata <- list(time = list(standard_name = 'time', long_name = 'time', +#' calendar = 'noleap', +#' units = 'days since 1970-01-01 00:00:00', prec = 'double', +#' dim = list(list(name = 'time', unlim = FALSE)))) #'attr(time, "variables") <- metadata #'attr(data, 'Variables')$dat1$time <- time #' -#'a <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, ncores = NULL) +#'a <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, +#' ncores = NULL) #'str(a) #' #'@export diff --git a/R/WaveDuration.R b/R/WaveDuration.R index 76874f9775641d5c1509fdb465dc90d62a72e5a5..5206c322747b01cdaceb18723ea979180cae39d8 100644 --- a/R/WaveDuration.R +++ b/R/WaveDuration.R @@ -23,13 +23,15 @@ #'@param ncores The number of cores to be used when computing the wave duration. #' #'@return A list of length 2: -#' \itemize{ -#' \item\code{$result}{An array with the same dimensions as the input -#' \code{data}, but with the time dimension reduce from daily to monthly or -#' seasonal resolution depending on the selected resolution in \code{by.season}.} -#' \item\code{$years}{A vector of the years and season/months corresponding to -#' the resolution selected in \code{by.season} and temporal length of the input -#' \code{data}}} +#'\itemize{ +#' \item{\code{$result}, an array with the same dimensions as the input +#' \code{data}, but with the time dimension reduce from daily to monthly +#' or seasonal resolution depending on the selected resolution in +#' \code{by.season}.} +#' \item{\code{$years}, a vector of the years and season/months corresponding +#' to the resolution selected in \code{by.season} and temporal length of +#' the input \code{data}.} +#'} #' #'@import multiApply #'@import PCICt diff --git a/man/AnoAgree.Rd b/man/AnoAgree.Rd index 63c1450039013f94bee9c4e66d29c0923fcdab84..bb4b30fe94db198e53c432e03649faf27a1290a0 100644 --- a/man/AnoAgree.Rd +++ b/man/AnoAgree.Rd @@ -2,7 +2,8 @@ % Please edit documentation in R/AnoAgree.R \name{AnoAgree} \alias{AnoAgree} -\title{Percentage of anomalies which agrees with the sign of the mean anomaly for multidimensional arrays} +\title{Percentage of anomalies which agrees with the sign of the mean anomaly for +multidimensional arrays} \usage{ AnoAgree(ano, membersdim, na.rm = TRUE, ncores = NULL) } @@ -11,15 +12,20 @@ AnoAgree(ano, membersdim, na.rm = TRUE, ncores = NULL) \item{membersdim}{The dimension in which models are stored.} -\item{na.rm}{A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored.} +\item{na.rm}{A logical indicating whether missing values should be removed. If +\code{na.rm} is FALSE an NA value in any of the arguments will cause a value +of NA to be returned, otherwise (TRUE by default) NA values are ignored.} \item{ncores}{The number of cores to be used when computing the agreement.} } \value{ -An array of one dimension less than the \code{ano} object, except for one dimensional arrays or vectors, for which an array of dimension 1 called 'var' is returned. +An array of one dimension less than the \code{ano} object, except for +one dimensional arrays or vectors, for which an array of dimension 1 called +'var' is returned. } \description{ -This function computes the mean and the percentage of agreement between anomalies. +This function computes the mean and the percentage of agreement +between anomalies. } \examples{ # Example with random sample: @@ -27,7 +33,8 @@ a <- NULL for(i in 1:20) { a <- c(a, rnorm(6)) } dim(a) <- c(lat = 2, lon = 3, var = 4, mod = 5) -agree <- AnoAgree(ano = a, membersdim = which(names(dim(a)) == 'mod'), na.rm = TRUE, ncores = NULL) +agree <- AnoAgree(ano = a, membersdim = which(names(dim(a)) == 'mod'), + na.rm = TRUE, ncores = NULL) print(agree) a <- rnorm(6) diff --git a/man/ArrayToList.Rd b/man/ArrayToList.Rd index 9951ae13d42a263ce58fdfd20d954c8d23f84ed2..43d3278653cac0aa7a01c773d04ed9dd0c627f57 100644 --- a/man/ArrayToList.Rd +++ b/man/ArrayToList.Rd @@ -9,17 +9,24 @@ ArrayToList(data, dim, level = "list", names = NULL) \arguments{ \item{data}{A multidimensional array.} -\item{dim}{A character string indicating the name of the dimension to split or an integer indicating the position of the dimension.} +\item{dim}{A character string indicating the name of the dimension to split or +an integer indicating the position of the dimension.} -\item{level}{A string character 'list' or 'sublist' indicating if it should be a list or a sublist. By default it creates a list.} +\item{level}{A string character 'list' or 'sublist' indicating if it should be +a list or a sublist. By default it creates a list.} -\item{names}{A vector of character strings to name the list (if it is a single string, it would be reused) or a single character string to name the elements in the sublist.} +\item{names}{A vector of character strings to name the list (if it is a single +string, it would be reused) or a single character string to name the +elements in the sublist.} } \value{ A list of arrays of the length of the dimension set in parameter 'dim'. } \description{ -This function splits an array into a list as required by PlotLayout function from package "s2dv" when parameter 'special_args' is used. The function ArrayToList allows to add names to the elements of the list in two different levels, the 'list' or the 'sublist'. +This function splits an array into a list as required by +PlotLayout function from package "s2dv" when parameter 'special_args' is used. +The function ArrayToList allows to add names to the elements of the list in +two different levels, the 'list' or the 'sublist'. } \examples{ data <- array(1:240, c(month = 12, member = 5, time = 4)) diff --git a/man/Climdex.Rd b/man/Climdex.Rd index 7afbf0b0085d5e1a54a8d72743b407013574d67a..e7580e17849a98674abf93370d38051b6b3e5c6b 100644 --- a/man/Climdex.Rd +++ b/man/Climdex.Rd @@ -44,10 +44,10 @@ in the parameter \code{data}. If NULL (by default), the dimension called \value{ A list of length 2: \itemize{ - \item\code{$result} {An array with the same dimensions as the input array, - except for the temporal dimension which is renamed to 'year', moved to the - first dimension position and reduce to annual resolution.} - \item\code{$years} {A vector of the corresponding years.} + \item{\code{$result}, an array with the same dimensions as the input array, + except for the temporal dimension which is renamed to 'year', moved + to the first dimension position and reduce to annual resolution.} + \item{\code{$years}, a vector of the corresponding years.} } } \description{ diff --git a/man/CombineIndices.Rd b/man/CombineIndices.Rd index 6d032cddcba684a8375572aa6c259da2c9d5e982..f0e5ff6f66253c2be1865ad72067cff002fcaeb0 100644 --- a/man/CombineIndices.Rd +++ b/man/CombineIndices.Rd @@ -7,29 +7,39 @@ CombineIndices(indices, weights = NULL, operation = "mean") } \arguments{ -\item{indices}{List of n-dimensional arrays with equal dimensions to be combined.} +\item{indices}{List of n-dimensional arrays with equal dimensions to be +combined.} -\item{weights}{Vector of weights for the indices, whose length is the same as the list of parameter \code{indices}. If not provided, a weight of 1 is assigned to each index. If \code{operation = 'mean'} the weights are normalized to sum 1 all together.} +\item{weights}{Vector of weights for the indices, whose length is the same as +the list of parameter \code{indices}. If not provided, a weight of 1 is +assigned to each index. If \code{operation = 'mean'} the weights are +normalized to sum 1 all together.} -\item{operation}{The operation for combining the indices, either \code{"mean"} (default), \code{"add"}, \code{"subtract"} or \code{"divide"}.} +\item{operation}{The operation for combining the indices, either \code{"mean"} +(default), \code{"add"}, \code{"subtract"} or \code{"divide"}.} } \value{ -An array of the same dimensions as one of the elements in the parameter \code{indices}. +An array of the same dimensions as one of the elements in the +parameter \code{indices}. } \description{ -Function to combine climate indices for multiple models through addition, subtraction, division or averaging, optionally applying weights to each index. +Function to combine climate indices for multiple models through +addition, subtraction, division or averaging, optionally applying weights to +each index. } \examples{ a <- matrix(rnorm(6), 2, 3) b <- matrix(rnorm(6), 2, 3) -comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), operation = "add") +comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), + operation = "add") print(comb_ind) a <- rnorm(24) dim(a) <- c(lon = 2, lat = 3, mod = 4) b <- rnorm(24) dim(b) <- c(lon = 2, lat = 3, mod = 4) -comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), operation = "add") +comb_ind <- CombineIndices(indices = list(a, b), weights = c(2, 1), + operation = "add") print(comb_ind) } diff --git a/man/DTRIndicator.Rd b/man/DTRIndicator.Rd index e8be18bb79aa379757334633414c7ea5438dec0f..d310b7b6446c8c2c1e8d49941f6dd6669c89d5f8 100644 --- a/man/DTRIndicator.Rd +++ b/man/DTRIndicator.Rd @@ -16,17 +16,31 @@ DTRIndicator( ) } \arguments{ -\item{tmax}{A numeric multidimensional array containing daily maximum temperature.} +\item{tmax}{A numeric multidimensional array containing daily maximum +temperature.} -\item{tmin}{A numeric multidimensional array containing daily minimum temperature. This array must be the same dimensions as \code{tmax} parameter.} +\item{tmin}{A numeric multidimensional array containing daily minimum +temperature. This array must be the same dimensions as \code{tmax} +parameter.} -\item{ref}{An output list from the \code{DTRRef} function with the same dimensions as parameters \code{tmax} and \code{tmin}, except the time dimension, containing the mean diurnal temperature variation for the reference period.} +\item{ref}{An output list from the \code{DTRRef} function with the same +dimensions as parameters \code{tmax} and \code{tmin}, except the time +dimension, containing the mean diurnal temperature variation for the +reference period.} -\item{by.seasons}{If TRUE (by default), the DTR is computed for each season (December-January-February, March-April-May, June-July-August and September-October-November) seperately. If FALSE is specified, the montly mean DTR is computed.} +\item{by.seasons}{If TRUE (by default), the DTR is computed for each season +(December-January-February, March-April-May, June-July-August and +September-October-November) seperately. If FALSE is specified, the montly +mean DTR is computed.} -\item{dates}{A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'tmax' and 'tmin' are considered.} +\item{dates}{A vector of dates with a calendar attributes. If NULL (by +default), the 'time' attributes of parameter 'tmax' and 'tmin' are +considered.} -\item{timedim}{An integer number indicating the position of the time dimension in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the dimension called 'time' in parameter \code{tmax} and \code{tmin} is considered as time dimension.} +\item{timedim}{An integer number indicating the position of the time dimension +in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the +dimension called 'time' in parameter \code{tmax} and \code{tmin} is +considered as time dimension.} \item{calendar}{A character indicating the calendar type.} @@ -35,12 +49,20 @@ DTRIndicator( \value{ A list of length 3: \itemize{ -\item\code{$dtr.ref}{An array with the same dimensions as the input \code{data}, but with the time dimension reduce from daily to monthly or seasonal resolution depending on the selected resolution in \code{by.season}.} -\item\code{$year}{A vector of the corresponding years.} -\item\code{$season}{A vector of the seasons or months corresponding to the resolution selected in \code{by.season}}} + \item{\code{$dtr.ref}, an array with the same dimensions as the input + \code{data}, but with the time dimension reduce from daily to monthly + or seasonal resolution depending on the selected resolution in + \code{by.season}.} + \item{\code{$year}, a vector of the corresponding years.} + \item{\code{$season}, a vector of the seasons or months corresponding to the + resolution selected in \code{by.season}.} +} } \description{ -This function computes the diurnal temperature indicator, defined as the number of days where the diurnal temperature variation exceeds the vulnerability threshold (defined as the mean(tmax -tmin) + 5 from the reference period). +This function computes the diurnal temperature indicator, defined +as the number of days where the diurnal temperature variation exceeds the +vulnerability threshold (defined as the mean(tmax -tmin) + 5 from the +reference period). } \examples{ ##Exmaple with synthetic data: @@ -48,12 +70,15 @@ tmax <- 1 : (2 * 3 * 730 * 1) dim(tmax) <- c(lon = 2, lat = 3, time = 730, model = 1) tmin <- (1 : (2 * 3 * 730 * 1)) - 1 dim(tmin) <- c(lon = 2, lat = 3, time = 730, model = 1) -time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", format = "\%Y-\%d-\%m \%H:\%M:\%S"), - as.POSIXct("1901-31-12 18:00:00", tz = "", format = "\%Y-\%d-\%m \%H:\%M:\%S"), "day") +time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", + format = "\%Y-\%d-\%m \%H:\%M:\%S"), + as.POSIXct("1901-31-12 18:00:00", tz = "", + format = "\%Y-\%d-\%m \%H:\%M:\%S"), "day") time <- as.POSIXct(time, tz = "CET") metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', - units = 'days since 1970-01-01 00:00:00', prec = 'double', + units = 'days since 1970-01-01 00:00:00', + prec = 'double', dim = list(list(name ='time', unlim = FALSE)))) attr(time, "variables") <- metadata attr(tmax, 'Variables')$dat1$time <- time diff --git a/man/DTRRef.Rd b/man/DTRRef.Rd index daea8c2390d609adb7055b306d56ad7b870d846a..ab44bb0329909505b4870080021ff92dba356c6b 100644 --- a/man/DTRRef.Rd +++ b/man/DTRRef.Rd @@ -16,33 +16,52 @@ DTRRef( ) } \arguments{ -\item{tmax}{A numeric multidimensional array containing daily maximum temperature.} +\item{tmax}{A numeric multidimensional array containing daily maximum +temperature.} -\item{tmin}{A numeric multidimensional array containing daily minimum temperature.} +\item{tmin}{A numeric multidimensional array containing daily minimum +temperature.} -\item{by.seasons}{If TRUE (by default), the DTR is computed for each season (December-January-February, March-April-May, June-July-August and September-October-November) seperately. If FALSE is specified, the montly mean DTR is computed.} +\item{by.seasons}{If TRUE (by default), the DTR is computed for each season +(December-January-February, March-April-May, June-July-August and +September-October-November) seperately. If FALSE is specified, the montly +mean DTR is computed.} -\item{dates}{A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'tmax' and 'tmin' are considered.} +\item{dates}{A vector of dates with a calendar attributes. If NULL (by +default), the 'time' attributes of parameter 'tmax' and 'tmin' are +considered.} -\item{timedim}{An integer number indicating the position of the time dimension in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the dimension called 'time' in parameter \code{tmax} and \code{tmin} is considered as time dimension.} +\item{timedim}{An integer number indicating the position of the time dimension +in the parameters \code{tmax} and \code{tmin}. If NULL (by default), the +dimension called 'time' in parameter \code{tmax} and \code{tmin} is +considered as time dimension.} \item{calendar}{A character indicating the calendar type.} -\item{na.rm}{A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored.} +\item{na.rm}{A logical indicating whether missing values should be removed. If +\code{na.rm} is FALSE an NA value in any of the arguments will cause a value +of NA to be returned, otherwise (TRUE by default) NA values are ignored.} \item{ncores}{The number of cores to be used when computing the index.} } \value{ A list of length 2: \itemize{ -\item\code{$dtr.ref} {An array with the same dimensions as the input \code{data}, but with the time dimension reduce from daily to monthly or seasonal resolution depending on the selected resolution in \code{by.season}.} -\item\code{$season} {A vector of the season or months corresponding to the resolution selected in \code{by.season}}} + \item{\code{$dtr.ref}, an array with the same dimensions as the input + \code{data}, but with the time dimension reduce from daily to monthly + or seasonal resolution depending on the selected resolution in + \code{by.season}.} +\item{\code{$season}, a vector of the season or months corresponding to the + resolution selected in \code{by.season}.} +} } \description{ -This function computes the mean diurnal temperature range (tmax - tmin). +This function computes the mean diurnal temperature range +(tmax - tmin). } \details{ -The function returns a reordered array with 'time' dimension in the first position in the \code{dtr.ref} label. +The function returns a reordered array with 'time' dimension in the + first position in the \code{dtr.ref} label. } \examples{ ##Exmaple with synthetic data: @@ -55,7 +74,8 @@ time <- seq.Date(as.Date("1900-01-01", format = "\%Y-\%d-\%m"), time <- as.POSIXct(time, tz = "CET") metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', - units = 'days since 1970-01-01 00:00:00', prec = 'double', + units = 'days since 1970-01-01 00:00:00', + prec = 'double', dim = list(list(name ='time', unlim = FALSE)))) attr(time, "variables") <- metadata attr(tmax, 'Variables')$dat1$time <- time @@ -73,6 +93,7 @@ dim(tmax) <- c(2, 3, 365) tmin <- (1:(2 * 3 * 365 * 1))-1 dim(tmin) <- c(2, 3, 365) -a <- DTRRef(tmax, tmin, by.seasons = FALSE, dates = time, timedim = 3, ncores = NULL) +a <- DTRRef(tmax, tmin, by.seasons = FALSE, dates = time, timedim = 3, + ncores = NULL) str(a) } diff --git a/man/DailyAno.Rd b/man/DailyAno.Rd index 3bf59f6cd8941a724a7723c8ae6f16d72394e904..d2729feac904a8ab22ddebaaadd62091ed79a5d9 100644 --- a/man/DailyAno.Rd +++ b/man/DailyAno.Rd @@ -9,19 +9,25 @@ DailyAno(data, jdays = NULL, dates = NULL, calendar = NULL, na.rm = TRUE) \arguments{ \item{data}{A vector of daily data.} -\item{jdays}{A vector of the corresponding day of the year. This vector must be the same length as parameter \code{data}.} +\item{jdays}{A vector of the corresponding day of the year. This vector must +be the same length as parameter \code{data}.} -\item{dates}{If \code{jdays} is not supplied, a vector of dates corresponding to the observations in \code{data} with defined calendar attributes.} +\item{dates}{If \code{jdays} is not supplied, a vector of dates corresponding +to the observations in \code{data} with defined calendar attributes.} \item{calendar}{A character indicating the calendar type.} -\item{na.rm}{A logical indicating whether missing values should be removed. If \code{na.rm} is FALSE an NA value in any of the arguments will cause a value of NA to be returned, otherwise (TRUE by default) NA values are ignored.} +\item{na.rm}{A logical indicating whether missing values should be removed. If +\code{na.rm} is FALSE an NA value in any of the arguments will cause a value +of NA to be returned, otherwise (TRUE by default) NA values are ignored.} } \value{ -A vector of daily anomalies of the same length as parameter \code{data}. +A vector of daily anomalies of the same length as parameter +\code{data}. } \description{ -This function computes daily anomalies from a vector containing the daily time series. +This function computes daily anomalies from a vector containing +the daily time series. } \examples{ # Time series in a vector example: diff --git a/man/Extremes.Rd b/man/Extremes.Rd index 34a4e7119f7152f9d38a14a1bb0054041d3d7277..e2d96ae43b6e71293d77e3c680b04d05cd768ca0 100644 --- a/man/Extremes.Rd +++ b/man/Extremes.Rd @@ -46,10 +46,10 @@ in the parameter \code{data}. If NULL (by default), the dimension called \value{ A list of length 2: \itemize{ - \item\code{$output1}{An array with the same dimensions as the original - \code{data}, except the time dimension which is reduced to annual resolution - given a timeseries of maximum spell lengths for each year.} - \item\code{$year}{A vector indicating the corresponding years.} + \item{\code{$output1}, an array with the same dimensions as the original + \code{data}, except the time dimension which is reduced to annual + resolution given a timeseries of maximum spell lengths for each year.} + \item{\code{$year}, a vector indicating the corresponding years.} } } \description{ @@ -74,11 +74,13 @@ dim(data) <- c(time = 310, lon = 2, lat = 3, model = 1) time <- as.POSIXct(paste(sort(rep(1902:1911, 31)), 1, 1:31, sep = "-"), tz = "CET") metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', - units = 'days since 1970-01-01 00:00:00', prec = 'double', + units = 'days since 1970-01-01 00:00:00', + prec = 'double', dim = list(list(name = 'time', unlim = FALSE)))) attr(time, "variables") <- metadata attr(data, 'Variables')$dat1$time <- time -threshold <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, ncores = NULL) +threshold <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, + ncores = NULL) res <- Extremes(data, threshold = threshold, op = ">", min.length = 6, spells.can.span.years = TRUE, max.missing.days = 5, ncores = NULL) diff --git a/man/Lon2Index.Rd b/man/Lon2Index.Rd index dbae6dcbc533716959433999b059eba7276c1799..0057319acf4af784465109063b0e801af7f39e29 100644 --- a/man/Lon2Index.Rd +++ b/man/Lon2Index.Rd @@ -9,15 +9,19 @@ Lon2Index(lon, lonmin, lonmax) \arguments{ \item{lon}{vector of longitudes values.} -\item{lonmin}{a numeric value indicating the minimum longitude of the region (understand as the left marging of the region).} +\item{lonmin}{a numeric value indicating the minimum longitude of the region +(understand as the left marging of the region).} -\item{lonmax}{a numeric value indicating the maximum longitude of the region (understand as the right mariging of the region).} +\item{lonmax}{a numeric value indicating the maximum longitude of the region +(understand as the right mariging of the region).} } \value{ -the index of positions of all values inside the region in the vector lon. +the index of positions of all values inside the region in the vector +lon. } \description{ -This auxiliary function returns the index of position of a region of longitudes in a given vector of longitudes. +This auxiliary function returns the index of position of a region +of longitudes in a given vector of longitudes. } \examples{ diff --git a/man/SeasonSelect.Rd b/man/SeasonSelect.Rd index 33066eed0e4ce2cd5b1a1abbe92930b43854975c..70b411b7e74c28a0af7e90e7f0a153f10d507cf8 100644 --- a/man/SeasonSelect.Rd +++ b/man/SeasonSelect.Rd @@ -9,22 +9,34 @@ SeasonSelect(data, season, dates = NULL, timedim = NULL, calendar = NULL) \arguments{ \item{data}{A numeric multidimensional array containing daily data.} -\item{season}{A charcater string indicating the season by the three months initials in capitals: 'DJF' for winter (summer), 'MAM' spring (autumn), 'JJA' for summer (winter) or 'SON' for autumn (spring) in the northern (southern) hemisphere.} +\item{season}{A charcater string indicating the season by the three months +initials in capitals: 'DJF' for winter (summer), 'MAM' spring (autumn), +'JJA' for summer (winter) or 'SON' for autumn (spring) in the northern +(southern) hemisphere.} -\item{dates}{A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' are considered.} +\item{dates}{A vector of dates with a calendar attributes. If NULL (by +default), the 'time' attributes of parameter 'data' are considered.} -\item{timedim}{An integer number indicating the position of the time dimension in the parameter \code{data}. If NULL (by default), the dimension called 'time' in parameter \code{data}.} +\item{timedim}{An integer number indicating the position of the time dimension +in the parameter \code{data}. If NULL (by default), the dimension called +'time' in parameter \code{data}.} \item{calendar}{A character indicating the calendar type.} } \value{ A list of length 2: \itemize{ -\item\code{$data} {A vector or array containing the daily values for the selected season, with the same dimensions as \code{data} input but the 'time' dimension reduce to the number of days corresponding to the selected season.} -\item\code{$dates} {A vector of dates reduce to the number of days corresponding to the selected season.}} + \item{\code{$data}, a vector or array containing the daily values for the + selected season, with the same dimensions as \code{data} input but the + 'time' dimension reduce to the number of days corresponding to the + selected season.} + \item{\code{$dates}, a vector of dates reduce to the number of days + corresponding to the selected season.} +} } \description{ -This function selects the daily data corresponding to the specified season. +This function selects the daily data corresponding to the +specified season. } \examples{ ## Example with synthetic data: @@ -34,7 +46,8 @@ time <- seq(ISOdate(1903,1,1), ISOdate(1904,12,31), "days") time <- as.POSIXct(time, tz = "CET") metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', - units = 'days since 1970-01-01 00:00:00', prec = 'double', + units = 'days since 1970-01-01 00:00:00', + prec = 'double', dim = list(list(name ='time', unlim = FALSE)))) attr(time, "variables") <- metadata attr(data, 'Variables')$dat1$time <- time diff --git a/man/SelBox.Rd b/man/SelBox.Rd index 1bc496beff0c876ff14323e80984321d290df3e0..13819e542adf016a32132940a5e60f735fefa75d 100644 --- a/man/SelBox.Rd +++ b/man/SelBox.Rd @@ -29,20 +29,21 @@ dimension. The default value is 'lat'.} \value{ A list of length 4: \itemize{ - \item\code{$data}{ - An array with the same dimensions as the input \code{data} array, but with - spatial dimension reduced to the selected \code{region}} - \item\code{$lat}{A vector with the new corresponding latitudes for the - selected \code{region}} - \item\code{$lon}{A vector with the new corresponding longitudes for the - selected \code{region}} - \item\code{$mask}{If parameter \code{mask} is supplied, an array with - reduced length of the dimensions to the selected \code{region}. Otherwise, - a NULL element is returned.}} + \item{\code{$data}, an array with the same dimensions as the input + \code{data} array, but with spatial dimension reduced to the selected + \code{region}.} + \item{\code{$lat}, a vector with the new corresponding latitudes for the + selected \code{region}.} + \item{\code{$lon}, a vector with the new corresponding longitudes for the + selected \code{region}.} + \item{\code{$mask}, if parameter \code{mask} is supplied, an array with + reduced length of the dimensions to the selected \code{region}. + Otherwise, a NULL element is returned.} +} } \description{ -Subset a spatial region from spatial data giving a vector with - the maximum and minimum of latitudes and longitudes of the selected region. +Subset a spatial region from spatial data giving a vector with +the maximum and minimum of latitudes and longitudes of the selected region. } \examples{ # Example with synthetic data: diff --git a/man/Threshold.Rd b/man/Threshold.Rd index e6ae99f6696ca434d49bd782226c75bb685062d3..0e661eb0b0880403d6cfc823ab0674ba34e38e8a 100644 --- a/man/Threshold.Rd +++ b/man/Threshold.Rd @@ -17,36 +17,44 @@ Threshold( \arguments{ \item{data}{A numeric n-dimensional array containing daily data.} -\item{dates}{A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' is considered.} +\item{dates}{A vector of dates with a calendar attributes. If NULL (by +default), the 'time' attributes of parameter 'data' is considered.} \item{calendar}{A character indicating the calendar type.} \item{base.range}{The years used for computing the threshold.} -\item{qtiles}{Numeric vector with values between 0 and 1 indicating the quantiles to be computed.} +\item{qtiles}{Numeric vector with values between 0 and 1 indicating the +quantiles to be computed.} \item{ncores}{The number of cores to be used when computing the threshold.} -\item{na.rm}{A logical value. If TRUE, any NA and NaN's are removed before the quantiles are computed (default as FALSE).} +\item{na.rm}{A logical value. If TRUE, any NA and NaN's are removed before the +quantiles are computed (default as FALSE).} } \value{ -An array with similar dimensions as the \code{data} input, but without 'time' dimension, and a new 'jdays' dimension. +An array with similar dimensions as the \code{data} input, but without +'time' dimension, and a new 'jdays' dimension. } \description{ -This function computes the threshold based on a quantile value for each day of the year of the daily data input. +This function computes the threshold based on a quantile value for each day of +the year of the daily data input. } \examples{ ##Example synthetic data: data <- 1:(2 * 3 * 372 * 1) dim(data) <- c(time = 372, lon = 2, lat = 3, model = 1) -time <- as.POSIXct(paste(sort(rep(1900:1911, 31)), 1, 1:31, sep = "-"), tz = "CET") -metadata <- list(time = list(standard_name = 'time', long_name = 'time', calendar = 'noleap', - units = 'days since 1970-01-01 00:00:00', prec = 'double', - dim = list(list(name = 'time', unlim = FALSE)))) +time <- as.POSIXct(paste(sort(rep(1900:1911, 31)), 1, 1:31, sep = "-"), + tz = "CET") +metadata <- list(time = list(standard_name = 'time', long_name = 'time', + calendar = 'noleap', + units = 'days since 1970-01-01 00:00:00', prec = 'double', + dim = list(list(name = 'time', unlim = FALSE)))) attr(time, "variables") <- metadata attr(data, 'Variables')$dat1$time <- time -a <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, ncores = NULL) +a <- Threshold(data, dates = NULL, base.range = NULL, qtiles = 0.9, + ncores = NULL) str(a) } diff --git a/man/WaveDuration.Rd b/man/WaveDuration.Rd index e639d550ed26c5eca3446473d8fa87510e9bcc2a..bca70b000fb53fe870e70b3169f26a40e5d51406 100644 --- a/man/WaveDuration.Rd +++ b/man/WaveDuration.Rd @@ -43,13 +43,15 @@ default), the 'time' attributes of parameter 'data' is used.} } \value{ A list of length 2: - \itemize{ - \item\code{$result}{An array with the same dimensions as the input - \code{data}, but with the time dimension reduce from daily to monthly or - seasonal resolution depending on the selected resolution in \code{by.season}.} - \item\code{$years}{A vector of the years and season/months corresponding to - the resolution selected in \code{by.season} and temporal length of the input - \code{data}}} +\itemize{ + \item{\code{$result}, an array with the same dimensions as the input + \code{data}, but with the time dimension reduce from daily to monthly + or seasonal resolution depending on the selected resolution in + \code{by.season}.} + \item{\code{$years}, a vector of the years and season/months corresponding + to the resolution selected in \code{by.season} and temporal length of + the input \code{data}.} +} } \description{ This function computes the duration of a heat/cold wave as the number of