diff --git a/Common/util_eddies.py b/Common/util_eddies.py index 734e18050531795fabdd4f250e1c6b97e3c49466..03782e4fa4a77006bc1800c47773c7e1a47c29a3 100644 --- a/Common/util_eddies.py +++ b/Common/util_eddies.py @@ -185,17 +185,20 @@ class SHPC_class: def comp_ishape(self, date, eddy_index, i_slice, orientation): """Compute the location in the shapefiles.""" - assert date >= self.d_init[i_slice] + ishape_last = self.get_ishape_last(i_slice, orientation) - if date == self.d_init[i_slice]: - ishape = eddy_index - 1 + if ishape_last is None: + ishape = None else: - # date > self.d_init[i_slice] - try: - ishape = self.get_ishape_last(i_slice, orientation)\ - [date - self.d_init[i_slice] - 1] + eddy_index - except TypeError: - ishape = None + 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 + else: + # k >= 1 + ishape = ishape_last[k - 1] + eddy_index return ishape