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

Polish

parent b2ee6af5
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,8 @@ from networkx import nx_agraph
import os
def read_eddy_graph(edgelist, shp_tr_dir = None, read_interp = True):
"""shp_tr_dir is for visible eddies."""
G = nx.DiGraph()
if os.access(edgelist, os.R_OK):
......@@ -37,8 +39,8 @@ def read_eddy_graph(edgelist, shp_tr_dir = None, read_interp = True):
# Assuming that the directory containing the interpolated
# eddies is in the same location as edgelist:
extr_file = path.join(path.dirname(edgelist), "SHP_triplet",
"extremum.shp")
dir_edgelist = path.dirname(edgelist)
extr_file = path.join(dir_edgelist, "SHP_triplet", "extremum.shp")
if os.access(extr_file, os.R_OK):
set_attribute(G, extr_file)
......@@ -59,6 +61,7 @@ def set_attribute(G, extr_file):
with shapefile.Reader(extr_file) as s_read:
for shape_rec in s_read:
n = (shape_rec.record.days_1950, shape_rec.record.eddy_index)
if (shape_rec.record.valid == 1
or shape_rec.record.interpolat == 1) and n in G:
G.add_node(n,
......@@ -76,7 +79,7 @@ def to_eddy_agraph(G):
A = nx_agraph.to_agraph(G)
for k, s in my_subgraphs.items():
for d, s in my_subgraphs.items():
A.add_subgraph(s, rank = "same")
for n in G:
......
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