From f4f8e571d12c3a493548e1ec14a628f9c8649609 Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Wed, 7 Jun 2023 12:38:18 +0200
Subject: [PATCH] only copy nature if it exists

---
 dartwrf/assim_synth_obs.py | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/dartwrf/assim_synth_obs.py b/dartwrf/assim_synth_obs.py
index fdb55ca..17c62c9 100755
--- a/dartwrf/assim_synth_obs.py
+++ b/dartwrf/assim_synth_obs.py
@@ -92,19 +92,15 @@ def prepare_nature_dart(time):
         time (dt.datetime): Time at which observations will be made
     """
 
-    try:
-        f_wrfout_nature = time.strftime(exp.nature+'/'+wrfout_format)
-        os.path.exists(f_wrfout_nature)
-    except:  # if nature is not available due to any reason
+    f_wrfout_nature = time.strftime(exp.nature+'/'+wrfout_format)
+    if os.path.exists(f_wrfout_nature):
+        print("linking nature to DART & georeferencing")
+        shutil.copy(f_wrfout_nature, cluster.dartrundir + "/wrfout_d01")
+        print("linked", f_wrfout_nature, "to", cluster.dartrundir + "/wrfout_d01")
+
+        wrfout_add_geo.run(cluster.geo_em, cluster.dartrundir + "/wrfout_d01")
+    else:  # if nature is not available due to any reason
         print('-> has no nature, not copying nature')
-        return
-
-    print("linking nature to DART & georeferencing")
-    shutil.copy(f_wrfout_nature, cluster.dartrundir + "/wrfout_d01")
-    print("linked", f_wrfout_nature, "to", cluster.dartrundir + "/wrfout_d01")
-
-    wrfout_add_geo.run(cluster.geo_em, cluster.dartrundir + "/wrfout_d01")
-
 
 def prepare_prior_ensemble(assim_time, prior_init_time, prior_valid_time, prior_path_exp):
     """Prepares DART files for running filter
-- 
GitLab