From 539ee8e044e67904416921e8aa42dde8f0afb90c Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Thu, 2 Sep 2021 18:21:22 +0200
Subject: [PATCH] Define `cell_mask` once if not `filter_ghosts`

---
 Convert_Matlab/inst_eddies_v6.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Convert_Matlab/inst_eddies_v6.py b/Convert_Matlab/inst_eddies_v6.py
index 33d796a2..82c2b5ca 100755
--- a/Convert_Matlab/inst_eddies_v6.py
+++ b/Convert_Matlab/inst_eddies_v6.py
@@ -157,6 +157,9 @@ if filter_ghosts:
     with open("node_id_param.json") as f: node_id_param = json.load(f)
     n1 = (d - node_id_param["d_init"]) * node_id_param["e_overestim"] + 1
     # (same starting node id for both orientations)
+else:
+    cell_mask = itertools.repeat(False) # no ghost
+
 # There are two factories, one for cyclones and one for anticyclones:
 factories = [dict(writers = {}, cell_name = "Anticyclonic_Cell",
                   cyclone = False, SHPC = "SHPC_anti", id = "id_anti_cell"),
@@ -201,8 +204,6 @@ while True:
                     = id_array.compressed() == np.arange(n1, n1 + n_eddies)
                 assert np.all(equal_range)
                 cell_mask = id_array.mask
-            else:
-                cell_mask = itertools.repeat(False) # no ghost
                 
             write_to_shp(factory["writers"], factory["cyclone"], d,
                          matlab_data[factory["cell_name"]], matlab_data["X"],
-- 
GitLab