From a21535e36ca27ab656b2aee355f91a53513f9df0 Mon Sep 17 00:00:00 2001 From: "v.gramlich1" <v.gramlichfz-juelich.de> Date: Sat, 14 Aug 2021 13:56:08 +0200 Subject: [PATCH] Fixed the problem in _load_competitors in post_processing and postprocessing_plotting, reverted the workaround in statistics --- mlair/helpers/statistics.py | 3 ++- mlair/plotting/postprocessing_plotting.py | 11 ++++++++++- mlair/run_modules/post_processing.py | 11 +---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mlair/helpers/statistics.py b/mlair/helpers/statistics.py index b63cbe80..90f4a8c9 100644 --- a/mlair/helpers/statistics.py +++ b/mlair/helpers/statistics.py @@ -301,7 +301,7 @@ class SkillScores: observation_name=self.observation_name) for (first, second) in combinations] return skill_score - ''' + def climatological_skill_scores(self, internal_data: Data, forecast_name: str) -> xr.DataArray: """ Calculate climatological skill scores according to Murphy (1988). @@ -385,6 +385,7 @@ class SkillScores: external_data=external_data).values.flatten()) return skill_score + ''' def _climatological_skill_score(self, internal_data, observation_name, forecast_name, mu_type=1, external_data=None): diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 6801addb..b7c0366e 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -116,7 +116,16 @@ class PlotOversamplingContingency(AbstractPlotClass): except (FileNotFoundError, KeyError): logging.debug(f"No competitor found for combination '{station_name}' and '{competitor_name}'.") continue - return xr.concat(competing_predictions, "type") if len(competing_predictions) > 0 else None + if len(competing_predictions)==0: + return None + else: + comp_array = xr.concat(competing_predictions, "type") + if len(comp_array.coords[self.ahead_dim]) == self.window_lead_time: + return comp_array + else: + raise ValueError(f"Ahead dimensions of competitors do not match model." + f" Competitor ahead: {len(comp_array.coords[self.ahead_dim])}" + f" but window_lead_time is {self.window_lead_time}.") def _min_max_threshold(self): min_threshold = 0 diff --git a/mlair/run_modules/post_processing.py b/mlair/run_modules/post_processing.py index 4defc4d6..80d40a66 100644 --- a/mlair/run_modules/post_processing.py +++ b/mlair/run_modules/post_processing.py @@ -138,16 +138,7 @@ class PostProcessing(RunEnvironment): except (FileNotFoundError, KeyError): logging.debug(f"No competitor found for combination '{station_name}' and '{competitor_name}'.") continue - if len(competing_predictions)==0: - return None - else: - comp_array = xr.concat(competing_predictions, "type") - if len(comp_array.coords[self.ahead_dim]) == self.window_lead_time: - return comp_array - else: - raise ValueError(f"Ahead dimensions of competitors do not match model." - f" Competitor ahead: {len(comp_array.coords[self.ahead_dim])}" - f" but window_lead_time is {self.window_lead_time}.") + return xr.concat(competing_predictions, "type") if len(competing_predictions) > 0 else None def bootstrap_postprocessing(self, create_new_bootstraps: bool, _iter: int = 0, bootstrap_type="singleinput", bootstrap_method="shuffle") -> None: -- GitLab