diff --git a/Analysis/report_graph.py b/Analysis/report_graph.py index 33dd796b4a61f6c781db2b58b539c1fcd4305dc2..38de2e5bf832f624c4024a85e3f96166afad3669 100755 --- a/Analysis/report_graph.py +++ b/Analysis/report_graph.py @@ -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: