Skip to content

Commit be2e674

Browse files
Change in help and colors (AntSimi#32)
1 parent 310972a commit be2e674

File tree

12 files changed

+338
-291
lines changed

12 files changed

+338
-291
lines changed

examples/02_eddy_identification/pet_contour_circle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
1414

1515
# %%
16-
# Plot
16+
# Plot the speed and effective (dashed) contours
1717
fig = plt.figure(figsize=(15, 8))
1818
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
1919
ax.set_aspect("equal")
2020
ax.set_xlim(10, 70)
2121
ax.set_ylim(-50, -25)
2222
a.display(ax, label="Anticyclonic contour", color="r", lw=1)
2323

24-
# Replace contour by circle
24+
# Replace contours by circles using center and radius (effective is dashed)
2525
a.circle_contour()
2626
a.display(ax, label="Anticyclonic circle", color="g", lw=1)
2727
ax.legend(loc="upper right")

examples/02_eddy_identification/pet_display_id.py

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

1616
# %%
17-
# filled contour with amplitude field
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")
@@ -24,11 +24,11 @@
2424
a.display(ax, **kwargs), c.display(ax, **kwargs)
2525
a.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
2626
m = c.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
27-
colorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))
27+
colorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.03, 0.02, 0.94]))
2828
colorbar.set_label('Amplitude (m)')
2929

3030
# %%
31-
# draw contour
31+
# Draw speed contours
3232
fig = plt.figure(figsize=(15, 8))
3333
ax = fig.add_axes([0.03, 0.03, 0.94, 0.94])
3434
ax.set_aspect("equal")

examples/02_eddy_identification/pet_eddy_detection.py

Lines changed: 39 additions & 41 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)
23+
ax.set_title(title, weight='bold')
2424
return ax
2525

2626

@@ -31,118 +31,116 @@ def update_axes(ax, mappable=None):
3131

3232

3333
# %%
34-
# Load Input grid, ADT will be used to detect eddies
34+
# Load Input grid, ADT is used to detect eddies
3535
g = RegularGridDataset(
3636
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3737
)
3838

3939
ax = start_axes("ADT (m)")
40-
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
40+
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15, cmap="RdBu_r")
4141
update_axes(ax, m)
4242

4343
# %%
44-
# Get u/v
44+
# Get geostrophic speed u,v
4545
# -------
46-
# U/V are deduced from ADT, this algortihm are not usable around equator (~+- 2°)
46+
# 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)")
4949
ax.set_xlim(2.5, 9), ax.set_ylim(37.5, 40)
50-
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
50+
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15, cmap="RdBu_r")
5151
u, v = g.grid("u").T, g.grid("v").T
5252
ax.quiver(g.x_c, g.y_c, u, v, scale=10)
5353
update_axes(ax, m)
5454

5555
# %%
5656
# Pre-processings
5757
# ---------------
58-
# Apply high filter to remove long scale to highlight mesoscale
58+
# Apply a high-pass filter to remove the large scale and highlight the mesoscale
5959
g.bessel_high_filter("adt", 500)
6060
ax = start_axes("ADT (m) filtered (500km)")
61-
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
61+
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15, cmap="RdBu_r")
6262
update_axes(ax, m)
6363

6464
# %%
6565
# Identification
6666
# --------------
67-
# run identification with slice of 2 mm
67+
# Run the identification step with slices of 2 mm
6868
date = datetime(2016, 5, 15)
6969
a, c = g.eddy_identification("adt", "u", "v", date, 0.002, shape_error=55)
7070

7171
# %%
72-
# All closed contour found in this input grid (Display only 1 contour every 4)
73-
ax = start_axes("ADT closed contour (only 1 / 4 levels)")
72+
# Display of all closed contours found in the grid (only 1 contour every 4)
73+
ax = start_axes("ADT closed contours (only 1 / 4 levels)")
7474
g.contours.display(ax, step=4)
7575
update_axes(ax)
7676

7777
# %%
78-
# Contours include in eddies
79-
ax = start_axes("ADT contour used as eddies")
78+
# Contours included in eddies
79+
ax = start_axes("ADT contours used as eddies")
8080
g.contours.display(ax, only_used=True)
8181
update_axes(ax)
8282

8383
# %%
84-
# Post analyse
84+
# Post analysis
8585
# ------------
86-
# Contours reject from several origin (shape error to high, several extremum in contour, ...)
87-
ax = start_axes("ADT contour reject")
86+
# Contours can be rejected for several reasons (shape error to high, several extremum in contour, ...)
87+
ax = start_axes("ADT rejected contours")
8888
g.contours.display(ax, only_unused=True)
8989
update_axes(ax)
9090

9191
# %%
92-
# Contours reject criterion
93-
#
92+
# Creteria for rejecting a contour
9493
# 0. - Accepted (green)
95-
# 1. - Reject for shape error (red)
96-
# 2. - Masked value in contour (blue)
97-
# 3. - Under or over pixel limit bound (black)
94+
# 1. - Rejection for shape error (red)
95+
# 2. - Masked value within contour (blue)
96+
# 3. - Under or over the pixel limit bounds (black)
9897
# 4. - Amplitude criterion (yellow)
99-
ax = start_axes("Contour reject criterion")
100-
g.contours.display(ax, only_unused=True, lw=0.25, display_criterion=True)
98+
ax = start_axes("Contours' rejection criteria")
99+
g.contours.display(ax, only_unused=True, lw=0.5, display_criterion=True)
101100
update_axes(ax)
102101

103102
# %%
104-
# Display shape error of each tested contour, the limit of shape error is set to 55 %
103+
# Display the shape error of each tested contour, the limit of shape error is set to 55 %
105104
ax = start_axes("Contour shape error")
106105
m = g.contours.display(
107-
ax, lw=0.5, field="shape_error", bins=arange(20, 90.1, 5), cmap="seismic"
106+
ax, lw=0.5, field="shape_error", bins=arange(20, 90.1, 5), cmap="PRGn_r"
108107
)
109108
update_axes(ax, m)
110109

111110
# %%
112-
# Contours closed which contains several eddies
113-
ax = start_axes("ADT contour reject but which contain eddies")
111+
# Some closed contours contains several eddies (aka, more than one extremum)
112+
ax = start_axes("ADT rejected contours containing eddies")
114113
g.contours.label_contour_unused_which_contain_eddies(a)
115114
g.contours.label_contour_unused_which_contain_eddies(c)
116115
g.contours.display(
117-
ax, only_contain_eddies=True, color="k", lw=1, label="Could be interaction contour"
116+
ax, only_contain_eddies=True, color="k", lw=1, label="Could be a contour of interaction"
118117
)
119-
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
120-
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
118+
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
119+
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
121120
ax.legend()
122121
update_axes(ax)
123122

124123
# %%
125124
# Output
126125
# ------
127-
# Display detected eddies, dashed lines represent effective contour
128-
# and solid lines represent contour of maximum of speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
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
129127

130-
ax = start_axes("Eddies detected")
131-
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
132-
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
128+
ax = start_axes("Detected Eddies")
129+
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
130+
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
133131
ax.legend()
134132
update_axes(ax)
135133

136134
# %%
137-
# Display speed radius of eddies detected
138-
ax = start_axes("Eddies speed radius (km)")
139-
a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)
140-
m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)
135+
# Display the speed radius of the detected eddies
136+
ax = start_axes("Speed Radius (km)")
137+
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)
141139
update_axes(ax, m)
142140

143141
# %%
144-
# Display speed radius of eddies detected with filled eddy contours
145-
ax = start_axes("Eddies speed radius (km)")
142+
# Filling the effective radius contours with the effective radius values
143+
ax = start_axes("Effective Radius (km)")
146144
kwargs = dict(vmin=10, vmax=80, cmap="magma_r", factor=0.001, lut=14, ref=-10)
147145
a.filled(ax, "radius_e", **kwargs)
148146
m = c.filled(

examples/02_eddy_identification/pet_eddy_detection_gulf_stream.py

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ def start_axes(title):
2121
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
2222
ax.set_xlim(279, 304), ax.set_ylim(29, 44)
2323
ax.set_aspect("equal")
24-
ax.set_title(title)
24+
ax.set_title(title, weight="bold")
2525
return ax
2626

2727

2828
def update_axes(ax, mappable=None):
2929
ax.grid()
3030
if mappable:
31-
plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))
31+
plt.colorbar(mappable, cax=ax.figure.add_axes([0.94, 0.05, 0.01, 0.9]))
3232

3333

3434
# %%
35-
# Load Input grid, ADT will be used to detect eddies
35+
# Load Input grid, ADT is used to detect eddies
3636
margin = 30
3737
g = RegularGridDataset(
3838
data.get_path("nrt_global_allsat_phy_l4_20190223_20190226.nc"),
@@ -46,108 +46,106 @@ def update_axes(ax, mappable=None):
4646
)
4747

4848
ax = start_axes("ADT (m)")
49-
m = g.display(ax, "adt", vmin=-0.15, vmax=1)
49+
m = g.display(ax, "adt", vmin=-1, vmax=1, cmap="RdBu_r")
5050
# Draw line on the gulf stream front
5151
great_current = Contours(g.x_c, g.y_c, g.grid("adt"), levels=(0.35,), keep_unclose=True)
5252
great_current.display(ax, color="k")
5353
update_axes(ax, m)
5454

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

6161
# %%
6262
# Pre-processings
6363
# ---------------
64-
# Apply high filter to remove long scale to highlight mesoscale
64+
# Apply a high-pass filter to remove the large scale and highlight the mesoscale
6565
g.bessel_high_filter("adt", 700)
6666
ax = start_axes("ADT (m) filtered (700km)")
67-
m = g.display(ax, "adt", vmin=-0.25, vmax=0.25)
67+
m = g.display(ax, "adt", vmin=-0.4, vmax=0.4, cmap="RdBu_r")
6868
great_current.display(ax, color="k")
6969
update_axes(ax, m)
7070

7171
# %%
7272
# Identification
7373
# --------------
74-
# run identification with slice of 2 mm
74+
# Run the identification step with slices of 2 mm
7575
date = datetime(2016, 5, 15)
7676
a, c = g.eddy_identification("adt", "u", "v", date, 0.002, shape_error=55)
7777

7878
# %%
79-
# All closed contour found in this input grid (Display only 1 contour every 5)
80-
ax = start_axes("ADT closed contour (only 1 / 5 levels)")
79+
# Display of all closed contours found in the grid (only 1 contour every 5)
80+
ax = start_axes("ADT closed contours (only 1 / 5 levels)")
8181
g.contours.display(ax, step=5, lw=1)
8282
great_current.display(ax, color="k")
8383
update_axes(ax)
8484

8585
# %%
86-
# Contours include in eddies
87-
ax = start_axes("ADT contour used as eddies")
86+
# Contours included in eddies
87+
ax = start_axes("ADT contours used as eddies")
8888
g.contours.display(ax, only_used=True, lw=0.25)
8989
great_current.display(ax, color="k")
9090
update_axes(ax)
9191

9292
# %%
93-
# Post analyse
93+
# Post analysis
9494
# ------------
95-
# Contours reject from several origin (shape error to high, several extremum in contour, ...)
96-
ax = start_axes("ADT contour reject")
95+
# Contours can be rejected for several reasons (shape error to high, several extremum in contour, ...)
96+
ax = start_axes("ADT rejected contours")
9797
g.contours.display(ax, only_unused=True, lw=0.25)
9898
great_current.display(ax, color="k")
9999
update_axes(ax)
100100

101101
# %%
102-
# Contours reject criterion
103-
#
102+
# Criteria for rejecting a contour
104103
# 0. - Accepted (green)
105-
# 1. - Reject for shape error (red)
106-
# 2. - Masked value in contour (blue)
107-
# 3. - Under or over pixel limit bound (black)
104+
# 1. - Rejection for shape error (red)
105+
# 2. - Masked value within contour (blue)
106+
# 3. - Under or over the pixel limit bounds (black)
108107
# 4. - Amplitude criterion (yellow)
109-
ax = start_axes("Contour reject criterion")
110-
g.contours.display(ax, only_unused=True, lw=0.25, display_criterion=True)
108+
ax = start_axes("Contours' rejection criteria")
109+
g.contours.display(ax, only_unused=True, lw=0.5, display_criterion=True)
111110
update_axes(ax)
112111

113112
# %%
114-
# Display shape error of each tested contour, the limit of shape error is set to 55 %
113+
# Display the shape error of each tested contour, the limit of shape error is set to 55 %
115114
ax = start_axes("Contour shape error")
116115
m = g.contours.display(
117-
ax, lw=0.5, field="shape_error", bins=arange(20, 90.1, 5), cmap="seismic"
116+
ax, lw=0.5, field="shape_error", bins=arange(20, 90.1, 5), cmap="PRGn_r"
118117
)
119118
update_axes(ax, m)
120119

121120
# %%
122-
# Contours closed which contains several eddies
123-
ax = start_axes("ADT contour reject but which contain eddies")
121+
# Some closed contours contains several eddies (aka, more than one extremum)
122+
ax = start_axes("ADT rejected contours containing eddies")
124123
g.contours.label_contour_unused_which_contain_eddies(a)
125124
g.contours.label_contour_unused_which_contain_eddies(c)
126125
g.contours.display(
127-
ax, only_contain_eddies=True, color="k", lw=1, label="Could be interaction contour"
126+
ax, only_contain_eddies=True, color="k", lw=1, label="Could be a contour of interaction"
128127
)
129-
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
130-
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
128+
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
129+
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
131130
ax.legend()
132131
update_axes(ax)
133132

134133
# %%
135134
# Output
136135
# ------
137-
# Display detected eddies, dashed lines represent effective contour
138-
# and solid lines represent contour of maximum of speed. See figure 1 of https://doi.org/10.1175/JTECH-D-14-00019.1
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
139137

140138
ax = start_axes("Eddies detected")
141-
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
142-
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
139+
a.display(ax, color="r", linewidth=0.75, label="Anticyclonic", ref=-10)
140+
c.display(ax, color="b", linewidth=0.75, label="Cyclonic", ref=-10)
143141
ax.legend()
144142
great_current.display(ax, color="k")
145143
update_axes(ax)
146144

147145

148146
# %%
149-
# Display speed radius of eddies detected
150-
ax = start_axes("Eddies speed radius (km)")
147+
# Display the effective radius of the detected eddies
148+
ax = start_axes("Effective radius (km)")
151149
a.filled(ax, "radius_e", vmin=10, vmax=150, cmap="magma_r", factor=0.001, lut=14)
152150
m = c.filled(ax, "radius_e", vmin=10, vmax=150, cmap="magma_r", factor=0.001, lut=14)
153151
great_current.display(ax, color="k")

0 commit comments

Comments
 (0)