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

Test `args.min_duration` outside the loop

Test `args.min_duration` outside the loop on `expanded_traj`. Clearer.
parent 4fcae9a3
No related branches found
No related tags found
No related merge requests found
......@@ -80,25 +80,31 @@ if __name__ == "__main__":
projection = ccrs.PlateCarree(central_longitude = 110)
fig, ax = plt.subplots(subplot_kw = {"projection": projection})
random.seed(0)
n_long_traj = 0
for traj in expanded_traj:
if args.min_duration > 1:
if args.min_duration == 1:
for traj in expanded_traj:
plot_single_traj(traj, e_overestim, SHPC, args.orientation, ax,
src_crs, args.annotate)
else:
# args.min_duration > 1
n_long_traj = 0
for traj in expanded_traj:
duration = report_graph.node_to_date_eddy(traj[- 1], e_overestim,
only_date = True) \
- report_graph.node_to_date_eddy(traj[0], e_overestim,
only_date = True)
if args.min_duration == 1 or duration >= args.min_duration:
if args.min_duration > 1: n_long_traj += 1
plot_single_traj(traj, e_overestim, SHPC, args.orientation, ax,
src_crs, args.annotate)
ax.add_feature(cfeature.LAND, edgecolor = "black")
ax.gridlines(draw_labels = True)
if duration >= args.min_duration:
n_long_traj += 1
plot_single_traj(traj, e_overestim, SHPC, args.orientation, ax,
src_crs, args.annotate)
if args.min_duration > 1:
print("Number of trajectories with sufficient duration:", n_long_traj)
ax.add_feature(cfeature.LAND, edgecolor = "black")
ax.gridlines(draw_labels = True)
if args.save:
plt.savefig(f"plot_traj.{args.save}")
print(f'Created "plot_traj.{args.save}".')
......
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