11"""
2- Eddy detection : Antartic circum polar
3- ======================================
2+ Eddy detection : Antartic Circumpolar Current
3+ =============================================
44
5- Script will detect eddies on adt field, and compute u,v with method add_uv(which could use, only if equator is avoid )
5+ This script detect eddies on the ADT field, and compute u,v with the method add_uv ( use it only if the Equator is avoided )
66
7- Two ones with filtering adt and another without
7+ Two detections are provided : with a filtered ADT and without filtering
88
99"""
1010from datetime import datetime
1111
1212from matplotlib import pyplot as plt
13+ from matplotlib import style
1314
1415from py_eddy_tracker import data
1516from py_eddy_tracker.dataset.grid import RegularGridDataset
1617
18+ pos_cb = [0.1, 0.52, 0.83, 0.015]
19+ pos_cb2 = [0.1, 0.07, 0.4, 0.015]
20+
1721
1822def quad_axes(title):
19- fig = plt.figure(figsize=(13, 8.5))
20- fig.suptitle(title, weight="bold")
23+ style.use("default")
24+ fig = plt.figure(figsize=(13, 10))
25+ fig.suptitle(title, weight="bold", fontsize=14)
2126 axes = list()
22- for position in (
23- [0.05, 0.53, 0.44, 0.44],
24- [0.53, 0.53, 0.44, 0.44],
25- [0.05, 0.03, 0.44, 0.44],
26- [0.53, 0.03, 0.44, 0.44],
27- ):
27+
28+ ax_pos = dict(
29+ topleft=[0.1, 0.54, 0.4, 0.38],
30+ topright=[0.53, 0.54, 0.4, 0.38],
31+ botleft=[0.1, 0.09, 0.4, 0.38],
32+ botright=[0.53, 0.09, 0.4, 0.38],
33+ )
34+
35+ for key, position in ax_pos.items():
2836 ax = fig.add_axes(position)
2937 ax.set_xlim(5, 45), ax.set_ylim(-60, -37)
3038 ax.set_aspect("equal"), ax.grid(True)
3139 axes.append(ax)
32- return axes
40+ if "right" in key:
41+ ax.set_yticklabels("")
42+ return fig, axes
43+
44+
45+ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"):
46+ for ax in fig.get_axes():
47+ ax.grid()
48+ ax.grid(which="major", linestyle="-", linewidth="0.5", color="black")
49+ if ax.get_ylabel() != "":
50+ ax.set_ylabel(ax.get_ylabel(), fontsize=labelsize, fontweight=labelweight)
51+ if ax.get_xlabel() != "":
52+ ax.set_xlabel(ax.get_xlabel(), fontsize=labelsize, fontweight=labelweight)
53+ if ax.get_title() != "":
54+ ax.set_title(ax.get_title(), fontsize=labelsize, fontweight=labelweight)
55+ ax.tick_params(labelsize=ticklabelsize)
3356
3457
3558# %%
@@ -69,20 +92,25 @@ def quad_axes(title):
6992# %%
7093# Figures
7194# -------
72- axs = quad_axes("General properties field")
73- m = g_raw.display(axs[0], "adt", vmin=-1, vmax=1, cmap="RdBu_r")
74- axs[0].set_title("ADT(m)")
75- m = g.display(axs[1], "adt_low", vmin=-1, vmax=1, cmap="RdBu_r")
76- axs[1].set_title("ADT (m) large scale with cut at 700 km")
77- m = g.display(axs[2], "adt", vmin=-1, vmax=1, cmap="RdBu_r")
78- axs[2].set_title("ADT (m) high scale with cut at 700 km")
79- cb = plt.colorbar(
80- m, cax=axs[0].figure.add_axes([0.03, 0.51, 0.94, 0.01]), orientation="horizontal"
81- )
82- cb.set_label("ADT(m)", labelpad=-2)
95+ kw_adt = dict(vmin=-1.5, vmax=1.5, cmap=plt.get_cmap("RdBu_r", 30))
96+ fig, axs = quad_axes("General properties field")
97+ m = g_raw.display(axs[0], "adt", **kw_adt)
98+ axs[0].set_title("Total ADT (m)")
99+ m = g.display(axs[1], "adt_low", **kw_adt)
100+ axs[1].set_title("ADT (m) large scale, cutoff at 700 km")
101+ m2 = g.display(axs[2], "adt", cmap=plt.get_cmap("RdBu_r", 20), vmin=-0.5, vmax=0.5)
102+ axs[2].set_title("ADT (m) high-pass filtered, a cutoff at 700 km")
103+ cb = plt.colorbar(m, cax=axs[0].figure.add_axes(pos_cb), orientation="horizontal")
104+ cb.set_label("ADT (m)", labelpad=0)
105+ cb2 = plt.colorbar(m2, cax=axs[2].figure.add_axes(pos_cb2), orientation="horizontal")
106+ cb2.set_label("ADT (m)", labelpad=0)
107+ set_fancy_labels(fig)
108+
109+ # %%
110+ # The large-scale North-South gradient is removed by the filtering step.
83111
84112# %%
85- axs = quad_axes("")
113+ fig, axs = quad_axes("")
86114axs[0].set_title("Without filter")
87115axs[0].set_ylabel("Contours used in eddies")
88116axs[1].set_title("With filter")
@@ -91,13 +119,18 @@ def quad_axes(title):
91119g.contours.display(axs[1], lw=0.5, only_used=True)
92120g_raw.contours.display(axs[2], lw=0.5, only_unused=True)
93121g.contours.display(axs[3], lw=0.5, only_unused=True)
122+ set_fancy_labels(fig)
123+
124+ # %%
125+ # Removing the large-scale North-South gradient reveals closed contours in the
126+ # South-Western corner of the ewample region.
94127
95128# %%
96129kw = dict(ref=-10, linewidth=0.75)
97130kw_a = dict(color="r", label="Anticyclonic ({nb_obs} eddies)")
98131kw_c = dict(color="b", label="Cyclonic ({nb_obs} eddies)")
99132kw_filled = dict(vmin=0, vmax=100, cmap="Spectral_r", lut=20, intern=True, factor=100)
100- axs = quad_axes("Comparison between two detection ")
133+ fig, axs = quad_axes("Comparison between two detections ")
101134# Match with intern/inner contour
102135i_a, j_a, s_a = a_.match(a, intern=True, cmin=0.15)
103136i_c, j_c, s_c = c_.match(c, intern=True, cmin=0.15)
@@ -107,10 +140,8 @@ def quad_axes(title):
107140c_.index(i_c).filled(axs[0], s_c, **kw_filled)
108141m = c.index(j_c).filled(axs[1], s_c, **kw_filled)
109142
110- cb = plt.colorbar(
111- m, cax=axs[0].figure.add_axes([0.03, 0.51, 0.94, 0.01]), orientation="horizontal"
112- )
113- cb.set_label("Similarity index", labelpad=-5)
143+ cb = plt.colorbar(m, cax=axs[0].figure.add_axes(pos_cb), orientation="horizontal")
144+ cb.set_label("Similarity index (%)", labelpad=-5)
114145a_.display(axs[0], **kw, **kw_a), c_.display(axs[0], **kw, **kw_c)
115146a.display(axs[1], **kw, **kw_a), c.display(axs[1], **kw, **kw_c)
116147
@@ -124,6 +155,12 @@ def quad_axes(title):
124155
125156for ax in axs:
126157 ax.legend()
158+
159+ set_fancy_labels(fig)
160+
161+ # %%
162+ # Very similar eddies have Similarity Indexes >= 40%
163+
127164# %%
128165# Criteria for rejecting a contour :
129166# 0. Accepted (green)
@@ -140,10 +177,10 @@ def quad_axes(title):
140177
141178for i, (label, field, factor, stop) in enumerate(
142179 (
143- ("speed radius (km)", "radius_s", 0.001, 120),
144- ("outter radius (km)", "radius_e", 0.001, 120),
145- ("amplitude (cm)", "amplitude", 100, 25),
146- ("speed max (cm/s)", "speed_average", 100, 25),
180+ ("Speed radius (km)", "radius_s", 0.001, 120),
181+ ("Effective radius (km)", "radius_e", 0.001, 120),
182+ ("Amplitude (cm)", "amplitude", 100, 25),
183+ ("Speed max (cm/s)", "speed_average", 100, 25),
147184 )
148185):
149186 ax = fig.add_subplot(2, 2, i + 1, title=label)
@@ -166,3 +203,5 @@ def quad_axes(title):
166203 ax.plot((0, 1000), (0, 1000), "g")
167204 ax.set_xlim(0, stop), ax.set_ylim(0, stop)
168205 ax.legend()
206+
207+ set_fancy_labels(fig)
0 commit comments