diff --git a/Overlap/report_graph.py b/Overlap/report_graph.py index 84da631a3e65b7a3b9b52be9a41b453ae1d08ef9..af273df2bca4b8111b396114f789430d5cc3cdff 100755 --- a/Overlap/report_graph.py +++ b/Overlap/report_graph.py @@ -6,6 +6,7 @@ from os import path from networkx import nx_agraph import os import json +import util_eddies def node_to_date_eddy(node_index, e_overestim, only_date = False): """Convert from node identification in graph to eddy identification in @@ -37,25 +38,24 @@ def read_eddy_graph(edgelist, shpc_dir = None): if shpc_dir is not None: # Read and set attributes of eddies: - extr_file = path.join(shpc_dir, "extremum") - set_attribute(G, extr_file) + handler = util_eddies.open_shpc(shpc_dir) + set_attribute(G, handler) else: print(edgelist, "not readable") G = nx.DiGraph() return G -def set_attribute(G, extr_file): - with shapefile.Reader(extr_file) as s_read: - for shape_rec in s_read: - 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 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) def to_eddy_agraph(G): my_subgraphs = {} diff --git a/Overlap/util_eddies.py b/Overlap/util_eddies.py new file mode 120000 index 0000000000000000000000000000000000000000..64088a7785b6713b39cc2b1ef218efa72760c62d --- /dev/null +++ b/Overlap/util_eddies.py @@ -0,0 +1 @@ +../Common/util_eddies.py \ No newline at end of file