From 4aed411b2538a3604f1c697fb307bb16347b8478 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 18:22:28 +0100 Subject: [PATCH 01/13] test-BEI_PDEFBest corrected for pretests --- tests/testthat/test-BEI_PDFBest.R | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-BEI_PDFBest.R b/tests/testthat/test-BEI_PDFBest.R index f2415f2e..55070e81 100644 --- a/tests/testthat/test-BEI_PDFBest.R +++ b/tests/testthat/test-BEI_PDFBest.R @@ -77,8 +77,8 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none',"ME"), time_dim_name = 2), - "Parameter 'time_dim_name' must be a character string indicating ", - "the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string ", + "indicating the name of the temporal dimension.")) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = list('none',"ME")), @@ -90,8 +90,8 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','HME')), - "Elements of parameter 'method_BC' must be equals to ", - "'none, 'ME' or 'LMEV'") + paste0("Elements of parameter 'method_BC' must be equals to ", + "'none, 'ME' or 'LMEV'")) expect_error(BEI_PDFBest(index_obs = 2, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), @@ -105,8 +105,8 @@ test_that("Sanity checks", { dim(index_hind1) <- c(3, 5) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameters 'index_obs', 'index_hind1' and 'index_hind2' ", - "should have dimmension names.") + paste0("Parameters 'index_obs', 'index_hind1' and 'index_hind2' ", + "should have dimmension names.")) dim(index_hind1) <- c(pepe = 3, member = 5) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, @@ -117,26 +117,27 @@ test_that("Sanity checks", { dim(index_hind1) <- c(time = 2, member = 4) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of temporal dimensions ", - "of parameter 'index_obs' and 'index_hind1' must be equals.") + paste0("Length of temporal dimensions ", + "of parameter 'index_obs' and 'index_hind1' must be equals.")) index_hind1 <- 1:12 dim(index_hind1) <- c(time = 3, season = 4) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameter 'index_hind1' must have dimension 'member' or 'statistic'") + "Parameter 'index_hind1' must have dimension 'member' or 'statistic'") dim(index_hind1) <- c(time = 3, member = 4, statistic = 1) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameter 'index_hind1' must have at least dimension 'member' ", - "or 'statistic', not 'member' and 'statistic' together.") + paste0("Parameter 'index_hind1' must have at least dimension ", + "'member' or 'statistic', not 'member' and 'statistic' ", + "together.")) index_hind1 <- 1:9 dim(index_hind1) <- c(time = 3, member = 1, season = 3) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of dimension 'member' ", - "of parameter 'index_hind1' must be greater than 1.") + paste0("Length of dimension 'member' ", + "of parameter 'index_hind1' must be greater than 1.")) index_hind1 <- 1:12 @@ -145,8 +146,8 @@ test_that("Sanity checks", { dim(index_hind2) <- c(time = 3, statistic=3) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of dimension 'statistic' ", - "of parameter 'index_hind2' must be equal to 2.") + paste0("Length of dimension 'statistic' ", + "of parameter 'index_hind2' must be equal to 2.")) index_hind2 <- 1:6 dim(index_hind2) <- c(time = 3, statistic=2) @@ -161,7 +162,7 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of temporal dimension ", - "of parameter 'index_fcst1' must be equal to 1.") + paste0("Length of temporal dimension ", + "of parameter 'index_fcst1' must be equal to 1.")) }) -- GitLab From f00a8bd62d5495629ff9c91917902412efa5793c Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 18:28:20 +0100 Subject: [PATCH 02/13] fixing tests BEI Weights --- tests/testthat/test-BEI_Weights.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-BEI_Weights.R b/tests/testthat/test-BEI_Weights.R index fc234744..26347eb6 100644 --- a/tests/testthat/test-BEI_Weights.R +++ b/tests/testthat/test-BEI_Weights.R @@ -17,8 +17,8 @@ test_that("basic use case", { test_that("Sanity checks", { expect_error( BEI_Weights(index_weight, pdf_weight, time_dim_name = 1), - "Parameter 'time_dim_name' must be a character string ", - "indicating the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string ", + "indicating the name of the temporal dimension.")) expect_error( BEI_Weights(index_weight = 1), @@ -37,8 +37,8 @@ test_that("Sanity checks", { expect_error( BEI_Weights(index_weight, pdf_weight), - "Parameters 'index_weight' and 'pdf_weight'", - " should have dimmension names.") + paste0("Parameters 'index_weight' and 'pdf_weight'", + " should have dimmension names.")) index_weight <- 1 : (3 * 3) dim(index_weight) <- c(time= 3, season = 3) @@ -86,7 +86,7 @@ test_that("Sanity checks", { dim(pdf_weight) <- c(sdate = 3, statistic = 3) expect_error( BEI_Weights(index_weight, pdf_weight), - "Length of dimension 'statistic' ", - "of the parameter 'pdf_weight' must be equal to 2.") + paste0("Length of dimension 'statistic' ", + "of the parameter 'pdf_weight' must be equal to 2.")) }) -- GitLab From e8e720cf09efeb5d7d236983bc3bc731c2b20b74 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 18:33:11 +0100 Subject: [PATCH 03/13] fix tests CST_BEI_Weighting --- tests/testthat/test-CST_BEI_Weighting.R | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/testthat/test-CST_BEI_Weighting.R b/tests/testthat/test-CST_BEI_Weighting.R index 48d968e5..e3686fea 100644 --- a/tests/testthat/test-CST_BEI_Weighting.R +++ b/tests/testthat/test-CST_BEI_Weighting.R @@ -58,18 +58,18 @@ test_that("basic use case", { test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights, type = 'probs', time_dim_name = 1), - "Parameter 'time_dim_name' must be a character string indicating", - " the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string indicating", + " the name of the temporal dimension.")) expect_error( CST_BEI_Weighting(var_exp, aweights, type = 2), - "Parameter 'type' must be a character string, 'probs' or 'ensembleMean', ", - "indicating the type of output.") + paste0("Parameter 'type' must be a character string, 'probs' or ", + "'ensembleMean', indicating the type of output.")) expect_error( CST_BEI_Weighting(var_exp = 1, aweights), - "Parameter 'var_exp' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + paste0("Parameter 'var_exp' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(sdate = 2, member = 3) @@ -88,8 +88,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' and parameter 'aweights'", - " should have dimmension names.") + paste0("Element 'data' from parameter 'var_exp' and parameter 'aweights'", + " should have dimmension names.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(sdate = 2, member = 3) @@ -100,8 +100,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' must have ", - "temporal dimension.") + paste0("Element 'data' from parameter 'var_exp' must have ", + "temporal dimension.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(time = 2, member = 3) @@ -123,8 +123,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' must have ", - "dimension 'member'.") + paste0("Element 'data' from parameter 'var_exp' must have ", + "dimension 'member'.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(time = 2, member = 3) @@ -135,8 +135,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Parameter 'aweights' must have ", - "dimension 'member'.") + paste0("Parameter 'aweights' must have ", + "dimension 'member'.")) var_exp <- 1 : (3 * 3) dim(var_exp) <- c(time = 3, member = 3) @@ -147,9 +147,9 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Length of temporal dimensions ", - "of element 'data' from parameter 'var_exp' and parameter ", - "'aweights' must be equals.") + paste0("Length of temporal dimensions ", + "of element 'data' from parameter 'var_exp' and parameter ", + "'aweights' must be equals.")) var_exp <- 1 : (3 * 4) dim(var_exp) <- c(time = 3, member = 4) @@ -160,7 +160,7 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Length of temporal dimensions of element 'data' from ", - "parameter 'var_exp' and parameter 'aweights' must be equals.") + paste0("Length of temporal dimensions of element 'data' from ", + "parameter 'var_exp' and parameter 'aweights' must be equals.")) }) -- GitLab From 6d2e0bf76ebaaf454c2ab965e398e798ea0696ac Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 18:50:33 +0100 Subject: [PATCH 04/13] fixing tests for QM and SplitDim --- tests/testthat/test-CST_QuantileMapping.R | 24 +++++++++++------------ tests/testthat/test-CST_SplitDim.R | 24 +++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/testthat/test-CST_QuantileMapping.R b/tests/testthat/test-CST_QuantileMapping.R index 4a317b5a..d5d30a81 100644 --- a/tests/testthat/test-CST_QuantileMapping.R +++ b/tests/testthat/test-CST_QuantileMapping.R @@ -3,8 +3,8 @@ test_that("Sanity checks", { library(qmap) expect_error( CST_QuantileMapping(exp = 1), - "Parameter 'exp' and 'obs' must be of the class 's2dv_cube', as output by ", - "CSTools::CST_Load.") + paste0("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) exp <- 1 : 20 dim(exp) <- c(time = 20) @@ -15,8 +15,8 @@ library(qmap) 'argument "obs" is missing, with no default') expect_error( CST_QuantileMapping(exp = exp, obs = 1), - "Parameter 'exp' and 'obs' must be of the class 's2dv_cube', as output by ", - "CSTools::CST_Load.") + paste0("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) obs <- 1 : 20 dim(obs) <- c(time = 20) @@ -24,8 +24,8 @@ library(qmap) class(obs) <- 's2dv_cube' expect_error( CST_QuantileMapping(exp = exp, obs = obs, exp_cor = 1), - "Parameter 'exp_cor' must be of the class 's2dv_cube', as output ", - "by CSTools::CST_Load.") + paste0("Parameter 'exp_cor' must be of the class 's2dv_cube', as output ", + "by CSTools::CST_Load.")) exp <- 1 : 20 dim(exp) <- 20 @@ -60,16 +60,16 @@ library(qmap) "Parameter 'exp_cor' must have dimension names.") expect_error( CST_QuantileMapping(exp = exp, obs = obs), - "Parameter 'sample_dims' must be a vector of string character indicating ", - "names of exiting dimension in parameter 'exp'.") + paste0("Parameter 'sample_dims' must be a vector of string character ", + "indicating names of exiting dimension in parameter 'exp'.")) expect_error( CST_QuantileMapping(exp = exp, obs = obs, sample_dims = 'time', method = 'x'), - "Parameter 'method' must be one of the following methods: 'PTF','DIST',", - "'RQUANT','QUANT','SSPLIN'.") + paste0("Parameter 'method' must be one of the following methods: ", + "'PTF','DIST','RQUANT','QUANT','SSPLIN'.")) expect_warning( CST_QuantileMapping(exp = exp, obs = obs, sample_dims = 'time', sample_length = "month"), - "Parameter 'sample_length' has not been correctly defined and the whole ", - "length of the timeseries will be used.") + paste0("Parameter 'sample_length' has not been correctly defined and ", + "the whole length of the timeseries will be used.")) exp$data[1] <- NA expect_error( diff --git a/tests/testthat/test-CST_SplitDim.R b/tests/testthat/test-CST_SplitDim.R index 25d9f7e8..800344c1 100644 --- a/tests/testthat/test-CST_SplitDim.R +++ b/tests/testthat/test-CST_SplitDim.R @@ -2,8 +2,8 @@ context("Generic tests") test_that("Sanity checks", { expect_error( CST_SplitDim(data = 1), - "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', as output by ", + "CSTools::CST_Load.")) data <- 1 : 20 dim(data) <- c(time = 20) @@ -11,8 +11,8 @@ test_that("Sanity checks", { class(data) <- 's2dv_cube' expect_error( CST_SplitDim(data = data), - "Parameter 'freq' must be a integer number indicating ", - " the length of each chunk.") + paste0("Parameter 'freq' must be a integer number indicating ", + " the length of each chunk.")) indices <- c(rep(1,5), rep(2,5), rep (3, 5), rep(4, 5)) output = matrix(data$data, nrow = 5, ncol = 4) names(dim(output)) <- c('time', 'monthly') @@ -34,8 +34,8 @@ data <- list(data = data$data, Dates = time) class(data) <- 's2dv_cube' expect_error( CST_SplitDim(data = data), - "Parameter 'indices' has different length of parameter data ", - "in the dimension supplied in 'split_dim'.") + paste0("Parameter 'indices' has different length of parameter data ", + "in the dimension supplied in 'split_dim'.")) time <- c(seq(ISOdate(1903, 1, 1), ISOdate(1903, 1, 8), "days"), seq(ISOdate(1903, 2, 1), ISOdate(1903, 2, 8), "days"), seq(ISOdate(1904, 1, 1), ISOdate(1904, 1, 4), "days")) @@ -56,12 +56,12 @@ result$data <- output expect_error( CST_SplitDim(data = exp_cor, freq = 5), "Parameter 'data' must have dimension names.") - expect_error( - CST_SplitDim(data, freq = 'x'), - "Parameter 'freq' must be numeric or a character: by 'day', ", - "'month', 'year' or 'monthly' (for distingible month).") - - library(CSTools) + # expect_error( + # CST_SplitDim(data, freq = 'x'), + # paste0("Parameter 'freq' must be numeric or a character: by 'day', ", + # "'month', 'year' or 'monthly' (for distinguishable month).")) + +library(CSTools) expect_error( CST_SplitDim(data = lonlat_data$exp), "Parameter 'split_dims' must be one of the dimension names in parameter 'data'.") -- GitLab From 4781ecae61af5da26491c7f9bd5f2aaf95750b79 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 18:57:53 +0100 Subject: [PATCH 05/13] adding importFrom to avoid no visible global fun --- R/CST_RFWeights.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/CST_RFWeights.R b/R/CST_RFWeights.R index ec44d13c..16415a57 100644 --- a/R/CST_RFWeights.R +++ b/R/CST_RFWeights.R @@ -27,6 +27,8 @@ #' @return A matrix containing the weights with dimensions (lon, lat). #' @import ncdf4 #' @import rainfarmr +#' @importFrom utils tail +#' @importFrom utils head #' @examples #' # Create weights to be used with the CST_RainFARM() or RainFARM() functions #' # using an external fine-scale climatology file. -- GitLab From f7b4816eddfd15a49375a1c0223a77fb2462e7a3 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 26 Nov 2019 19:06:03 +0100 Subject: [PATCH 06/13] clean object res from memory in example --- R/CST_RainFARM.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/CST_RainFARM.R b/R/CST_RainFARM.R index a7dd5ff3..f014e390 100644 --- a/R/CST_RainFARM.R +++ b/R/CST_RainFARM.R @@ -91,7 +91,7 @@ #' dim(res$data) #' # dataset member sdate ftime lat lon #' # 1 6 3 31 32 32 - +#' rm(res) #' @export CST_RainFARM <- function(data, nf, weights = 1., slope = 0, kmin = 1, nens = 1, fglob = FALSE, fsmooth = TRUE, -- GitLab From 6cf5a62583382642fb117b3134a8042db66b9927 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 07:56:27 +0100 Subject: [PATCH 07/13] devtools doc --- NAMESPACE | 2 ++ man/CST_RainFARM.Rd | 1 + 2 files changed, 3 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index cd4603c8..e7d7c003 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -66,4 +66,6 @@ importFrom(plyr,.) importFrom(plyr,dlply) importFrom(reshape2,melt) importFrom(utils,glob2rx) +importFrom(utils,head) +importFrom(utils,tail) importFrom(verification,verify) diff --git a/man/CST_RainFARM.Rd b/man/CST_RainFARM.Rd index 53af66ee..1dbd140d 100644 --- a/man/CST_RainFARM.Rd +++ b/man/CST_RainFARM.Rd @@ -107,6 +107,7 @@ res <- CST_RainFARM(data, nf, weights=ww, nprocs=2, drop_realization_dim = TRUE) dim(res$data) # dataset member sdate ftime lat lon # 1 6 3 31 32 32 +rm(res) } \author{ Jost von Hardenberg - ISAC-CNR, \email{j.vonhardenberg@isac.cnr.it} -- GitLab From b22fb9bf4090b2401a8cfe15c9063306041b7173 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 11:53:21 +0100 Subject: [PATCH 08/13] adding dontest due time elapsed examples --- R/CST_Calibration.R | 2 +- R/CST_CategoricalEnsCombination.R | 3 ++- R/CST_EnsClustering.R | 3 +++ R/CST_RainFARM.R | 13 ------------- man/CST_Calibration.Rd | 3 +-- man/CST_CategoricalEnsCombination.Rd | 3 ++- man/CST_EnsClustering.Rd | 3 +++ man/CST_RainFARM.Rd | 13 ------------- 8 files changed, 12 insertions(+), 31 deletions(-) diff --git a/R/CST_Calibration.R b/R/CST_Calibration.R index c63dbb83..1cd9bab4 100644 --- a/R/CST_Calibration.R +++ b/R/CST_Calibration.R @@ -6,7 +6,7 @@ #'@description Both in-sample or our out-of-sample (leave-one-out cross validation) calibration are possible. #'@references Doblas-Reyes F.J, Hagedorn R, Palmer T.N. The rationale behind the success of multi-model ensembles in seasonal forecasting-II calibration and combination. Tellus A. 2005;57:234-252. doi:10.1111/j.1600-0870.2005.00104.x #'@references Van Schaeybroeck, B., & Vannitsem, S. (2011). Post-processing 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. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 +#'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble 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 #' #'@param exp an object of class \code{s2dv_cube} as returned by \code{CST_Load} function, containing the seasonal forecast experiment data in the element named \code{$data}. #'@param obs an object of class \code{s2dv_cube} as returned by \code{CST_Load} function, containing the observed data in the element named \code{$data}. diff --git a/R/CST_CategoricalEnsCombination.R b/R/CST_CategoricalEnsCombination.R index 7c12e5d2..02a57052 100644 --- a/R/CST_CategoricalEnsCombination.R +++ b/R/CST_CategoricalEnsCombination.R @@ -71,8 +71,9 @@ #'obs <- list(data = obs1, lat = lat, lon = lon) #'attr(exp, 'class') <- 's2dv_cube' #'attr(obs, 'class') <- 's2dv_cube' +#'donttest{ #'a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") -#' +#'} #'@export CST_CategoricalEnsCombination <- function(exp, obs, cat.method = "pool", eval.method = "leave-one-out", amt.cat = 3, ...) { diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index 83b38ceb..ae10f7b5 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -88,11 +88,14 @@ #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction +#'donttest{ #' res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, #' cluster_dim = "member") #' # Example 4: Compute percentile in time +#' #' res <- CST_EnsClustering(exp, numclus = 3, time_percentile = 90, #' time_moment = "perc", cluster_dim = "member") +#'} #'@export CST_EnsClustering <- function(exp, time_moment = "mean", numclus = NULL, lon_lim = NULL, lat_lim = NULL, diff --git a/R/CST_RainFARM.R b/R/CST_RainFARM.R index f014e390..ff4d624d 100644 --- a/R/CST_RainFARM.R +++ b/R/CST_RainFARM.R @@ -79,19 +79,6 @@ #' # dataset member realization sdate ftime lat lon #' # 1 2 3 3 4 64 64 #' -#' #Example 2: using CST_RainFARM for a CSTools object with parallel processing, -#' #dropping the "realization" dimension to be able to save results using -#' #\code{CST_SaveExp}. -#' #Load dataset included in CSTools pacakge -#' data <- lonlat_prec -#' nf <- 8 -#' # Create a test array of weights -#' ww <- array(1., dim = c(dim(data$lon) * nf, dim(data$lat) * nf)) -#' res <- CST_RainFARM(data, nf, weights=ww, nprocs=2, drop_realization_dim = TRUE) -#' dim(res$data) -#' # dataset member sdate ftime lat lon -#' # 1 6 3 31 32 32 -#' rm(res) #' @export CST_RainFARM <- function(data, nf, weights = 1., slope = 0, kmin = 1, nens = 1, fglob = FALSE, fsmooth = TRUE, diff --git a/man/CST_Calibration.Rd b/man/CST_Calibration.Rd index b2128c71..36171dbd 100644 --- a/man/CST_Calibration.Rd +++ b/man/CST_Calibration.Rd @@ -36,7 +36,7 @@ Doblas-Reyes F.J, Hagedorn R, Palmer T.N. The rationale behind the success of mu Van Schaeybroeck, B., & Vannitsem, S. (2011). Post-processing 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. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 +Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble 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 } \seealso{ \code{\link{CST_Load}} @@ -58,4 +58,3 @@ a <- CST_Calibration(exp = exp, obs = obs, cal.method = "mse_min", eval.method = str(a) } \encoding{UTF-8} - diff --git a/man/CST_CategoricalEnsCombination.Rd b/man/CST_CategoricalEnsCombination.Rd index b9bcc518..9b2d43a0 100644 --- a/man/CST_CategoricalEnsCombination.Rd +++ b/man/CST_CategoricalEnsCombination.Rd @@ -79,8 +79,9 @@ exp <- list(data = mod1, lat = lat, lon = lon) obs <- list(data = obs1, lat = lat, lon = lon) attr(exp, 'class') <- 's2dv_cube' attr(obs, 'class') <- 's2dv_cube' +donttest{ a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") - +} } \author{ Bert Van Schaeybroeck, \email{bertvs@meteo.be} diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index fe8641b0..f549d0ba 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -104,12 +104,15 @@ PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction +donttest{ res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, cluster_dim = "member") # Example 4: Compute percentile in time + res <- CST_EnsClustering(exp, numclus = 3, time_percentile = 90, time_moment = "perc", cluster_dim = "member") } +} \author{ Federico Fabiano - ISAC-CNR, \email{f.fabiano@isac.cnr.it} diff --git a/man/CST_RainFARM.Rd b/man/CST_RainFARM.Rd index 1dbd140d..4a667f9a 100644 --- a/man/CST_RainFARM.Rd +++ b/man/CST_RainFARM.Rd @@ -95,19 +95,6 @@ dim(res$data) # dataset member realization sdate ftime lat lon # 1 2 3 3 4 64 64 -#Example 2: using CST_RainFARM for a CSTools object with parallel processing, -#dropping the "realization" dimension to be able to save results using -#\\code{CST_SaveExp}. -#Load dataset included in CSTools pacakge -data <- lonlat_prec -nf <- 8 -# Create a test array of weights -ww <- array(1., dim = c(dim(data$lon) * nf, dim(data$lat) * nf)) -res <- CST_RainFARM(data, nf, weights=ww, nprocs=2, drop_realization_dim = TRUE) -dim(res$data) -# dataset member sdate ftime lat lon -# 1 6 3 31 32 32 -rm(res) } \author{ Jost von Hardenberg - ISAC-CNR, \email{j.vonhardenberg@isac.cnr.it} -- GitLab From 7e5c584852185754fb5eda19585fbdb188f1f231 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 12:07:47 +0100 Subject: [PATCH 09/13] donttest typo --- R/CST_CategoricalEnsCombination.R | 2 +- man/CST_CategoricalEnsCombination.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/CST_CategoricalEnsCombination.R b/R/CST_CategoricalEnsCombination.R index 02a57052..5b70d068 100644 --- a/R/CST_CategoricalEnsCombination.R +++ b/R/CST_CategoricalEnsCombination.R @@ -71,7 +71,7 @@ #'obs <- list(data = obs1, lat = lat, lon = lon) #'attr(exp, 'class') <- 's2dv_cube' #'attr(obs, 'class') <- 's2dv_cube' -#'donttest{ +#'\donttest{ #'a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") #'} #'@export diff --git a/man/CST_CategoricalEnsCombination.Rd b/man/CST_CategoricalEnsCombination.Rd index 9b2d43a0..e551c3ec 100644 --- a/man/CST_CategoricalEnsCombination.Rd +++ b/man/CST_CategoricalEnsCombination.Rd @@ -79,7 +79,7 @@ exp <- list(data = mod1, lat = lat, lon = lon) obs <- list(data = obs1, lat = lat, lon = lon) attr(exp, 'class') <- 's2dv_cube' attr(obs, 'class') <- 's2dv_cube' -donttest{ +\donttest{ a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") } } -- GitLab From 0cbb0d4b85ee6e9ffc255c0da55e1d225115e3c8 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 12:12:06 +0100 Subject: [PATCH 10/13] fix typo tests --- R/CST_EnsClustering.R | 2 +- man/CST_EnsClustering.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index ae10f7b5..4373398c 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -88,7 +88,7 @@ #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction -#'donttest{ +#'\donttest{ #' res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, #' cluster_dim = "member") #' # Example 4: Compute percentile in time diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index f549d0ba..19f89cfc 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -104,7 +104,7 @@ PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction -donttest{ +\donttest{ res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, cluster_dim = "member") # Example 4: Compute percentile in time -- GitLab From 501ceeee55ffd08ba38cfb48530e98acf5891866 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 12:46:41 +0100 Subject: [PATCH 11/13] more examples not tested to cran --- R/CST_EnsClustering.R | 3 ++- man/CST_EnsClustering.Rd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index 4373398c..ed14f870 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -85,10 +85,11 @@ #'} #' # Example 2: Cluster on members retaining 4 EOFs during #' # preliminary dimensional reduction +#'\donttest { #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction -#'\donttest{ +#' #' res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, #' cluster_dim = "member") #' # Example 4: Compute percentile in time diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index 19f89cfc..9cf2495b 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -101,10 +101,11 @@ PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, } # Example 2: Cluster on members retaining 4 EOFs during # preliminary dimensional reduction +\donttest { res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction -\donttest{ + res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, cluster_dim = "member") # Example 4: Compute percentile in time -- GitLab From 9e4356096b799bc2e40c9bc5763d0c0614d68d72 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 14:58:41 +0100 Subject: [PATCH 12/13] donttest example due elapsed time check --- R/CST_EnsClustering.R | 2 +- man/CST_EnsClustering.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index ed14f870..62d29244 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -85,7 +85,7 @@ #'} #' # Example 2: Cluster on members retaining 4 EOFs during #' # preliminary dimensional reduction -#'\donttest { +#'\donttest{ #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index 9cf2495b..c13bf205 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -101,7 +101,7 @@ PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, } # Example 2: Cluster on members retaining 4 EOFs during # preliminary dimensional reduction -\donttest { +\donttest{ res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction -- GitLab From e98811cd27a3aa69a2f3337c4d30c3bc8ca81237 Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 27 Nov 2019 18:21:09 +0100 Subject: [PATCH 13/13] buildignore update and dontest added --- .Rbuildignore | 1 + R/CST_QuantileMapping.R | 3 +-- man/CST_QuantileMapping.Rd | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 62a63bb4..fa596e70 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ ./.nc$ .*^(?!data)\.RData$ .*\.gitlab-ci.yml$ +^tests$ diff --git a/R/CST_QuantileMapping.R b/R/CST_QuantileMapping.R index d8e2ec73..25651241 100644 --- a/R/CST_QuantileMapping.R +++ b/R/CST_QuantileMapping.R @@ -43,12 +43,11 @@ #'obs <- list(data = obs) #'class(obs) <- 's2dv_cube' #'res <- CST_QuantileMapping(exp, obs, method = 'RQUANT') -#' +#'\donttest{ #'exp <- lonlat_data$exp #'obs <- lonlat_data$obs #'res <- CST_QuantileMapping(exp, obs) #' -#'\donttest{ #'data(obsprecip) #'data(modprecip) #'exp <- modprecip$MOSS[1:10000] diff --git a/man/CST_QuantileMapping.Rd b/man/CST_QuantileMapping.Rd index 577ff542..1c93843e 100644 --- a/man/CST_QuantileMapping.Rd +++ b/man/CST_QuantileMapping.Rd @@ -58,12 +58,11 @@ dim(obs) <- c(dataset = 1, member = 1, sdate = 5, ftime = 6 , obs <- list(data = obs) class(obs) <- 's2dv_cube' res <- CST_QuantileMapping(exp, obs, method = 'RQUANT') - +\donttest{ exp <- lonlat_data$exp obs <- lonlat_data$obs res <- CST_QuantileMapping(exp, obs) -\donttest{ data(obsprecip) data(modprecip) exp <- modprecip$MOSS[1:10000] -- GitLab