From 49b65e965d6c848c0cee6a9ebc55a96174398221 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 23 Nov 2023 21:50:50 +0100 Subject: [PATCH] Save orientation of eddies in Graphtool graph --- Trajectories/Tests/component_60148580.graphml | 2 ++ Trajectories/Tests/example_2.graphml | 2 ++ Trajectories/Tests/segments_cost.graphml | 2 ++ Trajectories/cost_function.py | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/Trajectories/Tests/component_60148580.graphml b/Trajectories/Tests/component_60148580.graphml index a47c6945..a7b6d0f3 100644 --- a/Trajectories/Tests/component_60148580.graphml +++ b/Trajectories/Tests/component_60148580.graphml @@ -18,6 +18,7 @@ <key id="key11" for="node" attr.name="name" attr.type="int" /> <key id="key12" for="node" attr.name="pos_first" attr.type="vector_float" /> <key id="key13" for="node" attr.name="pos_last" attr.type="vector_float" /> + <key id="key14" for="graph" attr.name="orientation" attr.type="string" /> <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst"> @@ -25,6 +26,7 @@ <data key="key0">0</data> <data key="key2">0</data> <data key="key5">3401</data> + <data key="key14">Anticyclones</data> <!-- vertices --> <node id="n0"> diff --git a/Trajectories/Tests/example_2.graphml b/Trajectories/Tests/example_2.graphml index 75e85fb4..b0c809dd 100644 --- a/Trajectories/Tests/example_2.graphml +++ b/Trajectories/Tests/example_2.graphml @@ -8,11 +8,13 @@ <key id="key1" for="edge" attr.name="cost_function" attr.type="float" /> <key id="key2" for="node" attr.name="name" attr.type="int" /> <key id="key3" for="node" attr.name="inst_eddies" attr.type="vector_int" /> + <key id="key4" for="graph" attr.name="orientation" attr.type="string" /> <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst"> <!-- graph properties --> <data key="key0">10</data> + <data key="key4">Anticyclones</data> <!-- vertices --> <node id="n0"> diff --git a/Trajectories/Tests/segments_cost.graphml b/Trajectories/Tests/segments_cost.graphml index 1966235d..8aef1310 100644 --- a/Trajectories/Tests/segments_cost.graphml +++ b/Trajectories/Tests/segments_cost.graphml @@ -6,6 +6,7 @@ <!-- property keys --> <key id="key0" for="edge" attr.name="cost_function" attr.type="float" /> <key id="key1" for="graph" attr.name="e_overestim" attr.type="int" /> + <key id="key2" for="graph" attr.name="orientation" attr.type="string" /> <key id="key3" for="node" attr.name="inst_eddies" attr.type="vector_int" /> <key id="key6" for="node" attr.name="name" attr.type="int" /> @@ -13,6 +14,7 @@ <!-- graph properties --> <data key="key1">10</data> + <data key="key2">Anticyclones</data> <!-- vertices --> <node id="n0"> diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py index b4fec82e..86feaaed 100755 --- a/Trajectories/cost_function.py +++ b/Trajectories/cost_function.py @@ -121,6 +121,11 @@ t1 = time.perf_counter() timings.write(f"loading: {t1 - t0:.0f} s\n") t0 = t1 +# It is useful to save the orientation to the output graph of this +# script for further processing of the output graph by other scripts: +g.graph_properties["orientation"] = g.new_graph_property("string") +g.graph_properties["orientation"] = args.orientation + pos_first = g.new_vp('vector<double>') pos_last = g.new_vp('vector<double>') first_av_rad = g.new_vp('float') -- GitLab