From 1215576ee0d14d1ff2679ef88829fbfcdf90ff12 Mon Sep 17 00:00:00 2001
From: leufen1 <l.leufen@fz-juelich.de>
Date: Thu, 6 May 2021 15:09:42 +0200
Subject: [PATCH] add exception if filter input plot wasn't successful

---
 mlair/helpers/filter.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/mlair/helpers/filter.py b/mlair/helpers/filter.py
index 30e81320..5d2c440d 100644
--- a/mlair/helpers/filter.py
+++ b/mlair/helpers/filter.py
@@ -274,11 +274,15 @@ class ClimateFIRFilter:
 
         # plot
         if self.plot_path is not None:
-            pos = 720
-            filter_example = filter_input_data.isel({time_dim: pos})
-            t0 = filter_example.coords[time_dim].values
-            t_slice = filter_input_data.isel({time_dim: slice(pos - length, pos + length + 1)}).coords[time_dim].values
-            self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, plot_index)
+            try:
+                pos = 720
+                filter_example = filter_input_data.isel({time_dim: pos})
+                t0 = filter_example.coords[time_dim].values
+                t_slice = filter_input_data.isel({time_dim: slice(pos - length, pos + length + 1)}).coords[
+                    time_dim].values
+                self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, plot_index)
+            except IndexError:
+                pass
 
         # select only values at tmp dimension 0 at each point in time
         return filt.sel({new_dim: 0}, drop=True), h, apriori
-- 
GitLab