Skip to content

Commit 2c78c22

Browse files
committed
- Allow to hide path in GUIEddy
- Iter obs on intern field or outter array
1 parent d123d37 commit 2c78c22

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

src/py_eddy_tracker/appli/gui.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def setup(self, cmap="jet", nb_step=25, figsize=(8, 6), **kwargs):
4444
self.fig = pyplot.figure(figsize=figsize, **kwargs)
4545
t0, t1 = self.period
4646
self.fig.suptitle(f"{t0} -> {t1}")
47-
self.ax = self.fig.add_axes((0.05, 0.05, 0.9, 0.9))
47+
self.ax = self.fig.add_axes((0.05, 0.05, 0.9, 0.9), projection="full_axes")
4848
self.ax.set_xlim(x_min, x_max), self.ax.set_ylim(y_min, y_max)
4949
self.ax.set_aspect("equal")
5050
self.ax.grid()
@@ -192,6 +192,11 @@ def anim():
192192
parser.add_argument(
193193
"--infinity_loop", action="store_true", help="Press Escape key to stop loop"
194194
)
195+
parser.add_argument(
196+
"--first_centered",
197+
action="store_true",
198+
help="Longitude will be centered on first obs, if there are only one group.",
199+
)
195200
args = parser.parse_args()
196201
variables = ["time", "track", "longitude", "latitude"]
197202
variables.extend(TrackEddiesObservations.intern(args.intern, public_label=True))
@@ -203,6 +208,14 @@ def anim():
203208
"You need to specify id to display or ask explicity all with --all option"
204209
)
205210
eddies = eddies.extract_ids(args.id)
211+
if args.first_centered:
212+
# TODO: include observatin class
213+
x0 = eddies.lon[0]
214+
eddies.lon[:] = (eddies.lon - x0 + 180) % 360 + x0 - 180
215+
eddies.contour_lon_e[:] = (
216+
(eddies.contour_lon_e.T - eddies.lon + 180) % 360 + eddies.lon - 180
217+
).T
218+
206219
a = Anim(
207220
eddies,
208221
intern=args.intern,
@@ -217,6 +230,7 @@ def gui_parser():
217230
parser = EddyParser("Eddy atlas GUI")
218231
parser.add_argument("atlas", nargs="+")
219232
parser.add_argument("--med", action="store_true")
233+
parser.add_argument("--nopath", action="store_true", help="Don't draw path")
220234
return parser.parse_args()
221235

222236

@@ -228,4 +242,5 @@ def guieddy():
228242
g = GUI(**atlas)
229243
if args.med:
230244
g.med()
245+
g.hide_path(not args.nopath)
231246
g.show()

src/py_eddy_tracker/appli/network.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def divide_network():
5353
args = parser.parse_args()
5454
contour_name = TrackEddiesObservations.intern(args.intern, public_label=True)
5555
e = TrackEddiesObservations.load_file(
56-
args.input, include_vars=("time", "track", *contour_name)
56+
args.input,
57+
include_vars=("time", "track", "latitude", "longitude", *contour_name),
5758
)
58-
e.split_network(intern=args.intern, window=args.window)
59-
# split_network(args.input, args.out)
59+
ids = e.split_network(intern=args.intern, window=args.window)
6060

6161

6262
def split_network(input, output):

src/py_eddy_tracker/dataset/grid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,9 @@ def setup_coordinates(self):
11631163

11641164
@classmethod
11651165
def with_array(cls, coordinates, datas, variables_description=None, **kwargs):
1166+
"""
1167+
Geo matrix data must be ordered like this (X,Y) and masked with numpy.ma.array
1168+
"""
11661169
vd = dict() if variables_description is None else variables_description
11671170
x_name, y_name = coordinates[0], coordinates[1]
11681171
obj = cls("array", x_name, y_name, unset=True, **kwargs)

src/py_eddy_tracker/gui.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ def setup(self):
146146
# param
147147
self.param_ax = self.figure.add_axes((0, 0, 1, 0.15), facecolor="0.2")
148148

149+
def hide_path(self, state):
150+
for name in self.datasets:
151+
self.m[name]["path_previous"].set_visible(state)
152+
self.m[name]["path_future"].set_visible(state)
153+
149154
def draw(self):
150155
self.m["mini_ax"] = self.figure.add_axes((0.3, 0.85, 0.4, 0.15), zorder=80)
151156
self.m["mini_ax"].grid()

src/py_eddy_tracker/observations/observation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,16 +456,16 @@ def __iter__(self):
456456
for obs in self.obs:
457457
yield obs
458458

459-
def iter_on(self, xname: str, bins=None):
459+
def iter_on(self, xname, bins=None):
460460
"""
461461
Yield observation group for each bin.
462462
463-
:param str xname:
463+
:param str,array xname:
464464
:param array bins: bounds of each bin ,
465465
:return: Group observations
466466
:rtype: self.__class__
467467
"""
468-
x = self[xname]
468+
x = self[xname] if isinstance(xname, str) else xname
469469
d = x[1:] - x[:-1]
470470
if bins is None:
471471
bins = arange(x.min(), x.max() + 2)

0 commit comments

Comments
 (0)