From a8e695daea619c2ef0aa044873c44c7ba5d958af Mon Sep 17 00:00:00 2001 From: leufen1 <l.leufen@fz-juelich.de> Date: Wed, 19 Jan 2022 09:42:16 +0100 Subject: [PATCH] assure variable order in input_data --- .coveragerc | 3 +++ mlair/data_handler/data_handler_mixed_sampling.py | 5 ++++- mlair/data_handler/data_handler_single_station.py | 2 +- mlair/data_handler/data_handler_with_filter.py | 5 +++-- mlair/plotting/abstract_plot_class.py | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index 69c1dcd3..bc1fedc1 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,9 @@ # .coveragerc to control coverage.py [run] branch = True +omit = + # do not test keras legacy + mlair/keras_legacy [report] diff --git a/mlair/data_handler/data_handler_mixed_sampling.py b/mlair/data_handler/data_handler_mixed_sampling.py index e5e95684..8633c647 100644 --- a/mlair/data_handler/data_handler_mixed_sampling.py +++ b/mlair/data_handler/data_handler_mixed_sampling.py @@ -363,7 +363,10 @@ class DataHandlerMixedSamplingWithClimateAndFirFilter(DataHandlerMixedSamplingWi if len(meteo_vars) > 0: if cls.data_handler_fir_pos is None: if "extend_length_opts" in kwargs: - cls.data_handler_fir_pos = 1 # use slower fir version with climate estimate + if isinstance(kwargs["extend_length_opts"], dict) and "meteo" not in kwargs["extend_length_opts"].keys(): + cls.data_handler_fir_pos = 0 # use faster fir version without climate estimate + else: + cls.data_handler_fir_pos = 1 # use slower fir version with climate estimate else: cls.data_handler_fir_pos = 0 # use faster fir version without climate estimate sp_keys = {k: copy.deepcopy(kwargs[k]) for k in cls.data_handler_fir[cls.data_handler_fir_pos].requirements() if k in kwargs} diff --git a/mlair/data_handler/data_handler_single_station.py b/mlair/data_handler/data_handler_single_station.py index 13092a94..038851d0 100644 --- a/mlair/data_handler/data_handler_single_station.py +++ b/mlair/data_handler/data_handler_single_station.py @@ -113,7 +113,7 @@ class DataHandlerSingleStation(AbstractDataHandler): # internal self._data: xr.DataArray = None # loaded raw data self.meta = None - self.variables = list(statistics_per_var.keys()) if variables is None else variables + self.variables = sorted(list(statistics_per_var.keys())) if variables is None else variables self.history = None self.label = None self.observation = None diff --git a/mlair/data_handler/data_handler_with_filter.py b/mlair/data_handler/data_handler_with_filter.py index 73afc778..997ecbf5 100644 --- a/mlair/data_handler/data_handler_with_filter.py +++ b/mlair/data_handler/data_handler_with_filter.py @@ -197,7 +197,8 @@ class DataHandlerFirFilterSingleStation(DataHandlerFilterSingleStation): plot_path=self.plot_path, plot_dates=self.plot_dates) self.fir_coeff = fir.filter_coefficients filter_data = fir.filtered_data - self.input_data = xr.concat(filter_data, pd.Index(self.create_filter_index(), name=self.filter_dim)) + input_data = xr.concat(filter_data, pd.Index(self.create_filter_index(), name=self.filter_dim)) + self.input_data = input_data.sel({self.target_dim: self.variables}) # this is just a code snippet to check the results of the kz filter # import matplotlib # matplotlib.use("TkAgg") @@ -386,7 +387,7 @@ class DataHandlerClimateFirFilterSingleStation(DataHandlerFirFilterSingleStation input_data = xr.concat(climate_filter_data, pd.Index(self.create_filter_index(add_unfiltered_index=False), name=self.filter_dim)) - self.input_data = input_data + self.input_data = input_data.sel({self.target_dim: self.variables}) # this is just a code snippet to check the results of the filter # import matplotlib diff --git a/mlair/plotting/abstract_plot_class.py b/mlair/plotting/abstract_plot_class.py index 7a91c226..21e5d941 100644 --- a/mlair/plotting/abstract_plot_class.py +++ b/mlair/plotting/abstract_plot_class.py @@ -8,7 +8,7 @@ import os from matplotlib import pyplot as plt -class AbstractPlotClass: +class AbstractPlotClass: # pragma: no cover """ Abstract class for all plotting routines to unify plot workflow. -- GitLab