From 1d5e31267ff0bfc8f4ad48893f678298812148d4 Mon Sep 17 00:00:00 2001
From: Felix Kleinert <f.kleinert@fz-juelich.de>
Date: Mon, 18 Oct 2021 17:00:18 +0200
Subject: [PATCH] add rmse plot for PlotSampleUncertaintyFromBootstrap

---
 mlair/plotting/postprocessing_plotting.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py
index 6d2d5ebd..8ed634b6 100644
--- a/mlair/plotting/postprocessing_plotting.py
+++ b/mlair/plotting/postprocessing_plotting.py
@@ -1004,6 +1004,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass):
     def __init__(self, data: xr.DataArray, plot_folder: str = ".", model_type_dim: str = "type",
                  error_measure: str = "mse", error_unit: str = None, dim_name_boots: str = 'boots'):
         super().__init__(plot_folder, "sample_uncertainty_from_bootstrap")
+        default_name = self.plot_name
         self.model_type_dim = model_type_dim
         self.error_measure = error_measure
         self.dim_name_boots = dim_name_boots
@@ -1011,9 +1012,16 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass):
         self.prepare_data(data)
         self._plot(orientation="v")
 
-        self.plot_name = self.plot_name + "_horizontal"
+        self.plot_name = default_name + "_horizontal"
         self._plot(orientation="h")
 
+        self._apply_root()
+
+        self.plot_name = default_name + "_sqrt"
+        self._plot(orientation="v")
+
+        self.plot_name = default_name + "_horizontal_sqrt"
+        self._plot(orientation="h")
 
         self._data_table = None
         self._n_boots = None
@@ -1022,6 +1030,11 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass):
         self._data_table = data.to_pandas()
         self._n_boots = self._data_table.shape[0]
 
+    def _apply_root(self):
+        self._data_table = np.sqrt(self._data_table)
+        self.error_measure = f"root {self.error_measure}"
+        self.error_unit = self.error_unit.replace("$^2$", "")
+
     def _plot(self, orientation: str = "v"):
         data_table = self._data_table
         n_boots = self._n_boots
@@ -1039,7 +1052,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass):
                     boxprops={'facecolor': 'none', 'edgecolor': 'k'},
                     width=.3, orient=orientation)
         if orientation == "v":
-            ax.set_ylabel(f"{self.error_measure}  (in {self.error_unit})")
+            ax.set_ylabel(f"{self.error_measure} (in {self.error_unit})")
             ax.set_xticklabels(ax.get_xticklabels(), rotation=45)
         elif orientation == "h":
             ax.set_xlabel(f"{self.error_measure}  (in {self.error_unit})")
-- 
GitLab