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

Polish

parent 74d3a6f2
No related branches found
No related tags found
No related merge requests found
......@@ -56,12 +56,12 @@ def plot_nbunch(G, nbunch, color = '#1f78b4', label = None, ax = None):
if pos[n] is None:
print("plot_nbunch: missing coordinates for node ", n)
nbunch_plot.remove(n)
xy = np.asarray([pos[n] for n in nbunch_plot])
src_crs = ccrs.PlateCarree()
ax.scatter(xy[:, 0], xy[:, 1], s = 10, c = color, marker='o',
transform = src_crs)
for e in G.edges(nbunch_plot):
if pos[e[0]] and pos[e[1]]:
arrow = patches.FancyArrowPatch(pos[e[0]], pos[e[1]],
......@@ -81,7 +81,7 @@ def plot_nbunch(G, nbunch, color = '#1f78b4', label = None, ax = None):
def plot_all_components(G, label):
for component, color in zip(G.graph["component_list"], color_iter):
plot_nbunch(G, component, color, label)
def plot_descendants(G, n, label):
nbunch = nx.descendants(G, n) | {n}
plot_nbunch(G, nbunch, label = label)
......@@ -90,7 +90,7 @@ def animate_nbunch(G, nbunch):
sorted_nbunch = sorted(nbunch)
j = 0
date = sorted_nbunch[0][0]
while j < len(sorted_nbunch):
# {sorted_nbunch[j][0] == date}
j += 1
......@@ -99,12 +99,12 @@ def animate_nbunch(G, nbunch):
plot_nbunch(G, sorted_nbunch[:j], label = date)
plt.waitforbuttonpress()
date += 1
if __name__ == "__main__":
import argparse
from os import path
import time
parser = argparse.ArgumentParser(description = __doc__)
parser.add_argument("edgelist", help = "path to input CSV file")
parser.add_argument("shpc_dir", help = "directory containing SHPC, with "
......@@ -154,7 +154,7 @@ if __name__ == "__main__":
if args.time:
print("Reading edge list and SHPC...")
t0 = time.perf_counter()
G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
args.orientation)
......@@ -173,7 +173,7 @@ if __name__ == "__main__":
print("Elapsed time:", t1 - t0, "s")
t0 = t1
print("Plotting...")
dest_crs = ccrs.PlateCarree((args.window[0] + args.window[2]) / 2)
ax = plt.axes(projection = dest_crs)
plot_all_components(G, label)
......@@ -181,7 +181,7 @@ if __name__ == "__main__":
if args.time:
print("Reading edge list and SHPC...")
t0 = time.perf_counter()
G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
args.orientation)
......@@ -189,23 +189,23 @@ if __name__ == "__main__":
t1 = time.perf_counter()
print("Elapsed time:", t1 - t0, "s")
t0 = t1
print("Finding component...")
print("Finding components...")
report_graph.add_component(G, args.node)
if args.time:
t1 = time.perf_counter()
print("Elapsed time:", t1 - t0, "s")
print("Plotting...")
dest_crs = ccrs.PlateCarree(G.nodes[args.node]["coordinates"][0])
ax = plt.axes(projection = dest_crs)
plot_nbunch(G, G.nodes[args.node]["component"], label = label)
else:
if args.time:
print("Reading edge lists and SHPC...")
print("Reading edge list and SHPC...")
t0 = time.perf_counter()
G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
args.orientation)
......@@ -214,14 +214,14 @@ if __name__ == "__main__":
print("Elapsed time:", t1 - t0, "s")
t0 = t1
print("Finding components...")
assign_all_components(G)
if args.time:
t1 = time.perf_counter()
print("Elapsed time:", t1 - t0, "s")
print("Plotting...")
ax = plt.axes(projection = ccrs.PlateCarree())
plot_all_components(G, label)
......
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