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

Compute `i_slice` in `comp_ishape`

Compute `i_slice` in `comp_ishape` if `i_slice` is None. Add default
value of None for dummy argument `i_slice`.
parent 6fc7f97e
No related branches found
No related tags found
No related merge requests found
...@@ -199,14 +199,18 @@ class SHPC_class: ...@@ -199,14 +199,18 @@ class SHPC_class:
assert i_slice >= 0 assert i_slice >= 0
return i_slice return i_slice
def comp_ishape(self, date, eddy_index, orientation, i_slice): def comp_ishape(self, date, eddy_index, orientation, i_slice = None):
"""Compute the location in the shapefiles. Returns None if ishape_last """Compute the location in the shapefiles: return `(i_slice, ishape)`.
was not found and could not be created. Crashes if date is not Compute i_slice if i_slice is None.
in i_slice. Returns None if eddy_index is greater than the
Returns None if ishape_last was not found and could not be
created. Crashes if i_slice is not None and date is not in
i_slice. Returns None if eddy_index is greater than the
maximum value. maximum value.
""" """
if i_slice is None: i_slice = self.get_slice(date)
ishape_last = self.get_ishape_last(i_slice, orientation) ishape_last = self.get_ishape_last(i_slice, orientation)
if ishape_last is None: if ishape_last is None:
...@@ -225,15 +229,15 @@ class SHPC_class: ...@@ -225,15 +229,15 @@ class SHPC_class:
else: else:
ishape = None ishape = None
return ishape return i_slice, ishape
def ishape_range(self, date, i_slice, orientation): def ishape_range(self, date, i_slice, orientation):
"""Returns an empty list if ishape_last was not found and could not be """Returns an empty list if ishape_last was not found and could not be
created. Crashes if date is not in i_slice. created. Crashes if i_slice is not None and date is not in i_slice.
""" """
ishape_start = self.comp_ishape(date, 1, orientation, i_slice) i_slice, ishape_start = self.comp_ishape(date, 1, orientation, i_slice)
if ishape_start is None: if ishape_start is None:
return [] return []
......
...@@ -40,7 +40,7 @@ else: ...@@ -40,7 +40,7 @@ else:
assert eddy_index >= 1 assert eddy_index >= 1
i_slice = SHPC.get_slice(date) i_slice = SHPC.get_slice(date)
ishape = SHPC.comp_ishape(date, eddy_index, args.orientation, i_slice) i_slice, ishape = SHPC.comp_ishape(date, eddy_index, args.orientation, i_slice)
print("ishape =", ishape) print("ishape =", ishape)
......
...@@ -24,8 +24,8 @@ print(f"{date_head=}") ...@@ -24,8 +24,8 @@ print(f"{date_head=}")
print(f"{date_tail=}") print(f"{date_tail=}")
i_slice_head = SHPC.get_slice(date_head) i_slice_head = SHPC.get_slice(date_head)
i_slice_tail = SHPC.get_slice(date_tail) i_slice_tail = SHPC.get_slice(date_tail)
ishape_head = SHPC.comp_ishape(date_head,eddy_i_head,orientation,i_slice_head) i_slice_head, ishape_head = SHPC.comp_ishape(date_head,eddy_i_head,orientation,i_slice_head)
ishape_tail = SHPC.comp_ishape(date_tail,eddy_i_tail,orientation,i_slice_tail) i_slice_tail, ishape_tail = SHPC.comp_ishape(date_tail,eddy_i_tail,orientation,i_slice_tail)
fig = plt.figure() fig = plt.figure()
projection = ccrs.PlateCarree() projection = ccrs.PlateCarree()
ax = plt.axes(projection = projection) ax = plt.axes(projection = projection)
......
...@@ -46,7 +46,7 @@ def set_attribute(G, SHPC, orientation): ...@@ -46,7 +46,7 @@ def set_attribute(G, SHPC, orientation):
n, G.graph["e_overestim"] n, G.graph["e_overestim"]
) )
i_slice = SHPC.get_slice(date_index) i_slice = SHPC.get_slice(date_index)
ishape = SHPC.comp_ishape( i_slice, ishape = SHPC.comp_ishape(
date_index, eddy_index, orientation, i_slice date_index, eddy_index, orientation, i_slice
) )
reader = SHPC.get_reader(i_slice, orientation, "extremum") reader = SHPC.get_reader(i_slice, orientation, "extremum")
......
...@@ -26,7 +26,7 @@ def get_extr_coord(traj, e_overestim, SHPC, orientation): ...@@ -26,7 +26,7 @@ def get_extr_coord(traj, e_overestim, SHPC, orientation):
node, e_overestim node, e_overestim
) )
i_slice = SHPC.get_slice(date_index) i_slice = SHPC.get_slice(date_index)
ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) i_slice, ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice)
shape = SHPC.get_reader(i_slice, orientation, layer="extremum").shape( shape = SHPC.get_reader(i_slice, orientation, layer="extremum").shape(
ishape ishape
) )
......
...@@ -78,7 +78,7 @@ def node_to_prop(node_list, e_overestim, SHPC, orientation): ...@@ -78,7 +78,7 @@ def node_to_prop(node_list, e_overestim, SHPC, orientation):
for n in node_list: for n in node_list:
date_index, eddy_index = util_eddies.node_to_date_eddy(n, e_overestim) date_index, eddy_index = util_eddies.node_to_date_eddy(n, e_overestim)
i_slice = SHPC.get_slice(date_index) i_slice = SHPC.get_slice(date_index)
ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice) i_slice, ishape = SHPC.comp_ishape(date_index, eddy_index, orientation, i_slice)
shapeRec = SHPC.get_reader( shapeRec = SHPC.get_reader(
i_slice, orientation, "extremum" i_slice, orientation, "extremum"
).shapeRecord(ishape) ).shapeRecord(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