Skip to content

Commit a44471c

Browse files
committed
eddies frequency
1 parent a10c425 commit a44471c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

examples/pet_pixel_used.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Count pixel used
3+
======================
4+
5+
"""
6+
7+
from matplotlib import pyplot as plt
8+
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
9+
import py_eddy_tracker_sample
10+
11+
12+
a = TrackEddiesObservations.load_file(py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr"))
13+
c = TrackEddiesObservations.load_file(py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr"))
14+
15+
# Plot
16+
fig = plt.figure(figsize=(15, 20))
17+
ax_a = fig.add_subplot(311)
18+
ax_a.set_title('Anticyclonic frequency')
19+
ax_c = fig.add_subplot(312)
20+
ax_c.set_title('Cyclonic frequency')
21+
ax_all = fig.add_subplot(313)
22+
ax_all.set_title('All eddies frequency')
23+
24+
step = 0.1
25+
kwargs_pcolormesh = dict(cmap='terrain_r', vmin=0, vmax=.75)
26+
g_a = a.grid_count(((-5, 37, step), (30, 46, step)), intern=True)
27+
t0, t1 = a.period
28+
g_a.vars["count"] = g_a.vars["count"] / (t1 - t0)
29+
m = g_a.display(ax_a, name="count", **kwargs_pcolormesh)
30+
31+
g_c = c.grid_count(((-5, 37, step), (30, 46, step)), intern=True)
32+
t0, t1 = c.period
33+
g_c.vars["count"] = g_c.vars["count"] / (t1 - t0)
34+
m = g_c.display(ax_c, name="count", **kwargs_pcolormesh)
35+
36+
m_c = g_c.vars["count"].mask
37+
m = m_c & g_a.vars["count"].mask
38+
g_c.vars["count"][m_c] = 0
39+
g_c.vars["count"] += g_a.vars["count"]
40+
g_c.vars["count"].mask = m
41+
42+
m = g_c.display(ax_all, name="count", **kwargs_pcolormesh)
43+
44+
for ax in (ax_a, ax_c, ax_all):
45+
ax.set_aspect("equal")
46+
ax.set_xlim(-5, 37)
47+
ax.set_ylim(30, 46)
48+
ax.grid()
49+
50+
plt.colorbar(m, cax=fig.add_axes([0.95, 0.05, 0.01, 0.9]))

0 commit comments

Comments
 (0)