From 2fe5119b914159434f9b2c130f6182d5d966a2b3 Mon Sep 17 00:00:00 2001 From: Nadia Milders Date: Thu, 29 Aug 2024 16:03:28 +0200 Subject: [PATCH] including climatology when ref is null --- R/RMSSS.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/RMSSS.R b/R/RMSSS.R index c322c7f..e05872b 100644 --- a/R/RMSSS.R +++ b/R/RMSSS.R @@ -138,7 +138,9 @@ RMSSS <- function(exp, obs, ref = NULL, time_dim = 'sdate', dat_dim = NULL, stop("Parameter 'ref' must be a numeric array or number 0 or 1.") } } else { - ref <- 0 + ref <- MeanDims(data = obs, dims = time_dim, na.rm = TRUE, drop = TRUE) + ref <- InsertDim(data = ref, posdim = which(names(dim(exp))==time_dim), + lendim = as.numeric(dim(exp)[time_dim]), name = time_dim) } if (!is.array(ref)) { # 0 or 1 ref <- array(data = ref, dim = dim(exp)) @@ -322,8 +324,8 @@ RMSSS <- function(exp, obs, ref = NULL, time_dim = 'sdate', dat_dim = NULL, # ref: [sdate, (dat)] or NULL if (is.null(ref)) { - ref <- array(data = 0, dim = dim(obs)) - } else if (identical(ref, 0) | identical(ref, 1)) { + ref <- array(data = mean(obs), dim = dim(obs)) + } else if (is.numeric(ref) & length(ref)==1) { ref <- array(ref, dim = dim(exp)) } -- GitLab