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

Loop on nodes if the number of nodes is small

Loop on nodes if the number of nodes is small compared to the number
of shapes. For faster execution.
parent 56ca8ea3
No related branches found
No related tags found
No related merge requests found
......@@ -47,15 +47,27 @@ def read_eddy_graph(edgelist, shpc_dir = None):
return G
def set_attribute(G, handler):
for shape_rec in handler["readers"]["extremum"]:
n = date_eddy_to_node(shape_rec.record.date,
shape_rec.record.eddy_index,
G.graph["e_overestim"])
if shape_rec.record.valid == 1 and n in G:
G.add_node(n, coordinates = tuple(shape_rec.shape.points[0]),
speed = shape_rec.record.speed,
ssh = shape_rec.record.ssh)
if G.number_of_nodes() <= len(handler["readers"]["extremum"]) / 100:
for n in G:
date_index, eddy_index = node_to_date_eddy(n,
G.graph["e_overestim"])
ishape = util_eddies.comp_ishape(handler, date_index, eddy_index)
shape_rec = handler["readers"]["extremum"].shapeRecord(ishape)
if shape_rec.record.valid == 1:
G.add_node(n, coordinates = tuple(shape_rec.shape.points[0]),
speed = shape_rec.record.speed,
ssh = shape_rec.record.ssh)
else:
for shape_rec in handler["readers"]["extremum"]:
n = date_eddy_to_node(shape_rec.record.date,
shape_rec.record.eddy_index,
G.graph["e_overestim"])
if shape_rec.record.valid == 1 and n in G:
G.add_node(n, coordinates = tuple(shape_rec.shape.points[0]),
speed = shape_rec.record.speed,
ssh = shape_rec.record.ssh)
def to_eddy_agraph(G):
my_subgraphs = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment