diff --git a/Common/util_eddies.py b/Common/util_eddies.py index a89e5a702afb0dc26c76d6193dadfa9df78a8c86..1ebff2464ed266c0b5421832e573a939584e71b3 100644 --- a/Common/util_eddies.py +++ b/Common/util_eddies.py @@ -185,7 +185,8 @@ class SHPC_class: def comp_ishape(self, date, eddy_index, i_slice, orientation): """Compute the location in the shapefiles. Returns None if ishape_last was not found and could not be created. Crashes if date is not - in i_slice. Crashes if eddy_index is out of range. + in i_slice. Returns None if eddy_index is greater than the + maximum value. """ @@ -196,13 +197,16 @@ class SHPC_class: else: k = date - self.d_init[i_slice] assert k >= 0 - assert 1 <= eddy_index <= self._e_max[i_slice][orientation][k] - - if k == 0: - ishape = eddy_index - 1 + assert 1 <= eddy_index + + if eddy_index <= self._e_max[i_slice][orientation][k]: + if k == 0: + ishape = eddy_index - 1 + else: + # k >= 1 + ishape = ishape_last[k - 1] + eddy_index else: - # k >= 1 - ishape = ishape_last[k - 1] + eddy_index + ishape = None return ishape