1
1
"""
2
- Eddy detection : Antartic circum polar
3
- ======================================
2
+ Eddy detection : Antartic Circumpolar Current
3
+ =============================================
4
4
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 )
6
6
7
- Two ones with filtering adt and another without
7
+ Two detections are provided : with a filtered ADT and without filtering
8
8
9
9
"""
10
10
from datetime import datetime
11
11
12
12
from matplotlib import pyplot as plt
13
+ from matplotlib import style
13
14
14
15
from py_eddy_tracker import data
15
16
from py_eddy_tracker .dataset .grid import RegularGridDataset
16
17
18
+ pos_cb = [0.1 , 0.52 , 0.83 , 0.015 ]
19
+ pos_cb2 = [0.1 , 0.07 , 0.4 , 0.015 ]
20
+
17
21
18
22
def 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 )
21
26
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 ():
28
36
ax = fig .add_axes (position )
29
37
ax .set_xlim (5 , 45 ), ax .set_ylim (- 60 , - 37 )
30
38
ax .set_aspect ("equal" ), ax .grid (True )
31
39
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 )
33
56
34
57
35
58
# %%
@@ -69,20 +92,25 @@ def quad_axes(title):
69
92
# %%
70
93
# Figures
71
94
# -------
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.
83
111
84
112
# %%
85
- axs = quad_axes ("" )
113
+ fig , axs = quad_axes ("" )
86
114
axs [0 ].set_title ("Without filter" )
87
115
axs [0 ].set_ylabel ("Contours used in eddies" )
88
116
axs [1 ].set_title ("With filter" )
@@ -91,13 +119,18 @@ def quad_axes(title):
91
119
g .contours .display (axs [1 ], lw = 0.5 , only_used = True )
92
120
g_raw .contours .display (axs [2 ], lw = 0.5 , only_unused = True )
93
121
g .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.
94
127
95
128
# %%
96
129
kw = dict (ref = - 10 , linewidth = 0.75 )
97
130
kw_a = dict (color = "r" , label = "Anticyclonic ({nb_obs} eddies)" )
98
131
kw_c = dict (color = "b" , label = "Cyclonic ({nb_obs} eddies)" )
99
132
kw_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 " )
101
134
# Match with intern/inner contour
102
135
i_a , j_a , s_a = a_ .match (a , intern = True , cmin = 0.15 )
103
136
i_c , j_c , s_c = c_ .match (c , intern = True , cmin = 0.15 )
@@ -107,10 +140,8 @@ def quad_axes(title):
107
140
c_ .index (i_c ).filled (axs [0 ], s_c , ** kw_filled )
108
141
m = c .index (j_c ).filled (axs [1 ], s_c , ** kw_filled )
109
142
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 )
114
145
a_ .display (axs [0 ], ** kw , ** kw_a ), c_ .display (axs [0 ], ** kw , ** kw_c )
115
146
a .display (axs [1 ], ** kw , ** kw_a ), c .display (axs [1 ], ** kw , ** kw_c )
116
147
@@ -124,6 +155,12 @@ def quad_axes(title):
124
155
125
156
for ax in axs :
126
157
ax .legend ()
158
+
159
+ set_fancy_labels (fig )
160
+
161
+ # %%
162
+ # Very similar eddies have Similarity Indexes >= 40%
163
+
127
164
# %%
128
165
# Criteria for rejecting a contour :
129
166
# 0. Accepted (green)
@@ -140,10 +177,10 @@ def quad_axes(title):
140
177
141
178
for i , (label , field , factor , stop ) in enumerate (
142
179
(
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 ),
147
184
)
148
185
):
149
186
ax = fig .add_subplot (2 , 2 , i + 1 , title = label )
@@ -166,3 +203,5 @@ def quad_axes(title):
166
203
ax .plot ((0 , 1000 ), (0 , 1000 ), "g" )
167
204
ax .set_xlim (0 , stop ), ax .set_ylim (0 , stop )
168
205
ax .legend ()
206
+
207
+ set_fancy_labels (fig )
0 commit comments