From d6914a40c11d09168b9b4a191e9a0362b56a5f0c Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Wed, 20 Sep 2023 17:08:45 +0200 Subject: [PATCH 1/7] Substitute CST_Load by CST_Start in documentation --- R/CST_Analogs.R | 28 +++++++++----- R/CST_Anomaly.R | 3 +- R/CST_BiasCorrection.R | 28 +++++++------- R/CST_Calibration.R | 60 ++++++++++++++--------------- R/CST_MergeDims.R | 3 +- R/CST_SaveExp.R | 10 ++--- R/s2dv_cube.R | 4 +- man/BiasCorrection.Rd | 12 +++--- man/CST_BiasCorrection.Rd | 16 ++++---- man/CST_Calibration.Rd | 42 ++++++++++---------- man/CST_SaveExp.Rd | 6 +-- man/Calibration.Rd | 18 ++++----- man/SaveExp.Rd | 4 +- man/s2dv_cube.Rd | 4 +- tests/testthat/test-CST_Anomaly.R | 2 +- tests/testthat/test-CST_MergeDims.R | 3 +- 16 files changed, 125 insertions(+), 118 deletions(-) diff --git a/R/CST_Analogs.R b/R/CST_Analogs.R index b6cbfa4e..53706d17 100644 --- a/R/CST_Analogs.R +++ b/R/CST_Analogs.R @@ -237,11 +237,15 @@ CST_Analogs <- function(expL, obsL, expVar = NULL, obsVar = NULL, region = NULL, expL$coords[[lon_name]] <- SelBox(obsL$data, lon = as.vector(obsL$coords[[lon_name]]), lat = as.vector(obsL$coords[[lat_name]]), - region = region)$lon + region = region, + londim = lon_name, + latdim = lat_name)$lon expL$coords[[lat_name]] <- SelBox(obsL$data, lon = as.vector(obsL$coords[[lon_name]]), lat = as.vector(obsL$coords[[lat_name]]), - region = region)$lat + region = region, + londim = lon_name, + latdim = lat_name)$lat } } @@ -933,8 +937,10 @@ FindAnalog <- function(expL, obsL, time_obsL, expVar, obsVar, criteria, dim(Analogs_dates) <- dim(best) if (all(!is.null(region), !is.null(lonVar), !is.null(latVar))) { if (is.null(obsVar)) { - obsVar <- SelBox(obsL, lon = lonL, lat = latL, region = region)$data - expVar <- SelBox(expL, lon = lonL, lat = latL, region = region)$data + obsVar <- SelBox(obsL, lon = lonL, lat = latL, region = region, + londim = lon_name, latdim = lat_name)$data + expVar <- SelBox(expL, lon = lonL, lat = latL, region = region, + londim = lon_name, latdim = lat_name)$data Analogs_fields <- Subset(obsVar, along = which(names(dim(obsVar)) == 'time'), indices = best) @@ -943,7 +949,7 @@ FindAnalog <- function(expL, obsL, time_obsL, expVar, obsVar, criteria, } else { obslocal <- SelBox(obsVar, lon = lonVar, lat = latVar, - region = region)$data + region = region, londim = lon_name, latdim = lat_name)$data Analogs_fields <- Subset(obslocal, along = which(names(dim(obslocal)) == 'time'), indices = best) @@ -1102,8 +1108,10 @@ Select <- function(expL, obsL, expVar = NULL, obsVar = NULL, position = pos1)) } if (criteria == "Local_dist" | criteria == "Local_cor") { - obs <- SelBox(obsL, lon = lonL, lat = latL, region = region)$data - exp <- SelBox(expL, lon = lonL, lat = latL, region = region)$data + obs <- SelBox(obsL, lon = lonL, lat = latL, region = region, + londim = lon_name, latdim = lat_name)$data + exp <- SelBox(expL, lon = lonL, lat = latL, region = region, + londim = lon_name, latdim = lat_name)$data metric2 <- Apply(list(obs), target_dims = list(c(lat_name, lon_name)), fun = .select, exp, metric = "dist", lon_name = lon_name, lat_name = lat_name)$output1 @@ -1128,8 +1136,10 @@ Select <- function(expL, obsL, expVar = NULL, obsVar = NULL, } } if (criteria == "Local_cor") { - obs <- SelBox(obsVar, lon = lonVar, lat = latVar, region = region)$data - exp <- SelBox(expVar, lon = lonVar, lat = latVar, region = region)$data + obs <- SelBox(obsVar, lon = lonVar, lat = latVar, region = region, + londim = lon_name, latdim = lat_name)$data + exp <- SelBox(expVar, lon = lonVar, lat = latVar, region = region, + londim = lon_name, latdim = lat_name)$data metric3 <- Apply(list(obs), target_dims = list(c(lat_name, lon_name)), fun = .select, exp, metric = "cor", lon_name = lon_name, lat_name = lat_name)$output1 diff --git a/R/CST_Anomaly.R b/R/CST_Anomaly.R index c9326741..a8fa5c4a 100644 --- a/R/CST_Anomaly.R +++ b/R/CST_Anomaly.R @@ -69,8 +69,7 @@ CST_Anomaly <- function(exp = NULL, obs = NULL, dim_anom = 'sdate', # Check 's2dv_cube' if (!inherits(exp, 's2dv_cube') & !is.null(exp) || !inherits(obs, 's2dv_cube') & !is.null(obs)) { - stop("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'exp' and 'obs' must be of the class 's2dv_cube'.") } # exp and obs if (is.null(exp$data) & is.null(obs$data)) { diff --git a/R/CST_BiasCorrection.R b/R/CST_BiasCorrection.R index 772d23ef..375f274d 100644 --- a/R/CST_BiasCorrection.R +++ b/R/CST_BiasCorrection.R @@ -5,14 +5,14 @@ #'described in Torralba et al. (2017). The adjusted forecasts have an equivalent #'standard deviation and mean to that of the reference dataset. #' -#'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Load} +#'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Start} #' function, containing the seasonal forecast experiment data in the element -#' named \code{$data} with at least time and member dimensions. -#'@param obs An object of class \code{s2dv_cube} as returned by \code{CST_Load} +#' named \code{$data} with at least time and ensemble dimensions. +#'@param obs An object of class \code{s2dv_cube} as returned by \code{CST_Start} #' function, containing the observed data in the element named \code{$data} #' with at least time dimension. #'@param exp_cor An object of class \code{s2dv_cube} as returned by -#' \code{CST_Load} function, containing the seasonal forecast experiment to be +#' \code{CST_Start} function, containing the seasonal forecast experiment to be #' corrected with at least time dimension. If it is NULL, the 'exp' forecast #' will be corrected. If there is only one corrected dataset, it should not #' have dataset dimension. If there is a corresponding corrected dataset for @@ -20,8 +20,8 @@ #' 'exp'. The default value is NULL. #'@param na.rm A logical value indicating whether missing values should be #' stripped before the computation proceeds, by default it is set to FALSE. -#'@param memb_dim A character string indicating the name of the member -#' dimension. By default, it is set to 'member'. +#'@param memb_dim A character string indicating the name of the ensemble +#' dimension. By default, it is set to 'ensemble'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -44,9 +44,9 @@ #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, lat = 6, lon = 7) #'lon <- seq(0, 30, 5) #'lat <- seq(0, 25, 5) #'coords <- list(lat = lat, lon = lon) @@ -98,19 +98,19 @@ CST_BiasCorrection <- function(exp, obs, exp_cor = NULL, na.rm = FALSE, #'standard deviation and mean to that of the reference dataset. #' #'@param exp A multidimensional array with named dimensions containing the -#' seasonal forecast experiment data with at least time and member dimensions. +#' seasonal forecast experiment data with at least time and ensemble dimensions. #'@param obs A multidimensional array with named dimensions containing the #' observed data with at least time dimension. #'@param exp_cor A multidimensional array with named dimensions containing the -#' seasonal forecast experiment to be corrected with at least time and member +#' seasonal forecast experiment to be corrected with at least time and ensemble #' dimension. If it is NULL, the 'exp' forecast will be corrected. If there is #' only one corrected dataset, it should not have dataset dimension. If there #' is a corresponding corrected dataset for each 'exp' forecast, the dataset #' dimension must have the same length as in 'exp'. The default value is NULL. #'@param na.rm A logical value indicating whether missing values should be #' stripped before the computation proceeds, by default it is set to FALSE. -#'@param memb_dim A character string indicating the name of the member -#' dimension. By default, it is set to 'member'. +#'@param memb_dim A character string indicating the name of the ensemble +#' dimension. By default, it is set to 'ensemble'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -134,9 +134,9 @@ CST_BiasCorrection <- function(exp, obs, exp_cor = NULL, na.rm = FALSE, #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, lat = 6, lon = 7) #'a <- BiasCorrection(exp = mod1, obs = obs1) #'@import multiApply #'@export diff --git a/R/CST_Calibration.R b/R/CST_Calibration.R index d4b9170b..400fcffd 100644 --- a/R/CST_Calibration.R +++ b/R/CST_Calibration.R @@ -2,7 +2,7 @@ #' #'@author Verónica Torralba, \email{veronica.torralba@bsc.es} #'@author Bert Van Schaeybroeck, \email{bertvs@meteo.be} -#'@description Five types of member-by-member bias correction can be performed. +#'@description Five types of ensemble-by-ensemble bias correction can be performed. #'The \code{"bias"} method corrects the bias only, the \code{"evmos"} method #'applies a variance inflation technique to ensure the correction of the bias #'and the correspondence of variance between forecast and observation (Van @@ -18,16 +18,16 @@ #'(2014). It is equivalent to function \code{Calibration} but for objects #'of class \code{s2dv_cube}. #' -#'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Load} -#' function with at least 'sdate' and 'member' dimensions, containing the +#'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Start} +#' function with at least 'sdate' and 'ensemble' dimensions, containing the #' seasonal hindcast experiment data in the element named \code{data}. The #' hindcast is used to calibrate the forecast in case the forecast is provided; #' if not, the same hindcast will be calibrated instead. -#'@param obs An object of class \code{s2dv_cube} as returned by \code{CST_Load} +#'@param obs An object of class \code{s2dv_cube} as returned by \code{CST_Start} #' function with at least 'sdate' dimension, containing the observed data in #' the element named \code{$data}. #'@param exp_cor An optional object of class \code{s2dv_cube} as returned by -#' \code{CST_Load} function with at least 'sdate' and 'member' dimensions, +#' \code{CST_Start} function with at least 'sdate' and 'ensemble' dimensions, #' containing the seasonal forecast experiment data in the element named #' \code{data}. If the forecast is provided, it will be calibrated using the #' hindcast and observations; if not, the hindcast will be calibrated instead. @@ -64,8 +64,8 @@ #'@param alpha A numeric value indicating the significance level for the #' correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to #' == "sign"}. -#'@param memb_dim A character string indicating the name of the member dimension. -#' By default, it is set to 'member'. +#'@param memb_dim A character string indicating the name of the ensemble dimension. +#' By default, it is set to 'ensemble'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -102,21 +102,21 @@ #'through linear regression. Nonlinear Processes in Geophysics, 18(2), #'147. \doi{10.5194/npg-18-147-2011} #'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -#'post-processing using member-by-member approaches: theoretical aspects. +#'post-processing using ensemble-by-ensemble approaches: theoretical aspects. #'Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. #'\doi{10.1002/qj.2397} #' -#'@seealso \code{\link{CST_Load}} +#'@seealso \code{\link{CST_Start}} #' #'@examples #'# Example 1: #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) -#'lon <- seq(0, 30, 5) -#'lat <- seq(0, 25, 5) -#'coords <- list(lat = lat, lon = lon) +#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'longitude <- seq(0, 30, 5) +#'latitude <- seq(0, 25, 5) +#'coords <- list(latitude = latitude, longitude = longitude) #'exp <- list(data = mod1, coords = coords) #'obs <- list(data = obs1, coords = coords) #'attr(exp, 'class') <- 's2dv_cube' @@ -126,16 +126,16 @@ #'# Example 2: #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) #'mod2 <- 1 : (1 * 3 * 1 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) -#'dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, ftime = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, time = 5, latitude = 6, longitude = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) -#'lon <- seq(0, 30, 5) -#'lat <- seq(0, 25, 5) -#'coords <- list(lat = lat, lon = lon) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'longitude <- seq(0, 30, 5) +#'latitude <- seq(0, 25, 5) +#'coords <- list(latitude = latitude, longitude = longitude) #'exp <- list(data = mod1, coords = coords) #'obs <- list(data = obs1, coords = coords) -#'exp_cor <- list(data = mod2, lat = lat, lon = lon) +#'exp_cor <- list(data = mod2, latitude = latitude, longitude = longitude) #'attr(exp, 'class') <- 's2dv_cube' #'attr(obs, 'class') <- 's2dv_cube' #'attr(exp_cor, 'class') <- 's2dv_cube' @@ -187,7 +187,7 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #' #'@author Verónica Torralba, \email{veronica.torralba@bsc.es} #'@author Bert Van Schaeybroeck, \email{bertvs@meteo.be} -#'@description Five types of member-by-member bias correction can be performed. +#'@description Five types of ensemble-by-ensemble bias correction can be performed. #'The \code{"bias"} method corrects the bias only, the \code{"evmos"} method #'applies a variance inflation technique to ensure the correction of the bias #'and the correspondence of variance between forecast and observation (Van @@ -204,13 +204,13 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'validation) calibration are possible. #' #'@param exp A multidimensional array with named dimensions (at least 'sdate' -#' and 'member') containing the seasonal hindcast experiment data. The hindcast +#' and 'ensemble') containing the seasonal hindcast experiment data. The hindcast #' is used to calibrate the forecast in case the forecast is provided; if not, #' the same hindcast will be calibrated instead. #'@param obs A multidimensional array with named dimensions (at least 'sdate') #' containing the observed data. #'@param exp_cor An optional multidimensional array with named dimensions (at -#' least 'sdate' and 'member') containing the seasonal forecast experiment +#' least 'sdate' and 'ensemble') containing the seasonal forecast experiment #' data. If the forecast is provided, it will be calibrated using the hindcast #' and observations; if not, the hindcast will be calibrated instead. If there #' is only one corrected dataset, it should not have dataset dimension. If there @@ -245,8 +245,8 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'@param alpha A numeric value indicating the significance level for the #' correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == #' "sign"}. -#'@param memb_dim A character string indicating the name of the member -#' dimension. By default, it is set to 'member'. +#'@param memb_dim A character string indicating the name of the ensemble +#' dimension. By default, it is set to 'ensemble'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -283,17 +283,17 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'through linear regression. Nonlinear Processes in Geophysics, 18(2), #'147. \doi{10.5194/npg-18-147-2011} #'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -#'post-processing using member-by-member approaches: theoretical aspects. +#'post-processing using ensemble-by-ensemble approaches: theoretical aspects. #'Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. #'\doi{10.1002/qj.2397} #' -#'@seealso \code{\link{CST_Load}} +#'@seealso \code{\link{CST_Start}} #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) #'a <- Calibration(exp = mod1, obs = obs1) #' #'@importFrom s2dv InsertDim Reorder diff --git a/R/CST_MergeDims.R b/R/CST_MergeDims.R index a1ecbd15..4b66629e 100644 --- a/R/CST_MergeDims.R +++ b/R/CST_MergeDims.R @@ -33,8 +33,7 @@ CST_MergeDims <- function(data, merge_dims = c('ftime', 'monthly'), rename_dim = NULL, na.rm = FALSE) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { - stop("Parameter 'data' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'data' must be of the class 's2dv_cube'.") } data$data <- MergeDims(data$data, merge_dims = merge_dims, rename_dim = rename_dim, na.rm = na.rm) diff --git a/R/CST_SaveExp.R b/R/CST_SaveExp.R index 2c363e46..39be1604 100644 --- a/R/CST_SaveExp.R +++ b/R/CST_SaveExp.R @@ -5,7 +5,7 @@ #'@description This function allows to divide and save a object of class #''s2dv_cube' into a NetCDF file, allowing to reload the saved data using #'\code{Start} function from StartR package. If the original 's2dv_cube' object -#'has been created from \code{CST_Load()}, then it can be reloaded with +#'has been created from \code{CST_Start()}, then it can be reloaded with #'\code{Load()}. #' #'@param data An object of class \code{s2dv_cube}. @@ -71,8 +71,8 @@ #'\dontrun{ #'data <- lonlat_temp$exp #'destination <- "./" -#'CST_SaveExp(data = data, destination = destination, ftime_dim = 'ftime', -#' var_dim = NULL, ftime_dim = 'ftime', var_dim = NULL) +#'CST_SaveExp(data = data, destination = destination, ftime_dim = 'time', +#' var_dim = NULL, ftime_dim = 'time', var_dim = NULL) #'} #' #'@import ncdf4 @@ -175,7 +175,7 @@ CST_SaveExp <- function(data, destination = "./", sdate_dim = 'sdate', #'@description This function allows to save a data array with metadata into a #'NetCDF file, allowing to reload the saved data using \code{Start} function #'from StartR package. If the original 's2dv_cube' object has been created from -#'\code{CST_Load()}, then it can be reloaded with \code{Load()}. +#'\code{CST_Start()}, then it can be reloaded with \code{Start()}. #' #'@author Perez-Zanon Nuria, \email{nuria.perez@bsc.es} #' @@ -258,7 +258,7 @@ CST_SaveExp <- function(data, destination = "./", sdate_dim = 'sdate', #'metadata <- lonlat_temp$exp$attrs$Variable$metadata #'SaveExp(data = data, destination = destination, coords = coords, #' Datasets = Datasets, varname = varname, Dates = Dates, -#' metadata = metadata, single_file = TRUE, ftime_dim = 'ftime', +#' metadata = metadata, single_file = TRUE, ftime_dim = 'time', #' var_dim = NULL) #'} #' diff --git a/R/s2dv_cube.R b/R/s2dv_cube.R index f4e5be66..6832490f 100644 --- a/R/s2dv_cube.R +++ b/R/s2dv_cube.R @@ -11,7 +11,7 @@ #'@author Perez-Zanon Nuria, \email{nuria.perez@bsc.es} #' #'@param data A multidimensional array with named dimensions, typically with -#' dimensions: dataset, member, sdate, ftime, lat and lon. +#' dimensions: dataset, ensemble, sdate, time, lat and lon. #'@param coords A list of named vectors with the coordinates corresponding to #' the dimensions of the data parameter. If any coordinate has dimensions, they #' will be set as NULL. If any coordinate is not provided, it is set as an @@ -65,7 +65,7 @@ #' } #'} #' -#'@seealso \code{\link[s2dv]{Load}} and \code{\link{CST_Load}} +#'@seealso \code{\link[s2dv]{Load}} and \code{\link{CST_Start}} #'@examples #'exp_original <- 1:100 #'dim(exp_original) <- c(lat = 2, time = 10, lon = 5) diff --git a/man/BiasCorrection.Rd b/man/BiasCorrection.Rd index fa087478..a7fe938b 100644 --- a/man/BiasCorrection.Rd +++ b/man/BiasCorrection.Rd @@ -17,13 +17,13 @@ BiasCorrection( } \arguments{ \item{exp}{A multidimensional array with named dimensions containing the -seasonal forecast experiment data with at least time and member dimensions.} +seasonal forecast experiment data with at least time and ensemble dimensions.} \item{obs}{A multidimensional array with named dimensions containing the observed data with at least time dimension.} \item{exp_cor}{A multidimensional array with named dimensions containing the -seasonal forecast experiment to be corrected with at least time and member +seasonal forecast experiment to be corrected with at least time and ensemble dimension. If it is NULL, the 'exp' forecast will be corrected. If there is only one corrected dataset, it should not have dataset dimension. If there is a corresponding corrected dataset for each 'exp' forecast, the dataset @@ -32,8 +32,8 @@ dimension must have the same length as in 'exp'. The default value is NULL.} \item{na.rm}{A logical value indicating whether missing values should be stripped before the computation proceeds, by default it is set to FALSE.} -\item{memb_dim}{A character string indicating the name of the member -dimension. By default, it is set to 'member'.} +\item{memb_dim}{A character string indicating the name of the ensemble +dimension. By default, it is set to 'ensemble'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -60,9 +60,9 @@ standard deviation and mean to that of the reference dataset. } \examples{ mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, lat = 6, lon = 7) a <- BiasCorrection(exp = mod1, obs = obs1) } \references{ diff --git a/man/CST_BiasCorrection.Rd b/man/CST_BiasCorrection.Rd index 4de92577..dcc6926f 100644 --- a/man/CST_BiasCorrection.Rd +++ b/man/CST_BiasCorrection.Rd @@ -16,16 +16,16 @@ CST_BiasCorrection( ) } \arguments{ -\item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Load} +\item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} function, containing the seasonal forecast experiment data in the element -named \code{$data} with at least time and member dimensions.} +named \code{$data} with at least time and ensemble dimensions.} -\item{obs}{An object of class \code{s2dv_cube} as returned by \code{CST_Load} +\item{obs}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} function, containing the observed data in the element named \code{$data} with at least time dimension.} \item{exp_cor}{An object of class \code{s2dv_cube} as returned by -\code{CST_Load} function, containing the seasonal forecast experiment to be +\code{CST_Start} function, containing the seasonal forecast experiment to be corrected with at least time dimension. If it is NULL, the 'exp' forecast will be corrected. If there is only one corrected dataset, it should not have dataset dimension. If there is a corresponding corrected dataset for @@ -35,8 +35,8 @@ each 'exp' forecast, the dataset dimension must have the same length as in \item{na.rm}{A logical value indicating whether missing values should be stripped before the computation proceeds, by default it is set to FALSE.} -\item{memb_dim}{A character string indicating the name of the member -dimension. By default, it is set to 'member'.} +\item{memb_dim}{A character string indicating the name of the ensemble +dimension. By default, it is set to 'ensemble'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -63,9 +63,9 @@ standard deviation and mean to that of the reference dataset. } \examples{ mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, lat = 6, lon = 7) lon <- seq(0, 30, 5) lat <- seq(0, 25, 5) coords <- list(lat = lat, lon = lon) diff --git a/man/CST_Calibration.Rd b/man/CST_Calibration.Rd index c8d1320f..4cd0cacb 100644 --- a/man/CST_Calibration.Rd +++ b/man/CST_Calibration.Rd @@ -22,18 +22,18 @@ CST_Calibration( ) } \arguments{ -\item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Load} -function with at least 'sdate' and 'member' dimensions, containing the +\item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} +function with at least 'sdate' and 'ensemble' dimensions, containing the seasonal hindcast experiment data in the element named \code{data}. The hindcast is used to calibrate the forecast in case the forecast is provided; if not, the same hindcast will be calibrated instead.} -\item{obs}{An object of class \code{s2dv_cube} as returned by \code{CST_Load} +\item{obs}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} function with at least 'sdate' dimension, containing the observed data in the element named \code{$data}.} \item{exp_cor}{An optional object of class \code{s2dv_cube} as returned by -\code{CST_Load} function with at least 'sdate' and 'member' dimensions, +\code{CST_Start} function with at least 'sdate' and 'ensemble' dimensions, containing the seasonal forecast experiment data in the element named \code{data}. If the forecast is provided, it will be calibrated using the hindcast and observations; if not, the hindcast will be calibrated instead. @@ -78,8 +78,8 @@ significant (\code{"sign"}). Only useful if \code{cal.method == "rpc-based"}.} correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == "sign"}.} -\item{memb_dim}{A character string indicating the name of the member dimension. -By default, it is set to 'member'.} +\item{memb_dim}{A character string indicating the name of the ensemble dimension. +By default, it is set to 'ensemble'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -100,7 +100,7 @@ dimensions as in the 'exp' object. nexp is the number of experiment is provided the returned array will be with the same dimensions as 'exp_cor'. } \description{ -Five types of member-by-member bias correction can be performed. +Five types of ensemble-by-ensemble bias correction can be performed. The \code{"bias"} method corrects the bias only, the \code{"evmos"} method applies a variance inflation technique to ensure the correction of the bias and the correspondence of variance between forecast and observation (Van @@ -130,12 +130,12 @@ the computation of the parameters needed to perform the calibration. \examples{ # Example 1: mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) -lon <- seq(0, 30, 5) -lat <- seq(0, 25, 5) -coords <- list(lat = lat, lon = lon) +dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +longitude <- seq(0, 30, 5) +latitude <- seq(0, 25, 5) +coords <- list(latitude = latitude, longitude = longitude) exp <- list(data = mod1, coords = coords) obs <- list(data = obs1, coords = coords) attr(exp, 'class') <- 's2dv_cube' @@ -145,16 +145,16 @@ a <- CST_Calibration(exp = exp, obs = obs, cal.method = "mse_min", eval.method = # Example 2: mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) mod2 <- 1 : (1 * 3 * 1 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) -dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, ftime = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, time = 5, latitude = 6, longitude = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) -lon <- seq(0, 30, 5) -lat <- seq(0, 25, 5) -coords <- list(lat = lat, lon = lon) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +longitude <- seq(0, 30, 5) +latitude <- seq(0, 25, 5) +coords <- list(latitude = latitude, longitude = longitude) exp <- list(data = mod1, coords = coords) obs <- list(data = obs1, coords = coords) -exp_cor <- list(data = mod2, lat = lat, lon = lon) +exp_cor <- list(data = mod2, latitude = latitude, longitude = longitude) attr(exp, 'class') <- 's2dv_cube' attr(obs, 'class') <- 's2dv_cube' attr(exp_cor, 'class') <- 's2dv_cube' @@ -176,12 +176,12 @@ through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. \doi{10.5194/npg-18-147-2011} Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -post-processing using member-by-member approaches: theoretical aspects. +post-processing using ensemble-by-ensemble approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. \doi{10.1002/qj.2397} } \seealso{ -\code{\link{CST_Load}} +\code{\link{CST_Start}} } \author{ Verónica Torralba, \email{veronica.torralba@bsc.es} diff --git a/man/CST_SaveExp.Rd b/man/CST_SaveExp.Rd index f8918eb9..70c6691e 100644 --- a/man/CST_SaveExp.Rd +++ b/man/CST_SaveExp.Rd @@ -88,15 +88,15 @@ Multiple or single NetCDF files containing the data array.\cr This function allows to divide and save a object of class 's2dv_cube' into a NetCDF file, allowing to reload the saved data using \code{Start} function from StartR package. If the original 's2dv_cube' object -has been created from \code{CST_Load()}, then it can be reloaded with +has been created from \code{CST_Start()}, then it can be reloaded with \code{Load()}. } \examples{ \dontrun{ data <- lonlat_temp$exp destination <- "./" -CST_SaveExp(data = data, destination = destination, ftime_dim = 'ftime', - var_dim = NULL, ftime_dim = 'ftime', var_dim = NULL) +CST_SaveExp(data = data, destination = destination, ftime_dim = 'time', + var_dim = NULL, ftime_dim = 'time', var_dim = NULL) } } diff --git a/man/Calibration.Rd b/man/Calibration.Rd index b907326a..bbebfd5c 100644 --- a/man/Calibration.Rd +++ b/man/Calibration.Rd @@ -23,7 +23,7 @@ Calibration( } \arguments{ \item{exp}{A multidimensional array with named dimensions (at least 'sdate' -and 'member') containing the seasonal hindcast experiment data. The hindcast +and 'ensemble') containing the seasonal hindcast experiment data. The hindcast is used to calibrate the forecast in case the forecast is provided; if not, the same hindcast will be calibrated instead.} @@ -31,7 +31,7 @@ the same hindcast will be calibrated instead.} containing the observed data.} \item{exp_cor}{An optional multidimensional array with named dimensions (at -least 'sdate' and 'member') containing the seasonal forecast experiment +least 'sdate' and 'ensemble') containing the seasonal forecast experiment data. If the forecast is provided, it will be calibrated using the hindcast and observations; if not, the hindcast will be calibrated instead. If there is only one corrected dataset, it should not have dataset dimension. If there @@ -74,8 +74,8 @@ significant (\code{"sign"}). Only useful if \code{cal.method == "rpc-based"}.} correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == "sign"}.} -\item{memb_dim}{A character string indicating the name of the member -dimension. By default, it is set to 'member'.} +\item{memb_dim}{A character string indicating the name of the ensemble +dimension. By default, it is set to 'ensemble'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -96,7 +96,7 @@ If 'exp_cor' is provided the returned array will be with the same dimensions as 'exp_cor'. } \description{ -Five types of member-by-member bias correction can be performed. +Five types of ensemble-by-ensemble bias correction can be performed. The \code{"bias"} method corrects the bias only, the \code{"evmos"} method applies a variance inflation technique to ensure the correction of the bias and the correspondence of variance between forecast and observation (Van @@ -125,9 +125,9 @@ the computation of the parameters needed to perform the calibration. } \examples{ mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) a <- Calibration(exp = mod1, obs = obs1) } @@ -146,12 +146,12 @@ through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. \doi{10.5194/npg-18-147-2011} Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -post-processing using member-by-member approaches: theoretical aspects. +post-processing using ensemble-by-ensemble approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. \doi{10.1002/qj.2397} } \seealso{ -\code{\link{CST_Load}} +\code{\link{CST_Start}} } \author{ Verónica Torralba, \email{veronica.torralba@bsc.es} diff --git a/man/SaveExp.Rd b/man/SaveExp.Rd index a9c0ac36..135d7e9c 100644 --- a/man/SaveExp.Rd +++ b/man/SaveExp.Rd @@ -108,7 +108,7 @@ Multiple or single NetCDF files containing the data array.\cr This function allows to save a data array with metadata into a NetCDF file, allowing to reload the saved data using \code{Start} function from StartR package. If the original 's2dv_cube' object has been created from -\code{CST_Load()}, then it can be reloaded with \code{Load()}. +\code{CST_Start()}, then it can be reloaded with \code{Start()}. } \examples{ \dontrun{ @@ -123,7 +123,7 @@ destination = './' metadata <- lonlat_temp$exp$attrs$Variable$metadata SaveExp(data = data, destination = destination, coords = coords, Datasets = Datasets, varname = varname, Dates = Dates, - metadata = metadata, single_file = TRUE, ftime_dim = 'ftime', + metadata = metadata, single_file = TRUE, ftime_dim = 'time', var_dim = NULL) } diff --git a/man/s2dv_cube.Rd b/man/s2dv_cube.Rd index e17a4607..b2fb54de 100644 --- a/man/s2dv_cube.Rd +++ b/man/s2dv_cube.Rd @@ -18,7 +18,7 @@ s2dv_cube( } \arguments{ \item{data}{A multidimensional array with named dimensions, typically with -dimensions: dataset, member, sdate, ftime, lat and lon.} +dimensions: dataset, ensemble, sdate, time, lat and lon.} \item{coords}{A list of named vectors with the coordinates corresponding to the dimensions of the data parameter. If any coordinate has dimensions, they @@ -134,7 +134,7 @@ exp8 <- s2dv_cube(data = exp_original, coords = coords, class(exp8) } \seealso{ -\code{\link[s2dv]{Load}} and \code{\link{CST_Load}} +\code{\link[s2dv]{Load}} and \code{\link{CST_Start}} } \author{ Perez-Zanon Nuria, \email{nuria.perez@bsc.es} diff --git a/tests/testthat/test-CST_Anomaly.R b/tests/testthat/test-CST_Anomaly.R index 772352aa..4715255f 100644 --- a/tests/testthat/test-CST_Anomaly.R +++ b/tests/testthat/test-CST_Anomaly.R @@ -49,7 +49,7 @@ test_that("1. Input checks", { # s2dv_cube expect_error( CST_Anomaly(exp = 1, obs = 1), - "Parameter 'exp' and 'obs' must be of the class 's2dv_cube', as output by CSTools::CST_Load." + "Parameter 'exp' and 'obs' must be of the class 's2dv_cube'." ) # exp and obs expect_error( diff --git a/tests/testthat/test-CST_MergeDims.R b/tests/testthat/test-CST_MergeDims.R index 0717a306..f7eac6ac 100644 --- a/tests/testthat/test-CST_MergeDims.R +++ b/tests/testthat/test-CST_MergeDims.R @@ -3,8 +3,7 @@ test_that("Sanity checks", { expect_error( CST_MergeDims(data = 1), - paste0("Parameter 'data' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.")) + paste0("Parameter 'data' must be of the class 's2dv_cube'.")) data <- list(data = 1:10) class(data) <- 's2dv_cube' expect_error( -- GitLab From c8e50b6cdcbbeb64c75e74990f2803023297f135 Mon Sep 17 00:00:00 2001 From: EVA RIFA ROVIRA Date: Mon, 9 Oct 2023 10:27:45 +0200 Subject: [PATCH 2/7] Substitute CST_Load by CST_Start --- DESCRIPTION | 2 +- R/CST_Analogs.R | 16 ++++++---------- R/CST_BiasCorrection.R | 18 +++++++++--------- R/CST_Calibration.R | 26 +++++++++++++------------- R/CST_QuantileMapping.R | 6 ++---- R/CST_SplitDim.R | 3 +-- R/CST_WeatherRegimes.R | 3 +-- R/as.s2dv_cube.R | 2 +- R/s2dv_cube.R | 4 ++-- 9 files changed, 36 insertions(+), 44 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0085fa4f..d0d8c7c2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -90,5 +90,5 @@ VignetteBuilder: knitr License: GPL-3 Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.3 Config/testthat/edition: 3 diff --git a/R/CST_Analogs.R b/R/CST_Analogs.R index 402ee316..42521085 100644 --- a/R/CST_Analogs.R +++ b/R/CST_Analogs.R @@ -24,7 +24,7 @@ #'This function has not constrains of specific regions, variables to downscale, #'or data to be used (seasonal forecast data, climate projections data, #'reanalyses data). The regrid into a finner scale is done interpolating with -#'CST_Load. Then, this interpolation is corrected selecting the analogs in the +#'CST_Start. Then, this interpolation is corrected selecting the analogs in the #'large and local scale in based of the observations. The function is an #'adapted version of the method of Yiou et al 2013. For an advanced search of #'Analogs (multiple Analogs, different criterias, further information from the @@ -104,8 +104,7 @@ #' best analog, for instance for downscaling. #'@param ncores The number of cores to use in parallel computation #' -#'@seealso \code{\link{CST_Load}}, \code{\link[s2dv]{Load}} and -#'\code{\link[s2dv]{CDORemap}} +#'@seealso \code{\link{CST_Start}}, \code{\link[startR]{Start}} #' #'@return An 's2dv_cube' object containing an array with the dowscaled values of #'the best analogs in element 'data'. If 'AnalogsInfo' is TRUE, 'data' is a list @@ -147,16 +146,13 @@ CST_Analogs <- function(expL, obsL, expVar = NULL, obsVar = NULL, # Check 's2dv_cube' if (!inherits(expL, "s2dv_cube") || !inherits(obsL, "s2dv_cube")) { - stop("Parameter 'expL' and 'obsL' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'expL' and 'obsL' must be of the class 's2dv_cube'.") } if (!is.null(expVar) && !inherits(expVar, "s2dv_cube")) { - stop("Parameter 'expVar' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'expVar' must be of the class 's2dv_cube'.") } if (!is.null(obsVar) && !inherits(obsVar, "s2dv_cube")) { - stop("Parameter 'obsVar' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'obsVar' must be of the class 's2dv_cube'.") } # Check 'obsL' object structure @@ -293,7 +289,7 @@ CST_Analogs <- function(expL, obsL, expVar = NULL, obsVar = NULL, #'ones. This function has not constrains of specific regions, variables to #'downscale, or data to be used (seasonal forecast data, climate projections #'data, reanalyses data). The regrid into a finner scale is done interpolating -#'with CST_Load. Then, this interpolation is corrected selecting the analogs in +#'with CST_Start. Then, this interpolation is corrected selecting the analogs in #'the large and local scale in based of the observations. The function is an #'adapted version of the method of Yiou et al 2013. #' diff --git a/R/CST_BiasCorrection.R b/R/CST_BiasCorrection.R index 375f274d..06f2c519 100644 --- a/R/CST_BiasCorrection.R +++ b/R/CST_BiasCorrection.R @@ -7,7 +7,7 @@ #' #'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Start} #' function, containing the seasonal forecast experiment data in the element -#' named \code{$data} with at least time and ensemble dimensions. +#' named \code{$data} with at least time and member dimensions. #'@param obs An object of class \code{s2dv_cube} as returned by \code{CST_Start} #' function, containing the observed data in the element named \code{$data} #' with at least time dimension. @@ -20,8 +20,8 @@ #' 'exp'. The default value is NULL. #'@param na.rm A logical value indicating whether missing values should be #' stripped before the computation proceeds, by default it is set to FALSE. -#'@param memb_dim A character string indicating the name of the ensemble -#' dimension. By default, it is set to 'ensemble'. +#'@param memb_dim A character string indicating the name of the member +#' dimension. By default, it is set to 'member'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -98,19 +98,19 @@ CST_BiasCorrection <- function(exp, obs, exp_cor = NULL, na.rm = FALSE, #'standard deviation and mean to that of the reference dataset. #' #'@param exp A multidimensional array with named dimensions containing the -#' seasonal forecast experiment data with at least time and ensemble dimensions. +#' seasonal forecast experiment data with at least time and member dimensions. #'@param obs A multidimensional array with named dimensions containing the #' observed data with at least time dimension. #'@param exp_cor A multidimensional array with named dimensions containing the -#' seasonal forecast experiment to be corrected with at least time and ensemble +#' seasonal forecast experiment to be corrected with at least time and member #' dimension. If it is NULL, the 'exp' forecast will be corrected. If there is #' only one corrected dataset, it should not have dataset dimension. If there #' is a corresponding corrected dataset for each 'exp' forecast, the dataset #' dimension must have the same length as in 'exp'. The default value is NULL. #'@param na.rm A logical value indicating whether missing values should be #' stripped before the computation proceeds, by default it is set to FALSE. -#'@param memb_dim A character string indicating the name of the ensemble -#' dimension. By default, it is set to 'ensemble'. +#'@param memb_dim A character string indicating the name of the member +#' dimension. By default, it is set to 'member'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -134,9 +134,9 @@ CST_BiasCorrection <- function(exp, obs, exp_cor = NULL, na.rm = FALSE, #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, lat = 6, lon = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, lat = 6, lon = 7) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, lat = 6, lon = 7) #'a <- BiasCorrection(exp = mod1, obs = obs1) #'@import multiApply #'@export diff --git a/R/CST_Calibration.R b/R/CST_Calibration.R index 400fcffd..25fc18a1 100644 --- a/R/CST_Calibration.R +++ b/R/CST_Calibration.R @@ -2,7 +2,7 @@ #' #'@author Verónica Torralba, \email{veronica.torralba@bsc.es} #'@author Bert Van Schaeybroeck, \email{bertvs@meteo.be} -#'@description Five types of ensemble-by-ensemble bias correction can be performed. +#'@description Five types of member-by-member bias correction can be performed. #'The \code{"bias"} method corrects the bias only, the \code{"evmos"} method #'applies a variance inflation technique to ensure the correction of the bias #'and the correspondence of variance between forecast and observation (Van @@ -19,7 +19,7 @@ #'of class \code{s2dv_cube}. #' #'@param exp An object of class \code{s2dv_cube} as returned by \code{CST_Start} -#' function with at least 'sdate' and 'ensemble' dimensions, containing the +#' function with at least 'sdate' and 'member' dimensions, containing the #' seasonal hindcast experiment data in the element named \code{data}. The #' hindcast is used to calibrate the forecast in case the forecast is provided; #' if not, the same hindcast will be calibrated instead. @@ -27,7 +27,7 @@ #' function with at least 'sdate' dimension, containing the observed data in #' the element named \code{$data}. #'@param exp_cor An optional object of class \code{s2dv_cube} as returned by -#' \code{CST_Start} function with at least 'sdate' and 'ensemble' dimensions, +#' \code{CST_Start} function with at least 'sdate' and 'member' dimensions, #' containing the seasonal forecast experiment data in the element named #' \code{data}. If the forecast is provided, it will be calibrated using the #' hindcast and observations; if not, the hindcast will be calibrated instead. @@ -64,8 +64,8 @@ #'@param alpha A numeric value indicating the significance level for the #' correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to #' == "sign"}. -#'@param memb_dim A character string indicating the name of the ensemble dimension. -#' By default, it is set to 'ensemble'. +#'@param memb_dim A character string indicating the name of the member dimension. +#' By default, it is set to 'member'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -102,7 +102,7 @@ #'through linear regression. Nonlinear Processes in Geophysics, 18(2), #'147. \doi{10.5194/npg-18-147-2011} #'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -#'post-processing using ensemble-by-ensemble approaches: theoretical aspects. +#'post-processing using member-by-member approaches: theoretical aspects. #'Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. #'\doi{10.1002/qj.2397} #' @@ -111,9 +111,9 @@ #'@examples #'# Example 1: #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) #'longitude <- seq(0, 30, 5) #'latitude <- seq(0, 25, 5) #'coords <- list(latitude = latitude, longitude = longitude) @@ -187,7 +187,7 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #' #'@author Verónica Torralba, \email{veronica.torralba@bsc.es} #'@author Bert Van Schaeybroeck, \email{bertvs@meteo.be} -#'@description Five types of ensemble-by-ensemble bias correction can be performed. +#'@description Five types of member-by-member bias correction can be performed. #'The \code{"bias"} method corrects the bias only, the \code{"evmos"} method #'applies a variance inflation technique to ensure the correction of the bias #'and the correspondence of variance between forecast and observation (Van @@ -245,8 +245,8 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'@param alpha A numeric value indicating the significance level for the #' correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == #' "sign"}. -#'@param memb_dim A character string indicating the name of the ensemble -#' dimension. By default, it is set to 'ensemble'. +#'@param memb_dim A character string indicating the name of the member +#' dimension. By default, it is set to 'member'. #'@param sdate_dim A character string indicating the name of the start date #' dimension. By default, it is set to 'sdate'. #'@param dat_dim A character string indicating the name of dataset dimension. @@ -291,9 +291,9 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) #'a <- Calibration(exp = mod1, obs = obs1) #' #'@importFrom s2dv InsertDim Reorder diff --git a/R/CST_QuantileMapping.R b/R/CST_QuantileMapping.R index 92b7ac03..cbb76c99 100644 --- a/R/CST_QuantileMapping.R +++ b/R/CST_QuantileMapping.R @@ -58,13 +58,11 @@ CST_QuantileMapping <- function(exp, obs, exp_cor = NULL, sdate_dim = 'sdate', ncores = NULL, ...) { # Check 's2dv_cube' if (!inherits(exp, 's2dv_cube') || !inherits(obs, 's2dv_cube')) { - stop("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'exp' and 'obs' must be of the class 's2dv_cube'.") } if (!is.null(exp_cor)) { if (!inherits(exp_cor, 's2dv_cube')) { - stop("Parameter 'exp_cor' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'exp_cor' must be of the class 's2dv_cube'.") } } diff --git a/R/CST_SplitDim.R b/R/CST_SplitDim.R index 25d610da..71f51bab 100644 --- a/R/CST_SplitDim.R +++ b/R/CST_SplitDim.R @@ -57,8 +57,7 @@ CST_SplitDim <- function(data, split_dim = 'time', indices = NULL, insert_ftime = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { - stop("Parameter 'data' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'data' must be of the class 's2dv_cube'.") } if (!is.null(insert_ftime)) { if (!is.numeric(insert_ftime)) { diff --git a/R/CST_WeatherRegimes.R b/R/CST_WeatherRegimes.R index 56783aeb..355a1d8b 100644 --- a/R/CST_WeatherRegimes.R +++ b/R/CST_WeatherRegimes.R @@ -72,8 +72,7 @@ CST_WeatherRegimes <- function(data, ncenters = NULL, ncores = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { - stop("Parameter 'data' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'data' must be of the class 's2dv_cube'.") } # Check 'exp' object structure if (!all(c('data', 'coords') %in% names(data))) { diff --git a/R/as.s2dv_cube.R b/R/as.s2dv_cube.R index 75d6a6da..f81766ec 100644 --- a/R/as.s2dv_cube.R +++ b/R/as.s2dv_cube.R @@ -51,7 +51,7 @@ #' } #'} #' -#'@seealso \code{\link{s2dv_cube}}, \code{\link[s2dv]{Load}}, +#'@seealso \code{\link{s2dv_cube}}, \code{\link{CST_Start}}, #'\code{\link[startR]{Start}} and \code{\link{CST_Load}} #'@examples #'\dontrun{ diff --git a/R/s2dv_cube.R b/R/s2dv_cube.R index 6832490f..6bf86a8c 100644 --- a/R/s2dv_cube.R +++ b/R/s2dv_cube.R @@ -2,7 +2,7 @@ #' #'@description This function allows to create an 's2dv_cube' object by passing #'information through its parameters. This function will be needed if the data -#'hasn't been loaded using CST_Load or has been transformed with other methods. +#'hasn't been loaded using CST_Start or has been transformed with other methods. #'An 's2dv_cube' object has many different components including metadata. This #'function will allow to create 's2dv_cube' objects even if not all elements #'are defined and for each expected missed parameter a warning message will be @@ -11,7 +11,7 @@ #'@author Perez-Zanon Nuria, \email{nuria.perez@bsc.es} #' #'@param data A multidimensional array with named dimensions, typically with -#' dimensions: dataset, ensemble, sdate, time, lat and lon. +#' dimensions: dataset, member, sdate, time, lat and lon. #'@param coords A list of named vectors with the coordinates corresponding to #' the dimensions of the data parameter. If any coordinate has dimensions, they #' will be set as NULL. If any coordinate is not provided, it is set as an -- GitLab From 8ebe4d9c3a00aa034dc7745f82222f8e85ce2724 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 10 Oct 2023 12:28:48 +0200 Subject: [PATCH 3/7] Few changes in CST_Calibration documentation regarding CST_Load --- R/CST_Anomaly.R | 2 +- R/CST_Calibration.R | 34 +++++++++++++++++----------------- R/CST_SaveExp.R | 3 +-- man/Analogs.Rd | 2 +- man/BiasCorrection.Rd | 12 ++++++------ man/CST_Analogs.Rd | 5 ++--- man/CST_Anomaly.Rd | 2 +- man/CST_BiasCorrection.Rd | 6 +++--- man/CST_Calibration.Rd | 36 ++++++++++++++++++------------------ man/Calibration.Rd | 16 ++++++++-------- man/as.s2dv_cube.Rd | 2 +- man/s2dv_cube.Rd | 4 ++-- 12 files changed, 61 insertions(+), 63 deletions(-) diff --git a/R/CST_Anomaly.R b/R/CST_Anomaly.R index eb519d29..654bb079 100644 --- a/R/CST_Anomaly.R +++ b/R/CST_Anomaly.R @@ -57,7 +57,7 @@ #'anom <- CST_Anomaly(exp = exp, obs = obs, cross = FALSE, memb = TRUE) #' #'@seealso \code{\link[s2dv]{Ano_CrossValid}}, \code{\link[s2dv]{Clim}} and -#'\code{\link{CST_Load}} +#'\code{\link{CST_Start}} #' #'@import multiApply #'@importFrom s2dv InsertDim Clim Ano_CrossValid Reorder diff --git a/R/CST_Calibration.R b/R/CST_Calibration.R index 25fc18a1..3ba22917 100644 --- a/R/CST_Calibration.R +++ b/R/CST_Calibration.R @@ -111,12 +111,12 @@ #'@examples #'# Example 1: #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) -#'longitude <- seq(0, 30, 5) -#'latitude <- seq(0, 25, 5) -#'coords <- list(latitude = latitude, longitude = longitude) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'lon <- seq(0, 30, 5) +#'lat <- seq(0, 25, 5) +#'coords <- list(lat = lat, lon = lon) #'exp <- list(data = mod1, coords = coords) #'obs <- list(data = obs1, coords = coords) #'attr(exp, 'class') <- 's2dv_cube' @@ -126,16 +126,16 @@ #'# Example 2: #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) #'mod2 <- 1 : (1 * 3 * 1 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) -#'dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, time = 5, latitude = 6, longitude = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, ftime = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) -#'longitude <- seq(0, 30, 5) -#'latitude <- seq(0, 25, 5) -#'coords <- list(latitude = latitude, longitude = longitude) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +#'lon <- seq(0, 30, 5) +#'lat <- seq(0, 25, 5) +#'coords <- list(lat = lat, lon = lon) #'exp <- list(data = mod1, coords = coords) #'obs <- list(data = obs1, coords = coords) -#'exp_cor <- list(data = mod2, latitude = latitude, longitude = longitude) +#'exp_cor <- list(data = mod2, lat = lat, lon = lon) #'attr(exp, 'class') <- 's2dv_cube' #'attr(obs, 'class') <- 's2dv_cube' #'attr(exp_cor, 'class') <- 's2dv_cube' @@ -204,13 +204,13 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'validation) calibration are possible. #' #'@param exp A multidimensional array with named dimensions (at least 'sdate' -#' and 'ensemble') containing the seasonal hindcast experiment data. The hindcast +#' and 'member') containing the seasonal hindcast experiment data. The hindcast #' is used to calibrate the forecast in case the forecast is provided; if not, #' the same hindcast will be calibrated instead. #'@param obs A multidimensional array with named dimensions (at least 'sdate') #' containing the observed data. #'@param exp_cor An optional multidimensional array with named dimensions (at -#' least 'sdate' and 'ensemble') containing the seasonal forecast experiment +#' least 'sdate' and 'member') containing the seasonal forecast experiment #' data. If the forecast is provided, it will be calibrated using the hindcast #' and observations; if not, the hindcast will be calibrated instead. If there #' is only one corrected dataset, it should not have dataset dimension. If there @@ -283,7 +283,7 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #'through linear regression. Nonlinear Processes in Geophysics, 18(2), #'147. \doi{10.5194/npg-18-147-2011} #'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -#'post-processing using ensemble-by-ensemble approaches: theoretical aspects. +#'post-processing using member-by-member approaches: theoretical aspects. #'Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. #'\doi{10.1002/qj.2397} #' @@ -291,9 +291,9 @@ CST_Calibration <- function(exp, obs, exp_cor = NULL, cal.method = "mse_min", #' #'@examples #'mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) #'obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +#'dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) #'a <- Calibration(exp = mod1, obs = obs1) #' #'@importFrom s2dv InsertDim Reorder diff --git a/R/CST_SaveExp.R b/R/CST_SaveExp.R index 4fddf03d..31608e89 100644 --- a/R/CST_SaveExp.R +++ b/R/CST_SaveExp.R @@ -90,8 +90,7 @@ CST_SaveExp <- function(data, destination = "./", sdate_dim = 'sdate', single_file = FALSE, extra_string = NULL) { # Check 's2dv_cube' if (!inherits(data, 's2dv_cube')) { - stop("Parameter 'data' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + stop("Parameter 'data' must be of the class 's2dv_cube'.") } # Check object structure if (!all(c('data', 'attrs') %in% names(data))) { diff --git a/man/Analogs.Rd b/man/Analogs.Rd index f5a89ae6..5b58ee00 100644 --- a/man/Analogs.Rd +++ b/man/Analogs.Rd @@ -143,7 +143,7 @@ the selection of the best analogs in a short number of posibilities, the best ones. This function has not constrains of specific regions, variables to downscale, or data to be used (seasonal forecast data, climate projections data, reanalyses data). The regrid into a finner scale is done interpolating -with CST_Load. Then, this interpolation is corrected selecting the analogs in +with CST_Start. Then, this interpolation is corrected selecting the analogs in the large and local scale in based of the observations. The function is an adapted version of the method of Yiou et al 2013. } diff --git a/man/BiasCorrection.Rd b/man/BiasCorrection.Rd index a7fe938b..e2b86f99 100644 --- a/man/BiasCorrection.Rd +++ b/man/BiasCorrection.Rd @@ -17,13 +17,13 @@ BiasCorrection( } \arguments{ \item{exp}{A multidimensional array with named dimensions containing the -seasonal forecast experiment data with at least time and ensemble dimensions.} +seasonal forecast experiment data with at least time and member dimensions.} \item{obs}{A multidimensional array with named dimensions containing the observed data with at least time dimension.} \item{exp_cor}{A multidimensional array with named dimensions containing the -seasonal forecast experiment to be corrected with at least time and ensemble +seasonal forecast experiment to be corrected with at least time and member dimension. If it is NULL, the 'exp' forecast will be corrected. If there is only one corrected dataset, it should not have dataset dimension. If there is a corresponding corrected dataset for each 'exp' forecast, the dataset @@ -32,8 +32,8 @@ dimension must have the same length as in 'exp'. The default value is NULL.} \item{na.rm}{A logical value indicating whether missing values should be stripped before the computation proceeds, by default it is set to FALSE.} -\item{memb_dim}{A character string indicating the name of the ensemble -dimension. By default, it is set to 'ensemble'.} +\item{memb_dim}{A character string indicating the name of the member +dimension. By default, it is set to 'member'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -60,9 +60,9 @@ standard deviation and mean to that of the reference dataset. } \examples{ mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, lat = 6, lon = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, lat = 6, lon = 7) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, lat = 6, lon = 7) a <- BiasCorrection(exp = mod1, obs = obs1) } \references{ diff --git a/man/CST_Analogs.Rd b/man/CST_Analogs.Rd index aa1e4d01..d837d70f 100644 --- a/man/CST_Analogs.Rd +++ b/man/CST_Analogs.Rd @@ -124,7 +124,7 @@ analogs. This function has not constrains of specific regions, variables to downscale, or data to be used (seasonal forecast data, climate projections data, reanalyses data). The regrid into a finner scale is done interpolating with -CST_Load. Then, this interpolation is corrected selecting the analogs in the +CST_Start. Then, this interpolation is corrected selecting the analogs in the large and local scale in based of the observations. The function is an adapted version of the method of Yiou et al 2013. For an advanced search of Analogs (multiple Analogs, different criterias, further information from the @@ -161,8 +161,7 @@ from surface pressure using analogues. Clim. Dyn., 41, 1419-1437. \email{pascal.yiou@lsce.ipsl.fr} } \seealso{ -\code{\link{CST_Load}}, \code{\link[s2dv]{Load}} and -\code{\link[s2dv]{CDORemap}} +\code{\link{CST_Start}}, \code{\link[startR]{Start}} } \author{ M. Carmen Alvarez-Castro, \email{carmen.alvarez-castro@cmcc.it} diff --git a/man/CST_Anomaly.Rd b/man/CST_Anomaly.Rd index 8c037bfb..ada952ee 100644 --- a/man/CST_Anomaly.Rd +++ b/man/CST_Anomaly.Rd @@ -86,7 +86,7 @@ anom <- CST_Anomaly(exp = exp, obs = obs, cross = FALSE, memb = TRUE) } \seealso{ \code{\link[s2dv]{Ano_CrossValid}}, \code{\link[s2dv]{Clim}} and -\code{\link{CST_Load}} +\code{\link{CST_Start}} } \author{ Perez-Zanon Nuria, \email{nuria.perez@bsc.es} diff --git a/man/CST_BiasCorrection.Rd b/man/CST_BiasCorrection.Rd index dcc6926f..c438d061 100644 --- a/man/CST_BiasCorrection.Rd +++ b/man/CST_BiasCorrection.Rd @@ -18,7 +18,7 @@ CST_BiasCorrection( \arguments{ \item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} function, containing the seasonal forecast experiment data in the element -named \code{$data} with at least time and ensemble dimensions.} +named \code{$data} with at least time and member dimensions.} \item{obs}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} function, containing the observed data in the element named \code{$data} @@ -35,8 +35,8 @@ each 'exp' forecast, the dataset dimension must have the same length as in \item{na.rm}{A logical value indicating whether missing values should be stripped before the computation proceeds, by default it is set to FALSE.} -\item{memb_dim}{A character string indicating the name of the ensemble -dimension. By default, it is set to 'ensemble'.} +\item{memb_dim}{A character string indicating the name of the member +dimension. By default, it is set to 'member'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} diff --git a/man/CST_Calibration.Rd b/man/CST_Calibration.Rd index 4cd0cacb..491b7271 100644 --- a/man/CST_Calibration.Rd +++ b/man/CST_Calibration.Rd @@ -23,7 +23,7 @@ CST_Calibration( } \arguments{ \item{exp}{An object of class \code{s2dv_cube} as returned by \code{CST_Start} -function with at least 'sdate' and 'ensemble' dimensions, containing the +function with at least 'sdate' and 'member' dimensions, containing the seasonal hindcast experiment data in the element named \code{data}. The hindcast is used to calibrate the forecast in case the forecast is provided; if not, the same hindcast will be calibrated instead.} @@ -33,7 +33,7 @@ function with at least 'sdate' dimension, containing the observed data in the element named \code{$data}.} \item{exp_cor}{An optional object of class \code{s2dv_cube} as returned by -\code{CST_Start} function with at least 'sdate' and 'ensemble' dimensions, +\code{CST_Start} function with at least 'sdate' and 'member' dimensions, containing the seasonal forecast experiment data in the element named \code{data}. If the forecast is provided, it will be calibrated using the hindcast and observations; if not, the hindcast will be calibrated instead. @@ -78,8 +78,8 @@ significant (\code{"sign"}). Only useful if \code{cal.method == "rpc-based"}.} correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == "sign"}.} -\item{memb_dim}{A character string indicating the name of the ensemble dimension. -By default, it is set to 'ensemble'.} +\item{memb_dim}{A character string indicating the name of the member dimension. +By default, it is set to 'member'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -100,7 +100,7 @@ dimensions as in the 'exp' object. nexp is the number of experiment is provided the returned array will be with the same dimensions as 'exp_cor'. } \description{ -Five types of ensemble-by-ensemble bias correction can be performed. +Five types of member-by-member bias correction can be performed. The \code{"bias"} method corrects the bias only, the \code{"evmos"} method applies a variance inflation technique to ensure the correction of the bias and the correspondence of variance between forecast and observation (Van @@ -130,12 +130,12 @@ the computation of the parameters needed to perform the calibration. \examples{ # Example 1: mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) -longitude <- seq(0, 30, 5) -latitude <- seq(0, 25, 5) -coords <- list(latitude = latitude, longitude = longitude) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +lon <- seq(0, 30, 5) +lat <- seq(0, 25, 5) +coords <- list(lat = lat, lon = lon) exp <- list(data = mod1, coords = coords) obs <- list(data = obs1, coords = coords) attr(exp, 'class') <- 's2dv_cube' @@ -145,16 +145,16 @@ a <- CST_Calibration(exp = exp, obs = obs, cal.method = "mse_min", eval.method = # Example 2: mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) mod2 <- 1 : (1 * 3 * 1 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) -dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, time = 5, latitude = 6, longitude = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) +dim(mod2) <- c(dataset = 1, member = 3, sdate = 1, ftime = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) -longitude <- seq(0, 30, 5) -latitude <- seq(0, 25, 5) -coords <- list(latitude = latitude, longitude = longitude) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) +lon <- seq(0, 30, 5) +lat <- seq(0, 25, 5) +coords <- list(lat = lat, lon = lon) exp <- list(data = mod1, coords = coords) obs <- list(data = obs1, coords = coords) -exp_cor <- list(data = mod2, latitude = latitude, longitude = longitude) +exp_cor <- list(data = mod2, lat = lat, lon = lon) attr(exp, 'class') <- 's2dv_cube' attr(obs, 'class') <- 's2dv_cube' attr(exp_cor, 'class') <- 's2dv_cube' @@ -176,7 +176,7 @@ through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. \doi{10.5194/npg-18-147-2011} Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -post-processing using ensemble-by-ensemble approaches: theoretical aspects. +post-processing using member-by-member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. \doi{10.1002/qj.2397} } diff --git a/man/Calibration.Rd b/man/Calibration.Rd index bbebfd5c..1c9bb1b5 100644 --- a/man/Calibration.Rd +++ b/man/Calibration.Rd @@ -23,7 +23,7 @@ Calibration( } \arguments{ \item{exp}{A multidimensional array with named dimensions (at least 'sdate' -and 'ensemble') containing the seasonal hindcast experiment data. The hindcast +and 'member') containing the seasonal hindcast experiment data. The hindcast is used to calibrate the forecast in case the forecast is provided; if not, the same hindcast will be calibrated instead.} @@ -31,7 +31,7 @@ the same hindcast will be calibrated instead.} containing the observed data.} \item{exp_cor}{An optional multidimensional array with named dimensions (at -least 'sdate' and 'ensemble') containing the seasonal forecast experiment +least 'sdate' and 'member') containing the seasonal forecast experiment data. If the forecast is provided, it will be calibrated using the hindcast and observations; if not, the hindcast will be calibrated instead. If there is only one corrected dataset, it should not have dataset dimension. If there @@ -74,8 +74,8 @@ significant (\code{"sign"}). Only useful if \code{cal.method == "rpc-based"}.} correlation test. Only useful if \code{cal.method == "rpc-based" & apply_to == "sign"}.} -\item{memb_dim}{A character string indicating the name of the ensemble -dimension. By default, it is set to 'ensemble'.} +\item{memb_dim}{A character string indicating the name of the member +dimension. By default, it is set to 'member'.} \item{sdate_dim}{A character string indicating the name of the start date dimension. By default, it is set to 'sdate'.} @@ -96,7 +96,7 @@ If 'exp_cor' is provided the returned array will be with the same dimensions as 'exp_cor'. } \description{ -Five types of ensemble-by-ensemble bias correction can be performed. +Five types of member-by-member bias correction can be performed. The \code{"bias"} method corrects the bias only, the \code{"evmos"} method applies a variance inflation technique to ensure the correction of the bias and the correspondence of variance between forecast and observation (Van @@ -125,9 +125,9 @@ the computation of the parameters needed to perform the calibration. } \examples{ mod1 <- 1 : (1 * 3 * 4 * 5 * 6 * 7) -dim(mod1) <- c(dataset = 1, ensemble = 3, sdate = 4, time = 5, latitude = 6, longitude = 7) +dim(mod1) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7) obs1 <- 1 : (1 * 1 * 4 * 5 * 6 * 7) -dim(obs1) <- c(dataset = 1, ensemble = 1, sdate = 4, time = 5, latitude = 6, longitude = 7) +dim(obs1) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7) a <- Calibration(exp = mod1, obs = obs1) } @@ -146,7 +146,7 @@ through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. \doi{10.5194/npg-18-147-2011} Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble -post-processing using ensemble-by-ensemble approaches: theoretical aspects. +post-processing using member-by-member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. \doi{10.1002/qj.2397} } diff --git a/man/as.s2dv_cube.Rd b/man/as.s2dv_cube.Rd index 30f9abd4..9d7bbde4 100644 --- a/man/as.s2dv_cube.Rd +++ b/man/as.s2dv_cube.Rd @@ -85,7 +85,7 @@ data <- as.s2dv_cube(data) } } \seealso{ -\code{\link{s2dv_cube}}, \code{\link[s2dv]{Load}}, +\code{\link{s2dv_cube}}, \code{\link{CST_Start}}, \code{\link[startR]{Start}} and \code{\link{CST_Load}} } \author{ diff --git a/man/s2dv_cube.Rd b/man/s2dv_cube.Rd index b2fb54de..53ba4acb 100644 --- a/man/s2dv_cube.Rd +++ b/man/s2dv_cube.Rd @@ -18,7 +18,7 @@ s2dv_cube( } \arguments{ \item{data}{A multidimensional array with named dimensions, typically with -dimensions: dataset, ensemble, sdate, time, lat and lon.} +dimensions: dataset, member, sdate, time, lat and lon.} \item{coords}{A list of named vectors with the coordinates corresponding to the dimensions of the data parameter. If any coordinate has dimensions, they @@ -84,7 +84,7 @@ elements in the structure:\cr \description{ This function allows to create an 's2dv_cube' object by passing information through its parameters. This function will be needed if the data -hasn't been loaded using CST_Load or has been transformed with other methods. +hasn't been loaded using CST_Start or has been transformed with other methods. An 's2dv_cube' object has many different components including metadata. This function will allow to create 's2dv_cube' objects even if not all elements are defined and for each expected missed parameter a warning message will be -- GitLab From e56821dc2e5141b7526a17042c17fc90b73d0493 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 10 Oct 2023 12:33:30 +0200 Subject: [PATCH 4/7] Correct minor changes in SaveExp regarding CST_Start --- R/CST_SaveExp.R | 4 ++-- man/CST_SaveExp.Rd | 2 +- man/SaveExp.Rd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/CST_SaveExp.R b/R/CST_SaveExp.R index 31608e89..b58824bd 100644 --- a/R/CST_SaveExp.R +++ b/R/CST_SaveExp.R @@ -5,7 +5,7 @@ #'@description This function allows to divide and save a object of class #''s2dv_cube' into a NetCDF file, allowing to reload the saved data using #'\code{Start} function from StartR package. If the original 's2dv_cube' object -#'has been created from \code{CST_Start()}, then it can be reloaded with +#'has been created from \code{CST_Load()}, then it can be reloaded with #'\code{Load()}. #' #'@param data An object of class \code{s2dv_cube}. @@ -178,7 +178,7 @@ CST_SaveExp <- function(data, destination = "./", sdate_dim = 'sdate', #'@description This function allows to save a data array with metadata into a #'NetCDF file, allowing to reload the saved data using \code{Start} function #'from StartR package. If the original 's2dv_cube' object has been created from -#'\code{CST_Start()}, then it can be reloaded with \code{Start()}. +#'\code{CST_Load()}, then it can be reloaded with \code{Load()}. #' #'@author Perez-Zanon Nuria, \email{nuria.perez@bsc.es} #' diff --git a/man/CST_SaveExp.Rd b/man/CST_SaveExp.Rd index 35b7d098..5894b704 100644 --- a/man/CST_SaveExp.Rd +++ b/man/CST_SaveExp.Rd @@ -93,7 +93,7 @@ Multiple or single NetCDF files containing the data array.\cr This function allows to divide and save a object of class 's2dv_cube' into a NetCDF file, allowing to reload the saved data using \code{Start} function from StartR package. If the original 's2dv_cube' object -has been created from \code{CST_Start()}, then it can be reloaded with +has been created from \code{CST_Load()}, then it can be reloaded with \code{Load()}. } \examples{ diff --git a/man/SaveExp.Rd b/man/SaveExp.Rd index d8ff9674..5a9fff85 100644 --- a/man/SaveExp.Rd +++ b/man/SaveExp.Rd @@ -113,7 +113,7 @@ Multiple or single NetCDF files containing the data array.\cr This function allows to save a data array with metadata into a NetCDF file, allowing to reload the saved data using \code{Start} function from StartR package. If the original 's2dv_cube' object has been created from -\code{CST_Start()}, then it can be reloaded with \code{Start()}. +\code{CST_Load()}, then it can be reloaded with \code{Load()}. } \examples{ \dontrun{ -- GitLab From a9c94282551777bd7389ce0707476b8227f91c0f Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 10 Oct 2023 12:40:36 +0200 Subject: [PATCH 5/7] Correct SaveExp examples input params --- R/CST_SaveExp.R | 22 +++++++++++----------- man/CST_SaveExp.Rd | 6 +++--- man/SaveExp.Rd | 16 ++++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/R/CST_SaveExp.R b/R/CST_SaveExp.R index b58824bd..7d5733f1 100644 --- a/R/CST_SaveExp.R +++ b/R/CST_SaveExp.R @@ -72,10 +72,10 @@ #' #'@examples #'\dontrun{ -#'data <- lonlat_temp$exp +#'data <- lonlat_temp_st$exp #'destination <- "./" -#'CST_SaveExp(data = data, destination = destination, ftime_dim = 'time', -#' var_dim = NULL, ftime_dim = 'time', var_dim = NULL) +#'CST_SaveExp(data = data, destination = destination, ftime_dim = 'ftime', +#' var_dim = 'var', dat_dim = 'dataset') #'} #' #'@import ncdf4 @@ -253,19 +253,19 @@ CST_SaveExp <- function(data, destination = "./", sdate_dim = 'sdate', #' #'@examples #'\dontrun{ -#'data <- lonlat_temp$exp$data -#'lon <- lonlat_temp$exp$coords$lon -#'lat <- lonlat_temp$exp$coords$lat +#'data <- lonlat_temp_st$exp$data +#'lon <- lonlat_temp_st$exp$coords$lon +#'lat <- lonlat_temp_st$exp$coords$lat #'coords <- list(lon = lon, lat = lat) -#'Datasets <- lonlat_temp$exp$attrs$Datasets +#'Datasets <- lonlat_temp_st$exp$attrs$Datasets #'varname <- 'tas' -#'Dates <- lonlat_temp$exp$attrs$Dates +#'Dates <- lonlat_temp_st$exp$attrs$Dates #'destination = './' -#'metadata <- lonlat_temp$exp$attrs$Variable$metadata +#'metadata <- lonlat_temp_st$exp$attrs$Variable$metadata #'SaveExp(data = data, destination = destination, coords = coords, #' Datasets = Datasets, varname = varname, Dates = Dates, -#' metadata = metadata, single_file = TRUE, ftime_dim = 'time', -#' var_dim = NULL) +#' metadata = metadata, single_file = TRUE, ftime_dim = 'ftime', +#' var_dim = 'var', dat_dim = 'dataset') #'} #' #'@import ncdf4 diff --git a/man/CST_SaveExp.Rd b/man/CST_SaveExp.Rd index 5894b704..9352e036 100644 --- a/man/CST_SaveExp.Rd +++ b/man/CST_SaveExp.Rd @@ -98,10 +98,10 @@ has been created from \code{CST_Load()}, then it can be reloaded with } \examples{ \dontrun{ -data <- lonlat_temp$exp +data <- lonlat_temp_st$exp destination <- "./" -CST_SaveExp(data = data, destination = destination, ftime_dim = 'time', - var_dim = NULL, ftime_dim = 'time', var_dim = NULL) +CST_SaveExp(data = data, destination = destination, ftime_dim = 'ftime', + var_dim = 'var', dat_dim = 'dataset') } } diff --git a/man/SaveExp.Rd b/man/SaveExp.Rd index 5a9fff85..c690d97e 100644 --- a/man/SaveExp.Rd +++ b/man/SaveExp.Rd @@ -117,19 +117,19 @@ from StartR package. If the original 's2dv_cube' object has been created from } \examples{ \dontrun{ -data <- lonlat_temp$exp$data -lon <- lonlat_temp$exp$coords$lon -lat <- lonlat_temp$exp$coords$lat +data <- lonlat_temp_st$exp$data +lon <- lonlat_temp_st$exp$coords$lon +lat <- lonlat_temp_st$exp$coords$lat coords <- list(lon = lon, lat = lat) -Datasets <- lonlat_temp$exp$attrs$Datasets +Datasets <- lonlat_temp_st$exp$attrs$Datasets varname <- 'tas' -Dates <- lonlat_temp$exp$attrs$Dates +Dates <- lonlat_temp_st$exp$attrs$Dates destination = './' -metadata <- lonlat_temp$exp$attrs$Variable$metadata +metadata <- lonlat_temp_st$exp$attrs$Variable$metadata SaveExp(data = data, destination = destination, coords = coords, Datasets = Datasets, varname = varname, Dates = Dates, - metadata = metadata, single_file = TRUE, ftime_dim = 'time', - var_dim = NULL) + metadata = metadata, single_file = TRUE, ftime_dim = 'ftime', + var_dim = 'var', dat_dim = 'dataset') } } -- GitLab From 7d42203fa92aee8a8ccd20ff378e7581bf3cf106 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 10 Oct 2023 13:03:15 +0200 Subject: [PATCH 6/7] Add startR import in the package and return to roxygen previous version --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d0d8c7c2..980023c2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -62,6 +62,7 @@ Depends: easyVerification Imports: s2dv, + startR, rainfarmr, multiApply (>= 2.1.1), ClimProjDiags, @@ -84,11 +85,10 @@ Suggests: testthat, knitr, markdown, - rmarkdown, - startR + rmarkdown VignetteBuilder: knitr License: GPL-3 Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.2.0 Config/testthat/edition: 3 -- GitLab From fb3096a16781fa416f27cb5fcdc314150ff4b6c8 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 10 Oct 2023 14:59:38 +0200 Subject: [PATCH 7/7] Correct ellipsis parameter in print method for s2dv_cube --- R/print.s2dv_cube.R | 6 ++++-- man/print.s2dv_cube.Rd | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/print.s2dv_cube.R b/R/print.s2dv_cube.R index 2ad4186d..3cb0744a 100644 --- a/R/print.s2dv_cube.R +++ b/R/print.s2dv_cube.R @@ -13,9 +13,11 @@ #'information about the 's2dv_cube', see \code{s2dv_cube()} and #'\code{as.s2dv_cube()} functions. #' -#'@param x An 's2dv_cube' object +#'@param x An 's2dv_cube' object. +#'@param ... Additional arguments of print function. +#' #'@export -print.s2dv_cube <- function(x) { +print.s2dv_cube <- function(x, ...) { if (is.atomic(x)) { cat(x, "\n") } else { diff --git a/man/print.s2dv_cube.Rd b/man/print.s2dv_cube.Rd index 3baca724..415e3f07 100644 --- a/man/print.s2dv_cube.Rd +++ b/man/print.s2dv_cube.Rd @@ -4,10 +4,12 @@ \alias{print.s2dv_cube} \title{Print method for s2dv_cube objects} \usage{ -\method{print}{s2dv_cube}(x) +\method{print}{s2dv_cube}(x, ...) } \arguments{ -\item{x}{An 's2dv_cube' object} +\item{x}{An 's2dv_cube' object.} + +\item{...}{Additional arguments of print function.} } \description{ This is an S3 method of the generic 'print' for the class 's2dv_cube'. When -- GitLab