diff --git a/mlair/helpers/filter.py b/mlair/helpers/filter.py index 247c4fc9c7c6d57d721c1d0895cc8c719b1bd4a5..5fc3df951ed5dec9e94ed7d34d8dc02bafddf262 100644 --- a/mlair/helpers/filter.py +++ b/mlair/helpers/filter.py @@ -214,6 +214,7 @@ class ClimateFIRFilter(FIRFilter): h = [] if self.sel_opts is not None: self.sel_opts = self.sel_opts if isinstance(self.sel_opts, dict) else {self.time_dim: self.sel_opts} + self._check_sel_opts() sampling = {1: "1d", 24: "1H"}.get(int(self.fs)) logging.debug(f"{self.display_name}: create diurnal_anomalies") if self.apriori_diurnal is True and sampling == "1H": @@ -303,6 +304,10 @@ class ClimateFIRFilter(FIRFilter): except Exception as e: logging.info(f"Could not plot climate fir filter due to following reason:\n{e}") + def _check_sel_opts(self): + if len(self.data.sel(**self.sel_opts).coords[self.time_dim]) == 0: + raise ValueError(f"Abort {self.__class__.__name__} as no data is available after applying sel_opts to data") + @staticmethod def _next_order(order: list, minimum_length: Union[int, None], pos: int, window: Union[str, tuple]) -> int: next_order = 0