From 4471398ddc70f0692406f558f047ce085b11fdcd Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Tue, 28 May 2024 00:47:06 +0200
Subject: [PATCH] catch indexerror

---
 dartwrf/assimilate.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dartwrf/assimilate.py b/dartwrf/assimilate.py
index 9f82616..275ce2b 100755
--- a/dartwrf/assimilate.py
+++ b/dartwrf/assimilate.py
@@ -31,7 +31,10 @@ def _find_nature(time):
     """
     glob_pattern = time.strftime(exp.nature_wrfout_pattern)  # replace time in pattern
     print('searching for nature in pattern:', glob_pattern)
-    f_nat = glob.glob(glob_pattern)[0]  # find the nature wrfout-file
+    try:
+        f_nat = glob.glob(glob_pattern)[0]  # find the nature wrfout-file
+    except IndexError:
+        raise IOError("no nature found with pattern "+glob_pattern)
 
     # check user input
     if not 'wrfout' in f_nat.split('/')[-1]:
-- 
GitLab