From 4bc1679f09132013032c212af2df134a99134410 Mon Sep 17 00:00:00 2001 From: Falco Weichselbaum <f.weichselbaum@fz-juelich.de> Date: Mon, 23 Aug 2021 14:06:01 +0200 Subject: [PATCH] ValueErrors raised when timeseries (history, label or observation) only consists of NaN --- mlair/data_handler/data_handler_single_station.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mlair/data_handler/data_handler_single_station.py b/mlair/data_handler/data_handler_single_station.py index 3392e416..e184260a 100644 --- a/mlair/data_handler/data_handler_single_station.py +++ b/mlair/data_handler/data_handler_single_station.py @@ -586,9 +586,16 @@ class DataHandlerSingleStation(AbstractDataHandler): non_nan_history = self.history.dropna(dim=dim) non_nan_label = self.label.dropna(dim=dim) non_nan_observation = self.observation.dropna(dim=dim) + if non_nan_label.shape[2] == 0: + raise ValueError(f'self.label consist of NaNs only - station {self.station} is therefore dropped') + if non_nan_history.shape[2] == 0: + raise ValueError(f'self.history consist of NaNs only - station {self.station} is therefore dropped') + if non_nan_observation.shape[2] == 0: + raise ValueError(f'self.observation consist of NaNs only - station {self.station} is therefore dropped') intersect = reduce(np.intersect1d, (non_nan_history.coords[dim].values, non_nan_label.coords[dim].values, non_nan_observation.coords[dim].values)) + if len(intersect) < max(self.min_length, 1): self.history = None self.label = None -- GitLab