diff --git a/mlair/data_handler/data_handler_single_station.py b/mlair/data_handler/data_handler_single_station.py index 3392e41631fb395e95fc15b9199d81e1fd02121d..e184260a8bfe3095c59b8c957cae18c7d7815af3 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