diff --git a/modules/Visualization/Visualization.R b/modules/Visualization/Visualization.R index 7df72086c6338f30e4e7431dde8c9c70c2c066c4..1f6e836de798a6aff8c5459566fa132af516eddd 100644 --- a/modules/Visualization/Visualization.R +++ b/modules/Visualization/Visualization.R @@ -26,21 +26,36 @@ 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, warn them. + } else { if (is.list(output_conf)) { - 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 } } + + # 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) {