diff --git a/NEWS.md b/NEWS.md index 3e625ed09e2933e7f4255ceef9fc1ad89e8af161..86f68cf453151690ec56fb6640686a3e4ee95db6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +### CSTools 3.1.0 +**Submission date to CRAN: XX-06-2020** + +- Fixes + + CST_Anomaly handles exp, obs or both. + + ### CSTools 3.0.0 **Submission date to CRAN: 10-02-2020** @@ -8,6 +15,7 @@ - Fixes + CST_Calibration handles missing values + BEI functions handle missing values + ### CSTools 2.0.0 **Submission date to CRAN: 25-11-2019** @@ -33,6 +41,7 @@ - Adding reference to S2S4E H2020 project into the DESCRIPTION file - Adding NEWS.md file + ### CSTools 1.0.1 **Release date on CRAN: 19-06-2019** diff --git a/R/CST_Anomaly.R b/R/CST_Anomaly.R index e76c46ab67164a77196460bf0e7dbb890d785819..c6de2ad1a697f9a54adba5254563835d2fe9de70 100644 --- a/R/CST_Anomaly.R +++ b/R/CST_Anomaly.R @@ -44,22 +44,28 @@ #'anom4 <- CST_Anomaly(exp = exp, obs = obs, cross = FALSE, memb = FALSE) #'str(anom4) #' +#'anom5 <- CST_Anomaly(lonlat_data$exp) +#' +#'anom6 <- CST_Anomaly(obs = lonlat_data$obs) +#' #'@seealso \code{\link[s2dverification]{Ano_CrossValid}}, \code{\link[s2dverification]{Clim}} and \code{\link{CST_Load}} #' #' #'@export CST_Anomaly <- function(exp = NULL, obs = NULL, cross = FALSE, memb = TRUE, dim_anom = 3) { - if (!inherits(exp, 's2dv_cube') || !inherits(obs, '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.") } - if (!is.null(obs) & dim(obs$data)['member'] != 1) { + if (!is.null(obs)) { + if (dim(obs$data)['member'] != 1) { stop("The length of the dimension 'member' in the component 'data' ", "of the parameter 'obs' must be equal to 1.") + } } - case_exp = case_obs = 0 if (is.null(exp) & is.null(obs)) { stop("One of the parameter 'exp' or 'obs' cannot be NULL.") @@ -75,6 +81,7 @@ CST_Anomaly <- function(exp = NULL, obs = NULL, cross = FALSE, memb = TRUE, dim_ warning("Parameter 'obs' is not provided and will be recycled.") } + if (!is.null(names(dim(exp$data))) & !is.null(names(dim(obs$data)))) { if (all(names(dim(exp$data)) %in% names(dim(obs$data)))) { dimnames <- names(dim(exp$data)) @@ -88,8 +95,8 @@ CST_Anomaly <- function(exp = NULL, obs = NULL, cross = FALSE, memb = TRUE, dim_ } dim_exp <- dim(exp$data) dim_obs <- dim(obs$data) + dimnames_data <- names(dim_exp) - if (dim_exp[dim_anom] == 1 | dim_obs[dim_anom] == 1) { stop("The length of dimension 'dim_anom' in label 'data' of the parameter ", "'exp' and 'obs' must be greater than 1.") diff --git a/man/CST_Anomaly.Rd b/man/CST_Anomaly.Rd index 07691ea7d7ff5a6105b0e0f4e53a9373d4fdccab..365cbf4615fe69382625ac7b25a94975024cd498 100644 --- a/man/CST_Anomaly.Rd +++ b/man/CST_Anomaly.Rd @@ -52,6 +52,10 @@ str(anom3) anom4 <- CST_Anomaly(exp = exp, obs = obs, cross = FALSE, memb = FALSE) str(anom4) +anom5 <- CST_Anomaly(lonlat_data$exp) + +anom6 <- CST_Anomaly(obs = lonlat_data$obs) + } \seealso{ \code{\link[s2dverification]{Ano_CrossValid}}, \code{\link[s2dverification]{Clim}} and \code{\link{CST_Load}}