From 5fb00673f540293a6930e991bbc1602cc7a546f7 Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Tue, 12 Sep 2023 16:28:02 +0200 Subject: [PATCH] Replace '[' with ClimProjDiags::Subset() to avoid eliminating time dimension when the length is one --- modules/Visualization/R/plot_ensemble_mean.R | 12 +++++++++--- .../Visualization/R/plot_most_likely_terciles_map.R | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/Visualization/R/plot_ensemble_mean.R b/modules/Visualization/R/plot_ensemble_mean.R index 07e35706..61fdb783 100644 --- a/modules/Visualization/R/plot_ensemble_mean.R +++ b/modules/Visualization/R/plot_ensemble_mean.R @@ -59,10 +59,16 @@ plot_ensemble_mean <- function(recipe, fcst, outdir) { for (i_syear in start_date) { if (length(start_date) == 1) { - i_var_ens_mean <- var_ens_mean[which(start_date == i_syear), , , ] + i_var_ens_mean <- ClimProjDiags::Subset(var_ens_mean, + along = c("syear"), + indices = which(start_date == i_syear), + drop = 'selected') outfile <- paste0(outdir[[var]], "forecast_ensemble_mean-", start_date) } else { - i_var_ens_mean <- var_ens_mean[which(start_date == i_syear), , , ] + i_var_ens_mean <- ClimProjDiags::Subset(var_ens_mean, + along = c("syear"), + indices = which(start_date == i_syear), + drop = 'selected') outfile <- paste0(outdir[[var]], "forecast_ensemble_mean-", i_syear) } toptitle <- paste0(system_name, " / ", str_to_title(var_long_name), @@ -147,5 +153,5 @@ plot_ensemble_mean <- function(recipe, fcst, outdir) { } } info(recipe$Run$logger, - "##### SKILL METRIC PLOTS SAVED TO OUTPUT DIRECTORY #####") + "##### FORECAST ENSEMBLE MEAN PLOT SAVED TO OUTPUT DIRECTORY #####") } diff --git a/modules/Visualization/R/plot_most_likely_terciles_map.R b/modules/Visualization/R/plot_most_likely_terciles_map.R index 4952a90e..f2ef9575 100644 --- a/modules/Visualization/R/plot_most_likely_terciles_map.R +++ b/modules/Visualization/R/plot_most_likely_terciles_map.R @@ -68,7 +68,10 @@ plot_most_likely_terciles <- function(recipe, c("syear", "time", "bin", "longitude", "latitude")) for (i_syear in start_date) { # Define name of output file and titles - i_var_probs <- var_probs[which(start_date == i_syear), , , , ] + i_var_probs <- ClimProjDiags::Subset(var_probs, + along = c("syear"), + indices = which(start_date == i_syear), + drop = 'selected') outfile <- paste0(outdir[[var]], "forecast_most_likely_tercile-", i_syear) # Mask if (!is.null(mask)) { -- GitLab