From 336e261cc578a4caf876b201fbb0b739092f33fb Mon Sep 17 00:00:00 2001
From: Felix Kleinert <f.kleinert@fz-juelich.de>
Date: Tue, 1 Feb 2022 08:12:39 +0100
Subject: [PATCH] store sector skill scores to file

---
 mlair/plotting/postprocessing_plotting.py | 2 +-
 mlair/run_modules/post_processing.py      | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py
index ac3007a2..a4768d96 100644
--- a/mlair/plotting/postprocessing_plotting.py
+++ b/mlair/plotting/postprocessing_plotting.py
@@ -682,7 +682,7 @@ class PlotSectorialSkillScore(AbstractPlotClass):  # pragma: no cover
         try:
             lower = np.max([-limit, np.min([0, helpers.float_round(data["data"].min(), 2) - 0.1])])
             upper = np.min([limit, helpers.float_round(data["data"].max(), 2) + 0.1])
-        except ValueError:
+        except Exception:
             lower, upper = (-limit, limit)
         return lower, upper
 
diff --git a/mlair/run_modules/post_processing.py b/mlair/run_modules/post_processing.py
index 56a7ab53..04bcbf75 100644
--- a/mlair/run_modules/post_processing.py
+++ b/mlair/run_modules/post_processing.py
@@ -118,6 +118,10 @@ class PostProcessing(RunEnvironment):
             self.skill_score_per_sector = self.calculate_error_metrics_based_on_upstream_wind_dir()
         except Exception as e:
             logging.info(f"Can not process upsstream wind sectors due to: {e}")
+        if self.skill_score_per_sector is not None:
+            path_sector_skill_scores = os.path.join(self.data_store.get("experiment_path"),
+                                                    f"data/skill_scores_per_sector_test.nc")
+            self.skill_score_per_sector.to_netcdf(path_sector_skill_scores)
 
         # calculate error metrics on test data
         self.calculate_test_score()
-- 
GitLab