Skip to content
Snippets Groups Projects
Commit 5444de1e authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Check that `eddy_index` is in the right range

In function `comp_ishape`, check that `eddy_index` is in the right
range.
parent 90bc2a28
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment