From 8e3e0e1076b1bf7431d6f1c3fadcbf194f5f2a7a Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Thu, 17 Jun 2021 22:06:03 +0200
Subject: [PATCH] Plot a single orientation in `plot_traj.py`

We are reverting commit b926e1b because now there are two SHPC input
directories for visible eddies, two SHPC for interpolated eddies and
edgelists in differents directories for the two orientations. Handling
the command line arguments would be awkward.
---
 Overlap/Analysis/plot_traj.py | 36 ++++++++++++++---------------------
 Overlap/Analysis/tests.json   |  3 +--
 2 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/Overlap/Analysis/plot_traj.py b/Overlap/Analysis/plot_traj.py
index 15b35c41..d79f6269 100755
--- a/Overlap/Analysis/plot_traj.py
+++ b/Overlap/Analysis/plot_traj.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
-"""Must be run from directory containing edgelist_cyclo.csv,
-edgelist_anti and SHP-triplet directory for interpolated eddies.
+"""Must be run from directory containing edgelist.csv and SHP-triplet
+directory for interpolated eddies.
 
 """
 
@@ -112,8 +112,8 @@ if __name__ == "__main__":
                         help = "Report elapsed time")
     group = parser.add_mutually_exclusive_group()
     group.add_argument("-n", "--node", help = "Select component containing "
-                       "node, with orientation cyclo or anti", nargs = 3,
-                       metavar = ("date_ind", "eddy_ind", "orient"))
+                       "node", nargs = 2,
+                       metavar = ("date_ind", "eddy_ind"))
     group.add_argument("-w", "--window", help = "choose a limited plot window",
                        type = float, nargs = 4,
                        metavar = ("lllon", "lllat", "urlon", "urlat"))
@@ -126,13 +126,10 @@ if __name__ == "__main__":
             sys.exit("bad values of urlon and lllon")
 
         if args.time:
-            print("Reading edge lists in current directory...")
+            print("Reading edge list in current directory...")
             t0 = time.perf_counter()
             
-        G_cyclo = report_graph.read_eddy_graph("edgelist_cyclo.csv",
-                                               args.shp_tr_dir)
-        G_anti = report_graph.read_eddy_graph("edgelist_anti.csv",
-                                               args.shp_tr_dir)
+        G = report_graph.read_eddy_graph("edgelist.csv", args.shp_tr_dir)
 
         if args.time:
             t1 = time.perf_counter()
@@ -140,10 +137,9 @@ if __name__ == "__main__":
             t0 = t1
             print("Finding components...")
 
-        for G in [G_cyclo, G_anti]:
-            for n, d in G.nodes.items():
-                if util_eddies.in_window(d["coordinates"], args.window):
-                    if "component" not in d: report_graph.add_component(G, n)
+        for n, d in G.nodes.items():
+            if util_eddies.in_window(d["coordinates"], args.window):
+                if "component" not in d: report_graph.add_component(G, n)
 
         if args.time:
             t1 = time.perf_counter()
@@ -153,7 +149,7 @@ if __name__ == "__main__":
             
         dest_crs = ccrs.PlateCarree((args.window[0] + args.window[2]) / 2)
         ax = plt.axes(projection = dest_crs)
-        for G in [G_cyclo, G_anti]: plot_all_components(G, args.label)
+        plot_all_components(G, args.label)
     elif args.node is not None:
         source = (int(args.node[0]), int(args.node[1]))
 
@@ -161,8 +157,7 @@ if __name__ == "__main__":
             print("Reading edge list in current directory...")
             t0 = time.perf_counter()
             
-        G = report_graph.read_eddy_graph(f"edgelist_{args.node[2]}.csv",
-                                         args.shp_tr_dir)
+        G = report_graph.read_eddy_graph("edgelist.csv", args.shp_tr_dir)
 
         if args.time:
             t1 = time.perf_counter()
@@ -185,10 +180,7 @@ if __name__ == "__main__":
             print("Reading edge lists in current directory...")
             t0 = time.perf_counter()
             
-        G_cyclo = report_graph.read_eddy_graph("edgelist_cyclo.csv",
-                                               args.shp_tr_dir)
-        G_anti = report_graph.read_eddy_graph("edgelist_anti.csv",
-                                              args.shp_tr_dir)
+        G = report_graph.read_eddy_graph("edgelist.csv", args.shp_tr_dir)
 
         if args.time:
             t1 = time.perf_counter()
@@ -196,7 +188,7 @@ if __name__ == "__main__":
             t0 = t1
             print("Finding components...")
             
-        for G in [G_cyclo, G_anti]: assign_all_components(G)
+        assign_all_components(G)
 
         if args.time:
             t1 = time.perf_counter()
@@ -204,7 +196,7 @@ if __name__ == "__main__":
             print("Plotting...")
             
         ax = plt.axes(projection = ccrs.PlateCarree())
-        for G in [G_cyclo, G_anti]: plot_all_components(G, args.label)
+        plot_all_components(G, args.label)
 
     ax.coastlines()
     ax.gridlines(draw_labels = True)
diff --git a/Overlap/Analysis/tests.json b/Overlap/Analysis/tests.json
index c8e05155..d0f70e38 100644
--- a/Overlap/Analysis/tests.json
+++ b/Overlap/Analysis/tests.json
@@ -35,8 +35,7 @@
 	],
 	"required":
 	[
-	    "$tests_old_dir/EGr2nd15md4np3/edgelist_anti.csv",
-	    "$tests_old_dir/EGr2nd15md4np3/edgelist_cyclo.csv",
+	    "$tests_old_dir/EGr2nd15md4np3/edgelist.csv",
 	    "$tests_old_dir/EGr2nd15md4np3/SHPC"
 	]
     },
-- 
GitLab