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

Add script `plot_traj.py`

parent ac30f53a
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
import report_graph
import util_eddies
import matplotlib.pyplot as plt
import numpy as np
import json
import cartopy.crs as ccrs
import random
import sys
if len(sys.argv) != 5:
sys.exit("Required arguments : expanded-traj-file e-overestim-file "
"SHPC-dir" "orientation")
with open(sys.argv[1]) as f:
trajectories = json.load(f)
print("Number of trajectories:", len(trajectories))
with open(sys.argv[2]) as f:
e_overestim = int(f.read())
SHPC = util_eddies.SHPC_class(sys.argv[3], def_orient = sys.argv[4])
src_crs = ccrs.PlateCarree()
projection = ccrs.PlateCarree()
fig, ax = plt.subplots(subplot_kw = {"projection": projection})
for traj in trajectories:
xy = []
for node in traj:
date_index, eddy_index = report_graph.node_to_date_eddy(node,
e_overestim)
i_slice = SHPC.get_slice(date_index)
ishape = SHPC.comp_ishape(date_index, eddy_index, i_slice)
shape = SHPC.get_reader(i_slice, layer = "extremum").shape(ishape)
xy.append(shape.points[0])
xy = np.array(xy)
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")
ax.coastlines()
ax.gridlines(draw_labels = True)
plt.show()
../Overlap/report_graph.py
\ No newline at end of file
../Common/util_eddies.py
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment