From b0aa47627639bf0afc03e5408c27d9f1aa35bbe6 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 13 May 2025 12:41:30 +0200 Subject: [PATCH] Update 'prob_thresholds' documentation and checks in R/RPSS.R --- R/RPSS.R | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/R/RPSS.R b/R/RPSS.R index 76c0dba..5c7006c 100644 --- a/R/RPSS.R +++ b/R/RPSS.R @@ -50,7 +50,12 @@ #' The default value is NULL. #'@param prob_thresholds A numeric vector of the relative thresholds (from 0 to #' 1) between the categories. The default value is c(1/3, 2/3), which -#' corresponds to tercile equiprobable categories. +#' corresponds to tercile equiprobable categories. When the inputs are +#' ensemble members ('cat_dim' is NULL), these thresholds are used to compute +#' category probabilities. If 'ref' is NULL, the thresholds are also used to +#' compute the reference forecast ('clim_probs'), even when 'exp' and 'obs' are +#' already given as probabilities. If 'ref' is provided and the inputs are +#' probabilities, 'prob_thresholds' is ignored. #'@param indices_for_clim A vector of the indices to be taken along 'time_dim' #' for computing the thresholds between the probabilistic categories. If NULL, #' the whole period is used. The default value is NULL. @@ -252,9 +257,11 @@ RPSS <- function(exp, obs, ref = NULL, time_dim = 'sdate', memb_dim = 'member', } } ## prob_thresholds - if (!is.numeric(prob_thresholds) | !is.vector(prob_thresholds) | - any(prob_thresholds <= 0) | any(prob_thresholds >= 1)) { - stop("Parameter 'prob_thresholds' must be a numeric vector between 0 and 1.") + if (is.null(cat_dim) || (!is.null(cat_dim) && is.null(ref))) { + if (!is.numeric(prob_thresholds) | !is.vector(prob_thresholds) | + any(prob_thresholds <= 0) | any(prob_thresholds >= 1)) { + stop("Parameter 'prob_thresholds' must be a numeric vector between 0 and 1.") + } } ## indices_for_clim if (is.null(indices_for_clim)) { -- GitLab