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

Define functions `search_beg` and `search_end`

Preparing for generalization of these functions.
parent 201c7522
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,11 @@ def node_to_prop(node_list, e_overestim, SHPC, orientation):
return properties
def search_beg(inst_eddies, max_delta):
return min(max_delta + 1, len(inst_eddies))
def search_end(inst_eddies, max_delta):
return max(len(inst_eddies) - max_delta - 1, 0)
t0 = time.perf_counter()
timings = open("timings_cost.txt", "w")
......@@ -174,7 +179,7 @@ print("Iterating on vertices...")
for n in g.vertices():
if n.in_degree() != 0:
# Define properties for beginning of the segment:
ip_beg = min(n_days_avg, len(g.vp.inst_eddies[n]))
ip_beg = search_beg(g.vp.inst_eddies[n], n_days_avg - 1)
properties = node_to_prop(
g.vp.inst_eddies[n][:ip_beg],
g.gp.e_overestim,
......@@ -194,7 +199,7 @@ for n in g.vertices():
if ip_beg < len_seg:
# We have to read more from the shapefiles and redefine
# properties.
ip_end = max(len_seg - n_days_avg, 0)
ip_end = search_end(g.vp.inst_eddies[n], n_days_avg - 1)
if ip_beg <= ip_end:
# We cannot use part of properties from the beginning
......
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