diff --git a/Trajectories/Tests/tests.json b/Trajectories/Tests/tests.json index 4959974d7c7dba00e9206844a132a30921464d5f..9dc5acdfce6ac3329f9966369c457ac5a0b32495 100644 --- a/Trajectories/Tests/tests.json +++ b/Trajectories/Tests/tests.json @@ -116,7 +116,7 @@ "$tests_old_dir/Trajectories/expanded_traj.json", "$tests_old_dir/Cost_functions/e_overestim.txt", "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC", - "Anticyclones", "--save=png" + "Anticyclones", "--save=png", "--annotate" ] }, { @@ -126,7 +126,8 @@ "$src_dir/Trajectories/plot_traj.py", "$tests_old_dir/Greece_trajectories/expanded_traj.json", "$tests_old_dir/Greece_cost_function/e_overestim.txt", - "$tests_old_dir/Greece/SHPC", "Anticyclones", "--save=png" + "$tests_old_dir/Greece/SHPC", "Anticyclones", "--save=png", + "--annotate" ] } ] diff --git a/Trajectories/plot_traj.py b/Trajectories/plot_traj.py index 645f32c1c4cb7b0bfc3fcda4fed6e6d31dc35f68..40ea5228047652843c4f4e98b00e82a6e1c4c7c0 100755 --- a/Trajectories/plot_traj.py +++ b/Trajectories/plot_traj.py @@ -16,6 +16,8 @@ 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 the " + "first point of trajectory with node number") args = parser.parse_args() with open(args.expanded_traj) as f: @@ -52,10 +54,12 @@ for traj in trajectories: ax.plot(xy[:, 0], xy[:, 1], color = "red", transform = src_crs) ax.plot(xy[0, 0], xy[0, 1], marker = "s", color = "black", transform = src_crs) - ax.annotate(str(traj[0]), - ax.projection.transform_point(xy[0, 0], xy[0, 1], src_crs), - xytext = (3 * random.random(), 3 * random.random()), - textcoords = "offset points") + if args.annotate: + ax.annotate(str(traj[0]), + ax.projection.transform_point(xy[0, 0], xy[0, 1], + src_crs), + xytext = (3 * random.random(), 3 * random.random()), + textcoords = "offset points") ax.coastlines() ax.gridlines(draw_labels = True)