From 41c8c5ccfbef6328f9141709b4d8b0abf9d0cb70 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Thu, 11 Mar 2021 22:05:12 +0100
Subject: [PATCH] Do not crash on missing SHPC directory

Do not crash on missing SHPC directory for interpolated
eddies. Motivation: when we call `read_eddy_graph` from
`plot_traj.py`, we just try to read data on interpolated eddies.
---
 Analysis/report_graph.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Analysis/report_graph.py b/Analysis/report_graph.py
index 734ee5a3..85ddb3dd 100755
--- a/Analysis/report_graph.py
+++ b/Analysis/report_graph.py
@@ -33,14 +33,18 @@ def read_eddy_graph(edgelist, shp_tr_dir = None, read_interp = True):
                 G.add_edge((k1, i1), (k2, i2), weight = weight)
 
         if read_interp:
-            # Read and set attributes of interpolated eddies:
+            # Try to read and set attributes of interpolated eddies:
 
             # Assuming that the directory containing the interpolated
             # eddies is in the same location as edgelist:
             extremum = path.join(path.dirname(edgelist), "SHP_triplet",
                                  "extremum")
 
-            set_attribute(G, extremum)
+            if os.access(extremum, os.R_OK):
+                set_attribute(G, extremum)
+            else:
+                print("Trying to read data on interpolated eddies but ",
+                      f"{extremum} is not readable")
 
         if shp_tr_dir is not None:
             # Read and set attributes of Visible eddies:
-- 
GitLab