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

Add option `-t` to `draw_segments.py`

So we do not have to symlink the file `traj_segm.json`.
parent fc83518a
No related branches found
No related tags found
No related merge requests found
......@@ -109,8 +109,7 @@
[
"$src_dir/Trajectories/draw_segments.py",
"$PWD/Eurec4A_graph_anti/segments_cost_functions.gt",
"segments.gv"
],
"symlink": ["$PWD/Eurec4A_graph_anti/traj_segm.json"]
"segments.gv", "-t", "$PWD/Eurec4A_graph_anti/traj_segm.json"
]
}
]
......@@ -16,6 +16,8 @@ import argparse
parser = argparse.ArgumentParser()
parser.add_argument("input_file", help = "Graph-tool file")
parser.add_argument("output_file", help = "Graphviz file")
parser.add_argument("-t",
help = "trajectory segments, JSON, to color trajectories")
args = parser.parse_args()
g_in = graph_tool.load_graph(args.input_file)
......@@ -33,12 +35,9 @@ for e in g_in.edges():
except AttributeError:
g_out.add_edge(g_in.vp.name[source], g_in.vp.name[target])
try:
with open("traj_segm.json") as f: traj_segm = json.load(f)
except FileNotFoundError:
print("traj_segm.json not found")
print("Will not color trajectories.")
else:
if args.t:
with open(args.t) as f: traj_segm = json.load(f)
for segment_list in traj_segm:
for i in range(len(segment_list) - 1):
e = g_out.get_edge(segment_list[i], segment_list[i + 1])
......
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