From 871ee33af02c27a2f3a89a5942d5cd446e4a9019 Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 12 Sep 2023 15:59:48 +0200 Subject: [PATCH] Make brks and cols be NULLif all data is NA --- modules/Visualization/R/plot_ensemble_mean.R | 13 ++- recipes/tests/recipe_seasonal_vizNA.yml | 85 ++++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 recipes/tests/recipe_seasonal_vizNA.yml diff --git a/modules/Visualization/R/plot_ensemble_mean.R b/modules/Visualization/R/plot_ensemble_mean.R index 07e35706..f343b1e1 100644 --- a/modules/Visualization/R/plot_ensemble_mean.R +++ b/modules/Visualization/R/plot_ensemble_mean.R @@ -53,10 +53,17 @@ plot_ensemble_mean <- function(recipe, fcst, outdir) { ugly_intervals <- seq(-max_value, max_value, max_value/20) brks <- pretty(ugly_intervals, n = 12, min.n = 8) } else { - brks <- pretty(range(var_ens_mean, na.rm = T), n = 15, min.n = 8) + if (all(is.na(var_ens_mean))) { + brks <- NULL + } else { + brks <- pretty(range(var_ens_mean, na.rm = T), n = 15, min.n = 8) + } + } + if (is.null(brks)) { + cols <- NULL + } else { + cols <- grDevices::hcl.colors(length(brks) - 1, palette, rev = rev) } - cols <- grDevices::hcl.colors(length(brks) - 1, palette, rev = rev) - for (i_syear in start_date) { if (length(start_date) == 1) { i_var_ens_mean <- var_ens_mean[which(start_date == i_syear), , , ] diff --git a/recipes/tests/recipe_seasonal_vizNA.yml b/recipes/tests/recipe_seasonal_vizNA.yml new file mode 100644 index 00000000..fac86933 --- /dev/null +++ b/recipes/tests/recipe_seasonal_vizNA.yml @@ -0,0 +1,85 @@ +################################################################################ +## RECIPE DESCRIPTION +################################################################################ + +Description: + Author: An-Chi Ho + Info: Test Visualization module to handle var is all NA + +################################################################################ +## ANALYSIS CONFIGURATION +################################################################################ + +Analysis: + Horizon: Seasonal + Variables: + name: tas + freq: monthly_mean + Datasets: + System: + name: [ECMWF-SEAS5] + Multimodel: no + Reference: + name: ERA5 + Time: + sdate: + - '1101' + fcst_year: '2020' + hcst_start: '2014' + hcst_end: '2016' + ftime_min: 1 + ftime_max: 2 + Region: + latmin: 0 + latmax: 3 + lonmin: 0 + lonmax: 2 + Regrid: + method: bilinear + type: 'r180x90' + Workflow: + Anomalies: + compute: no + cross_validation: no + save: 'none' + Calibration: + method: raw + save: 'none' + Skill: + metric: RPSS, CRPSS + save: 'none' + Probabilities: + percentiles: [[1/3, 2/3], [1/10, 9/10], [1/4, 2/4, 3/4]] + save: 'none' + Visualization: + plots: forecast_ensemble_mean + multi_panel: no + projection: cylindrical_equidistant + Indicators: + index: no + ncores: 8 + remove_NAs: yes + Output_format: S2S4E + +################################################################################ +## Run CONFIGURATION +################################################################################ +Run: + Loglevel: INFO + Terminal: yes + filesystem: esarchive + output_dir: /esarchive/scratch/aho/tmp/auto-s2s_outputs + code_dir: /esarchive/scratch/aho/git/auto-s2s/ + autosubmit: no + # fill only if using autosubmit + auto_conf: + script: /esarchive/scratch/vagudets/repos/auto-s2s/example_scripts/test_parallel_workflow.R + expid: # autosubmit experiment ID + hpc_user: bsc32762 # your hpc username + wallclock: 04:00 # hh:mm + processors_per_job: 8 # use ncores parameter? + platform: nord3v2 # make this constant? + email_notifications: yes # enable/disable email notifications + email_address: victoria.agudetse@bsc.es # email address for notifications + notify_completed: no # notify me by email when a job finishes + notify_failed: yes # notify me by email when a job fails -- GitLab