From 25bafb920061b42372d87b573407acb9212075d4 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Thu, 23 Nov 2023 21:53:22 +0100
Subject: [PATCH] Remove argument orientation of `plot_traj.py`

Read orientation from `expanded_traj.json`.
---
 Trajectories/Tests/tests.json | 2 --
 Trajectories/plot_traj.py     | 9 ++++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Trajectories/Tests/tests.json b/Trajectories/Tests/tests.json
index d55627b6..5e36a6ed 100644
--- a/Trajectories/Tests/tests.json
+++ b/Trajectories/Tests/tests.json
@@ -113,7 +113,6 @@
             "$src_dir/Trajectories/plot_traj.py",
             "$tests_old_dir/Trajectories/expanded_traj.json",
             "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC",
-            "Anticyclones",
             "--save=png",
             "--annotate"
 	]
@@ -123,7 +122,6 @@
             "$src_dir/Trajectories/plot_traj.py",
             "$tests_old_dir/Greece_trajectories/expanded_traj.json",
             "$tests_old_dir/Greece/SHPC",
-            "Anticyclones",
             "--save=png",
             "--annotate"
 	]
diff --git a/Trajectories/plot_traj.py b/Trajectories/plot_traj.py
index eb6f6bbf..e65aadac 100755
--- a/Trajectories/plot_traj.py
+++ b/Trajectories/plot_traj.py
@@ -61,7 +61,6 @@ if __name__ == "__main__":
     parser = argparse.ArgumentParser()
     parser.add_argument("expanded_traj", help = "JSon file")
     parser.add_argument("SHPC", help = "directory")
-    parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
     parser.add_argument("--save", metavar = "format",
                         help = "Save file to specified format")
     parser.add_argument("--annotate", action = "store_true", help = "annotate "
@@ -73,7 +72,7 @@ if __name__ == "__main__":
 
     with open(args.expanded_traj) as f: expanded_traj = json.load(f)
     print("Number of trajectories:", len(expanded_traj["traj"]))
-    SHPC = util_eddies.SHPC_class(args.SHPC, def_orient = args.orientation)
+    SHPC = util_eddies.SHPC_class(args.SHPC, def_orient = expanded_traj["orientation"])
     src_crs = ccrs.Geodetic()
     projection = ccrs.Mercator(central_longitude = 110)
     fig, ax = plt.subplots(subplot_kw = {"projection": projection})
@@ -82,7 +81,7 @@ if __name__ == "__main__":
     if args.min_duration == 1:
         for traj in expanded_traj["traj"]:
             plot_single_traj(
-                traj, expanded_traj["e_overestim"], SHPC, args.orientation, ax,
+                traj, expanded_traj["e_overestim"], SHPC, expanded_traj["orientation"], ax,
                 src_crs, args.annotate, color = "red")
     else:
         # args.min_duration > 1
@@ -93,14 +92,14 @@ if __name__ == "__main__":
             if duration >= args.min_duration:
                 n_long_traj += 1
                 plot_single_traj(
-                    traj, expanded_traj["e_overestim"], SHPC, args.orientation,
+                    traj, expanded_traj["e_overestim"], SHPC, expanded_traj["orientation"],
                     ax, src_crs, args.annotate, color = "red")
 
         print("Number of trajectories with sufficient duration:", n_long_traj)
         ax.set_title(rf"lifetime $\geq$ {args.min_duration} time steps"
                      f"\nnumber of trajectories: {n_long_traj}")
 
-    ax.set_title(args.orientation, loc = "left")
+    ax.set_title(expanded_traj["orientation"], loc = "left")
     ax.add_feature(cfeature.LAND, edgecolor = "black")
     ax.gridlines(draw_labels = True)
 
-- 
GitLab