Skip to content

Commit 3a3a84b

Browse files
committed
Solve docstring python example issue
1 parent be2e674 commit 3a3a84b

30 files changed

+257
-180
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: 11 additions & 4 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

@@ -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,7 +140,9 @@ 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
# %%

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/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_pixel_used.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
plt.colorbar(m, cax=fig.add_axes([0.95, 0.27, 0.01, 0.7]))
5555

5656
g_c.vars["count"] = ratio
57-
m = g_c.display(ax_ratio, name="count", vmin=0.1, vmax=10, norm=LogNorm(), cmap='coolwarm_r')
57+
m = g_c.display(
58+
ax_ratio, name="count", vmin=0.1, vmax=10, norm=LogNorm(), cmap="coolwarm_r"
59+
)
5860
plt.colorbar(m, cax=fig.add_axes([0.95, 0.02, 0.01, 0.2]))
5961

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

notebooks/python_module/02_eddy_identification/pet_display_id.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"Fill effective contour with amplitude \n\n"
54+
"Fill effective contour with amplitude\n\n"
5555
]
5656
},
5757
{
@@ -62,7 +62,7 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 140)\nax.set_ylim(-80, 0)\nkwargs = dict(extern_only=True, color=\"k\", lw=1)\na.display(ax, **kwargs), c.display(ax, **kwargs)\na.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=.5)\nm = c.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=.5)\ncolorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.03, 0.02, 0.94]))\ncolorbar.set_label('Amplitude (m)')"
65+
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 140)\nax.set_ylim(-80, 0)\nkwargs = dict(extern_only=True, color=\"k\", lw=1)\na.display(ax, **kwargs), c.display(ax, **kwargs)\na.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=0.5)\nm = c.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=0.5)\ncolorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.03, 0.02, 0.94]))\ncolorbar.set_label(\"Amplitude (m)\")"
6666
]
6767
},
6868
{
@@ -129,7 +129,7 @@
129129
"name": "python",
130130
"nbconvert_exporter": "python",
131131
"pygments_lexer": "ipython3",
132-
"version": "3.7.6"
132+
"version": "3.7.7"
133133
}
134134
},
135135
"nbformat": 4,

0 commit comments

Comments
 (0)