From 137279d9abe7730252e98ceb7455153d14057185 Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Thu, 21 Sep 2023 11:00:17 +0200 Subject: [PATCH 1/2] Modify output configuration logic in Visualization module --- modules/Visualization/Visualization.R | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/Visualization/Visualization.R b/modules/Visualization/Visualization.R index 7df72086..eedc1c54 100644 --- a/modules/Visualization/Visualization.R +++ b/modules/Visualization/Visualization.R @@ -26,21 +26,30 @@ Visualization <- function(recipe, # s2dv_cube objects # skill_metrics: list of arrays containing the computed skill metrics # significance: Bool. Whether to include significance dots where applicable + + # Try to set default configuration if not specified by user if (is.null(output_conf) && !is.null(recipe$Analysis$Region$name)) { output_conf <- read_yaml("modules/Visualization/output_size.yml", eval.exp = TRUE)$region - output_conf <- output_conf[[recipe$Analysis$Region$name]] - if (is.null(output_conf)) { - stop("Region not found in the ouput_conf file") # warning? + if (recipe$Analysis$Region$name %in% names(output_conf)) { + output_conf <- output_conf[[recipe$Analysis$Region$name]] + } else { + warn(recipe$Run$logger, + paste0("The region name is not found in the 'output_conf' file. ", + "The default plot settings will be used.")) + output_conf <- NULL } - } else{ + ## If the user chooses to specify the configuration... what? + } else { if (is.list(output_conf)) { + ## What does this warning mean? warning("Shape of the list of configuration?") } } + + # Get plot types and create output directories plots <- strsplit(recipe$Analysis$Workflow$Visualization$plots, ", | |,")[[1]] recipe$Run$output_dir <- paste0(recipe$Run$output_dir, "/plots/") - ## TODO: Sort this out outdir <- get_dir(recipe = recipe, variable = data$hcst$attrs$Variable$varName) for (directory in outdir) { -- GitLab From 8c166497141538f18a28e5e4bde4bbeb67a5a9e9 Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Tue, 26 Sep 2023 12:19:50 +0200 Subject: [PATCH 2/2] Refine warnings about output_conf --- modules/Visualization/Visualization.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/Visualization/Visualization.R b/modules/Visualization/Visualization.R index eedc1c54..1f6e836d 100644 --- a/modules/Visualization/Visualization.R +++ b/modules/Visualization/Visualization.R @@ -39,11 +39,17 @@ Visualization <- function(recipe, "The default plot settings will be used.")) output_conf <- NULL } - ## If the user chooses to specify the configuration... what? + # If the user chooses to specify the configuration, warn them. } else { if (is.list(output_conf)) { - ## What does this warning mean? - warning("Shape of the list of configuration?") + warning(paste0("Parameter 'output_conf' should be a list matching the ", + "parameters of the requested plotting function, i.e. ", + "PlotEquiMap, PlotRobinson or PlotLayout. There could be ", + "plotting erros if the list is incomplete.")) + } else { + warning(paste("Parameter 'output_conf' should be a list.", + "Using default configuration.")) + output_conf <- NULL } } -- GitLab