Skip to content

Commit a10c425

Browse files
committed
add example
1 parent 9721ac7 commit a10c425

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

examples/pet_center_count.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Count center
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+
a = a.merge(c)
15+
# Plot
16+
fig = plt.figure(figsize=(15, 8))
17+
ax = fig.add_subplot(111)
18+
ax.set_aspect("equal")
19+
ax.set_xlim(-5, 37)
20+
ax.set_ylim(30, 46)
21+
step = .1
22+
t0, t1 = a.period
23+
g = a.grid_count(((-5, 37, step), (30, 46, step)), center=True)
24+
g.vars['count'] = g.vars['count'] / (step ** 2 * (t1 - t0))
25+
m = g.display(ax, name='count', vmin=0, vmax=2)
26+
ax.grid()
27+
cb = plt.colorbar(m)
28+
cb.set_label('Eddies by 1°^2 by day')
29+

examples/pet_display_id.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Display identification
3+
======================
4+
5+
"""
6+
7+
from matplotlib import pyplot as plt
8+
from py_eddy_tracker.observations.observation import EddiesObservations
9+
from py_eddy_tracker import data
10+
11+
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
12+
c = EddiesObservations.load_file(data.get_path("Cyclonic_20190223.nc"))
13+
14+
# Plot
15+
fig = plt.figure(figsize=(15,8))
16+
ax = fig.add_subplot(111)
17+
ax.set_aspect('equal')
18+
ax.set_xlim(0, 360)
19+
ax.set_ylim(-80, 80)
20+
a.display(ax, label="Anticyclonic", color="r", lw=1)
21+
c.display(ax, label="Cyclonic", color="b", lw=1)
22+
ax.legend(loc="upper right")

0 commit comments

Comments
 (0)