Skip to content

Commit f8b97a8

Browse files
committed
update example
1 parent 972ff2a commit f8b97a8

File tree

6 files changed

+54
-54
lines changed

6 files changed

+54
-54
lines changed

examples/02_eddy_identification/pet_eddy_detection.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
55
Script will detect eddies on adt field, and compute u,v with method add_uv(which could use, only if equator is avoid)
66
7+
Figures will show different step to detect eddies.
8+
79
"""
810
from datetime import datetime
911
from matplotlib import pyplot as plt
@@ -12,10 +14,9 @@
1214

1315

1416
def start_axes(title):
15-
fig = plt.figure(figsize=(12.5, 5))
16-
ax = fig.add_axes([0.03, 0.03, 0.94, 0.94])
17-
ax.set_xlim(-5, 37)
18-
ax.set_ylim(30, 46)
17+
fig = plt.figure(figsize=(13, 5))
18+
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
19+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
1920
ax.set_aspect("equal")
2021
ax.set_title(title)
2122
return ax
@@ -31,14 +32,21 @@ def update_axes(ax, mappable=None):
3132
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3233
)
3334

34-
ax = start_axes("ADT(m)")
35+
ax = start_axes("ADT (m)")
3536
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
3637
update_axes(ax, m)
3738

3839
g.add_uv("adt")
40+
ax = start_axes("U/V deduce from ADT (m)")
41+
ax.set_xlim(2.5, 9), ax.set_ylim(37.5, 40)
42+
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
43+
u, v = g.grid("u").T, g.grid("v").T
44+
ax.quiver(g.x_c, g.y_c, u, v, scale=10)
45+
update_axes(ax, m)
46+
3947
g.bessel_high_filter("adt", 500, order=2)
4048

41-
ax = start_axes("ADT (m) filtered(500km, order 2)")
49+
ax = start_axes("ADT (m) filtered (500km, order 2)")
4250
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
4351
update_axes(ax, m)
4452

@@ -60,19 +68,21 @@ def update_axes(ax, mappable=None):
6068
ax = start_axes("ADT contour reject but which contain eddies")
6169
g.contours.label_contour_unused_which_contain_eddies(a)
6270
g.contours.label_contour_unused_which_contain_eddies(c)
63-
g.contours.display(ax, only_contain_eddies=True, color="k", lw=1, label="Could be interaction contour")
64-
a.display(ax, color="b", linewidth=0.5, label="Anticyclonic", ref=-10)
65-
c.display(ax, color="r", linewidth=0.5, label="Cyclonic", ref=-10)
71+
g.contours.display(
72+
ax, only_contain_eddies=True, color="k", lw=1, label="Could be interaction contour"
73+
)
74+
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
75+
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
6676
ax.legend()
6777
update_axes(ax)
6878

6979
ax = start_axes("Eddies detected")
70-
a.display(ax, color="b", linewidth=0.5, label="Anticyclonic", ref=-10)
71-
c.display(ax, color="r", linewidth=0.5, label="Cyclonic", ref=-10)
80+
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
81+
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
7282
ax.legend()
7383
update_axes(ax)
7484

7585
ax = start_axes("Eddies speed radius (km)")
76-
a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap='jet', factor=0.001)
77-
m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap='jet', factor=0.001)
86+
a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)
87+
m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)
7888
update_axes(ax, m)

examples/08_tracking_manipulation/pet_display_field.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
fig = plt.figure(figsize=(12, 6))
1919
ax = fig.add_axes((0.05, 0.1, 0.9, 0.9))
2020
ax.set_aspect("equal")
21-
ax.set_xlim(-5, 37)
22-
ax.set_ylim(30, 46)
21+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
2322
m = c.scatter(ax, "amplitude", ref=-10, vmin=0, vmax=0.1)
2423
ax.grid()
2524

examples/08_tracking_manipulation/pet_display_track.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
fig = plt.figure(figsize=(12, 5))
2525
ax = fig.add_axes((0.05, 0.1, 0.9, 0.9))
2626
ax.set_aspect("equal")
27-
ax.set_xlim(-5, 37)
28-
ax.set_ylim(30, 46)
27+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
2928
a.plot(ax, ref=-10, label="Anticyclonic", color="r", lw=0.1)
3029
c.plot(ax, ref=-10, label="Cyclonic", color="b", lw=0.1)
3130
ax.legend()

examples/10_tracking_diagnostics/pet_center_count.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
)
1818
a = a.merge(c)
1919
# Plot
20-
fig = plt.figure(figsize=(20, 8))
21-
ax = fig.add_subplot(111)
22-
ax.set_xlim(-5, 37)
23-
ax.set_ylim(30, 46)
20+
fig = plt.figure(figsize=(13.5, 5))
21+
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
22+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
2423
ax.set_aspect("equal")
2524
step = 0.1
2625
t0, t1 = a.period
27-
g = a.grid_count(((-6, 37, step), (30, 46, step)), center=True)
26+
g = a.grid_count(((-7, 37, step), (30, 46, step)), center=True)
2827
m = g.display(ax, name="count", vmin=0, vmax=2, factor=1 / (step ** 2 * (t1 - t0)))
2928
ax.grid()
3029
cb = plt.colorbar(m, cax=fig.add_axes([0.95, 0.05, 0.01, 0.9]))

examples/10_tracking_diagnostics/pet_geographic_stats.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
import py_eddy_tracker_sample
1010

1111

12+
def start_axes(title):
13+
fig = plt.figure(figsize=(13.5, 5))
14+
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
15+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
16+
ax.set_aspect("equal")
17+
ax.set_title(title)
18+
return ax
19+
20+
1221
a = TrackEddiesObservations.load_file(
1322
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
1423
)
@@ -17,42 +26,27 @@
1726
)
1827
a = a.merge(c)
1928

20-
fig = plt.figure(figsize=(15, 7))
21-
ax = fig.add_subplot(111)
22-
ax.set_xlim(-5, 37)
23-
ax.set_ylim(30, 46)
24-
ax.set_aspect("equal")
2529
step = 0.1
30+
ax = start_axes("Amplitude mean by box of %s°" % step)
2631
g = a.grid_stat(((-5, 37, step), (30, 46, step)), "amplitude")
27-
m = g.display(ax, name="amplitude", vmin=0, vmax=0.2)
32+
m = g.display(ax, name="amplitude", vmin=0, vmax=10, factor=100)
2833
ax.grid()
29-
cb = plt.colorbar(m, cax=fig.add_axes([0.92, 0.05, 0.01, 0.9]))
30-
cb.set_label("Amplitude (m)")
31-
ax.set_title("Amplitude mean by box of %s°" % step)
32-
33-
fig = plt.figure(figsize=(15, 7))
34-
ax = fig.add_subplot(111)
35-
ax.set_xlim(-5, 37)
36-
ax.set_ylim(30, 46)
37-
ax.set_aspect("equal")
34+
cb = plt.colorbar(m, cax=ax.figure.add_axes([0.94, 0.05, 0.01, 0.9]))
35+
cb.set_label("Amplitude (cm)")
36+
37+
ax = start_axes("Speed radius mean by box of %s°" % step)
3838
step = 0.1
39-
g = a.grid_stat(((-5, 37, step), (30, 46, step)), "radius_s")
39+
g = a.grid_stat(((-7, 37, step), (30, 46, step)), "radius_s")
4040
m = g.display(ax, name="radius_s", vmin=10, vmax=50, factor=0.001)
4141
ax.grid()
42-
cb = plt.colorbar(m, cax=fig.add_axes([0.92, 0.05, 0.01, 0.9]))
42+
cb = plt.colorbar(m, cax=ax.figure.add_axes([0.94, 0.05, 0.01, 0.9]))
4343
cb.set_label("Speed radius (km)")
44-
ax.set_title("Speed radius mean by box of %s°" % step)
4544

46-
fig = plt.figure(figsize=(15, 7))
47-
ax = fig.add_subplot(111)
48-
ax.set_xlim(-5, 37)
49-
ax.set_ylim(30, 46)
50-
ax.set_aspect("equal")
45+
ax = start_axes("Percent of virtual by box of %s°" % step)
5146
step = 0.1
52-
g = a.grid_stat(((-5, 37, step), (30, 46, step)), "virtual")
47+
g = a.grid_stat(((-7, 37, step), (30, 46, step)), "virtual")
5348
g.vars["virtual"] *= 100
5449
m = g.display(ax, name="virtual", vmin=0, vmax=15)
5550
ax.grid()
56-
cb = plt.colorbar(m, cax=fig.add_axes([0.92, 0.05, 0.01, 0.9]))
51+
cb = plt.colorbar(m, cax=ax.figure.add_axes([0.94, 0.05, 0.01, 0.9]))
5752
cb.set_label("Percent of virtual (%)")
58-
ax.set_title("Percent of virtual by box of %s°" % step)

examples/10_tracking_diagnostics/pet_pixel_used.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
t0, t1 = a.period
1919

2020
# Plot
21-
fig = plt.figure(figsize=(15, 20))
22-
ax_a = fig.add_subplot(311)
21+
fig = plt.figure(figsize=(12, 14))
22+
ax_a = fig.add_axes([0.03, 0.66, 0.90, 0.33])
2323
ax_a.set_title("Anticyclonic frequency")
24-
ax_c = fig.add_subplot(312)
24+
ax_c = fig.add_axes([0.03, 0.33, 0.90, 0.33])
2525
ax_c.set_title("Cyclonic frequency")
26-
ax_all = fig.add_subplot(313)
26+
ax_all = fig.add_axes([0.03, 0, 0.90, 0.33])
2727
ax_all.set_title("All eddies frequency")
2828

2929
step = 0.1
@@ -45,8 +45,7 @@
4545

4646
for ax in (ax_a, ax_c, ax_all):
4747
ax.set_aspect("equal")
48-
ax.set_xlim(-5, 37)
49-
ax.set_ylim(30, 46)
48+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
5049
ax.grid()
5150

5251
plt.colorbar(m, cax=fig.add_axes([0.95, 0.05, 0.01, 0.9]))

0 commit comments

Comments
 (0)