Skip to content

Commit 719c7b0

Browse files
committed
Merge remote-tracking branch 'upstream/master'
# Conflicts: # examples/02_eddy_identification/pet_display_id.py # examples/02_eddy_identification/pet_eddy_detection.py # examples/02_eddy_identification/pet_eddy_detection_gulf_stream.py # examples/02_eddy_identification/pet_filter_and_detection.py # notebooks/python_module/02_eddy_identification/pet_display_id.ipynb # notebooks/python_module/02_eddy_identification/pet_eddy_detection.ipynb # notebooks/python_module/02_eddy_identification/pet_eddy_detection_gulf_stream.ipynb # src/py_eddy_tracker/observations/observation.py
2 parents 5b44bc8 + 1633dfa commit 719c7b0

33 files changed

+274
-191
lines changed

examples/02_eddy_identification/pet_display_id.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
c = EddiesObservations.load_file(data.get_path("Cyclonic_20190223.nc"))
1515

1616
# %%
17-
# Fill effective contour with amplitude
17+
# Fill effective contour with amplitude
1818
fig = plt.figure(figsize=(15, 8))
1919
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
2020
ax.set_aspect("equal")
2121
ax.set_xlim(0, 140)
2222
ax.set_ylim(-80, 0)
2323
kwargs = dict(extern_only=True, color="k", lw=1)
2424
a.display(ax, **kwargs), c.display(ax, **kwargs)
25-
a.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
26-
m = c.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
25+
a.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=0.5)
26+
m = c.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=0.5)
2727
colorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.03, 0.02, 0.94]))
28-
colorbar.set_label('Amplitude (m)')
28+
colorbar.set_label("Amplitude (m)")
2929

3030
# %%
3131
# Draw speed contours

examples/02_eddy_identification/pet_eddy_detection.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def start_axes(title):
2020
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
2121
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
2222
ax.set_aspect("equal")
23-
ax.set_title(title, weight='bold')
23+
ax.set_title(title, weight="bold")
2424
return ax
2525

2626

@@ -42,7 +42,7 @@ def update_axes(ax, mappable=None):
4242

4343
# %%
4444
# Get geostrophic speed u,v
45-
# -------
45+
# -------------------------
4646
# U/V are deduced from ADT, this algortihm is not ok near the equator (~+- 2°)
4747
g.add_uv("adt")
4848
ax = start_axes("U/V deduce from ADT (m)")
@@ -82,7 +82,7 @@ def update_axes(ax, mappable=None):
8282

8383
# %%
8484
# Post analysis
85-
# ------------
85+
# -------------
8686
# Contours can be rejected for several reasons (shape error to high, several extremum in contour, ...)
8787
ax = start_axes("ADT rejected contours")
8888
g.contours.display(ax, only_unused=True)
@@ -113,7 +113,11 @@ def update_axes(ax, mappable=None):
113113
g.contours.label_contour_unused_which_contain_eddies(a)
114114
g.contours.label_contour_unused_which_contain_eddies(c)
115115
g.contours.display(
116-
ax, only_contain_eddies=True, color="k", lw=1, label="Could be a contour of interaction"
116+
ax,
117+
only_contain_eddies=True,
118+
color="k",
119+
lw=1,
120+
label="Could be a contour of interaction",
117121
)
118122
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
119123
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
@@ -123,7 +127,8 @@ def update_axes(ax, mappable=None):
123127
# %%
124128
# Output
125129
# ------
126-
# When displaying the detected eddies, dashed lines are for effective contour, solide lines for the contour of the maximum mean speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
130+
# When displaying the detected eddies, dashed lines are for effective contour, solide lines for the contour of
131+
# the maximum mean speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
127132

128133
ax = start_axes("Detected Eddies")
129134
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
@@ -135,14 +140,16 @@ def update_axes(ax, mappable=None):
135140
# Display the speed radius of the detected eddies
136141
ax = start_axes("Speed Radius (km)")
137142
a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="magma_r", factor=0.001)
138-
m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="magma_r", factor=0.001)
143+
m = c.scatter(
144+
ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="magma_r", factor=0.001
145+
)
139146
update_axes(ax, m)
140147

141148
# %%
142149
# Filling the effective radius contours with the effective radius values
143150
ax = start_axes("Effective Radius (km)")
144151
kwargs = dict(vmin=10, vmax=80, cmap="magma_r", factor=0.001, lut=14, ref=-10)
145-
a.filled(ax, "radius_e", **kwargs)
152+
a.filled(ax, "effective_radius", **kwargs)
146153
m = c.filled(
147154
ax, "radius_e", vmin=10, vmax=80, cmap="magma_r", factor=0.001, lut=14, ref=-10
148155
)

examples/02_eddy_identification/pet_eddy_detection_gulf_stream.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def update_axes(ax, mappable=None):
5454

5555
# %%
5656
# Get geostrophic speed u,v
57-
# -------
57+
# -------------------------
5858
# U/V are deduced from ADT, this algortihm is not ok near the equator (~+- 2°)
5959
g.add_uv("adt")
6060

@@ -91,7 +91,7 @@ def update_axes(ax, mappable=None):
9191

9292
# %%
9393
# Post analysis
94-
# ------------
94+
# -------------
9595
# Contours can be rejected for several reasons (shape error to high, several extremum in contour, ...)
9696
ax = start_axes("ADT rejected contours")
9797
g.contours.display(ax, only_unused=True, lw=0.25)
@@ -123,7 +123,11 @@ def update_axes(ax, mappable=None):
123123
g.contours.label_contour_unused_which_contain_eddies(a)
124124
g.contours.label_contour_unused_which_contain_eddies(c)
125125
g.contours.display(
126-
ax, only_contain_eddies=True, color="k", lw=1, label="Could be a contour of interaction"
126+
ax,
127+
only_contain_eddies=True,
128+
color="k",
129+
lw=1,
130+
label="Could be a contour of interaction",
127131
)
128132
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
129133
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
@@ -133,7 +137,8 @@ def update_axes(ax, mappable=None):
133137
# %%
134138
# Output
135139
# ------
136-
# When displaying the detected eddies, dashed lines are for effective contour, solide lines for the contour of the maximum mean speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
140+
# When displaying the detected eddies, dashed lines are for effective contour, solide lines for the contour of the
141+
# maximum mean speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
137142

138143
ax = start_axes("Eddies detected")
139144
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)

examples/02_eddy_identification/pet_filter_and_detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def update_axes(ax, mappable=None):
5757

5858
# %%
5959
# Amplitude and Speed Radius distributions
60-
# -----------------------
60+
# ----------------------------------------
6161
fig = plt.figure(figsize=(12, 5))
6262
ax_a = fig.add_subplot(121, xlabel="Amplitude (cm)")
6363
ax_r = fig.add_subplot(122, xlabel="Speed Radius (km)")

examples/02_eddy_identification/pet_radius_vs_area.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
ax.grid()
3333
ax.set_xlabel("Speed radius computed with fit_circle")
3434
ax.set_ylabel("Radius deduced from area\nof contour_lon_s/contour_lat_s")
35-
ax.set_title('Area vs radius')
35+
ax.set_title("Area vs radius")
3636
ax.plot(a["radius_s"] / 1000.0, (areas / pi) ** 0.5 / 1000.0, ".")
3737
ax.plot((0, 250), (0, 250), "r")
3838

@@ -46,4 +46,4 @@
4646
ax.set_xlabel("Radius ratio")
4747
ax.set_ylabel("Shape error")
4848
ax.set_title("err = f(radius_ratio)")
49-
ax.plot(a["radius_s"] / (areas / pi) ** .5 , a['shape_error_s'], ".")
49+
ax.plot(a["radius_s"] / (areas / pi) ** 0.5, a["shape_error_s"], ".")

examples/02_eddy_identification/pet_sla_and_adt.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,18 @@ def update_axes(ax, mappable=None):
133133
ax.set_xlabel("Absolute Dynamic Topography")
134134
ax.set_ylabel("Sea Level Anomaly")
135135

136-
ax.plot(a_adt[field][i_a_adt] * factor, a_sla[field][i_a_sla] * factor, "r.", label='Anticyclonic')
137-
ax.plot(c_adt[field][i_c_adt] * factor, c_sla[field][i_c_sla] * factor, "b.", label='Cyclonic')
136+
ax.plot(
137+
a_adt[field][i_a_adt] * factor,
138+
a_sla[field][i_a_sla] * factor,
139+
"r.",
140+
label="Anticyclonic",
141+
)
142+
ax.plot(
143+
c_adt[field][i_c_adt] * factor,
144+
c_sla[field][i_c_sla] * factor,
145+
"b.",
146+
label="Cyclonic",
147+
)
138148
ax.set_aspect("equal"), ax.grid()
139149
ax.plot((0, 1000), (0, 1000), "g")
140150
ax.set_xlim(0, stop), ax.set_ylim(0, stop)

examples/06_grid_manipulation/pet_hide_pixel_out_eddies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# We will used the outter contour
3535
x_name, y_name = a.intern(False)
3636
adt = g.grid("adt")
37-
mask = ones(adt.shape, dtype='bool')
37+
mask = ones(adt.shape, dtype="bool")
3838
for eddy in a:
3939
i, j = Path(create_vertice(eddy[x_name], eddy[y_name])).pixels_in(g)
4040
mask[i, j] = False

examples/06_grid_manipulation/pet_okubo_weiss.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def update_axes(axes, mappable=None):
6262
v_y = g.compute_stencil(g.grid("vgos"), vertical=True)
6363
ow = g.vars["ow"] = (u_x - v_y) ** 2 + (v_x + u_y) ** 2 - (v_x - u_y) ** 2
6464

65-
6665
ax = start_axes("Okubo weis")
6766
m = g.display(ax, "ow", vmin=-1e-10, vmax=1e-10, cmap="bwr")
6867
update_axes(ax, m)
@@ -84,7 +83,6 @@ def update_axes(axes, mappable=None):
8483
a.display(ax, **kw_ed), c.display(ax, **kw_ed)
8584
update_axes(ax, m)
8685

87-
8886
# %%
8987
# Get okubo-weiss mean/min/center in eddies
9088
plt.figure(figsize=(8, 6))

examples/10_tracking_diagnostics/pet_center_count.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
cb.set_label("Eddies by 1°^2 by day")
5959

6060
g_c.vars["count"] = ratio
61-
m = g_c.display(ax_ratio, name="count", vmin=0.1, vmax=10, norm=LogNorm(), cmap='coolwarm_r')
61+
m = g_c.display(
62+
ax_ratio, name="count", vmin=0.1, vmax=10, norm=LogNorm(), cmap="coolwarm_r"
63+
)
6264
plt.colorbar(m, cax=fig.add_axes([0.94, 0.02, 0.01, 0.2]))
6365

6466
for ax in (ax_a, ax_c, ax_all, ax_ratio):

examples/10_tracking_diagnostics/pet_histo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
for x0, name, title, xmax, factor, bins in zip(
2727
(0.4, 0.72, 0.08),
28-
("radius_s", "speed_average", "amplitude"),
28+
("speed_radius", "speed_average", "amplitude"),
2929
("Speed radius (km)", "Speed average (cm/s)", "Amplitude (cm)"),
3030
(100, 50, 20),
3131
(0.001, 100, 100),

0 commit comments

Comments
 (0)