|
8 | 8 | from itertools import chain
|
9 | 9 |
|
10 | 10 | from matplotlib import pyplot
|
| 11 | +from matplotlib.animation import FuncAnimation |
11 | 12 | from matplotlib.collections import LineCollection
|
12 |
| -from numpy import where |
| 13 | +from numpy import arange, where |
13 | 14 |
|
14 | 15 | from .. import EddyParser
|
15 | 16 | from ..gui import GUI
|
|
20 | 21 |
|
21 | 22 |
|
22 | 23 | class Anim:
|
23 |
| - |
24 | 24 | def __init__(
|
25 | 25 | self, eddy, intern=False, sleep_event=0.1, graphic_information=False, **kwargs
|
26 | 26 | ):
|
@@ -262,6 +262,7 @@ def anim():
|
262 | 262 | parser.add_argument(
|
263 | 263 | "--vmax", default=None, type=float, help="Upper bound to color contour"
|
264 | 264 | )
|
| 265 | + parser.add_argument("--avi", help="Filename to save animation (avi)") |
265 | 266 | args = parser.parse_args()
|
266 | 267 | variables = ["time", "track", "longitude", "latitude", args.field]
|
267 | 268 | variables.extend(TrackEddiesObservations.intern(args.intern, public_label=True))
|
@@ -293,7 +294,12 @@ def anim():
|
293 | 294 | range_color=(args.vmin, args.vmax),
|
294 | 295 | graphic_information=logger.getEffectiveLevel() == logging.DEBUG,
|
295 | 296 | )
|
296 |
| - a.show(infinity_loop=args.infinity_loop) |
| 297 | + if args.avi is None: |
| 298 | + a.show(infinity_loop=args.infinity_loop) |
| 299 | + else: |
| 300 | + kwargs = dict(frames=arange(*a.period), interval=50) |
| 301 | + ani = FuncAnimation(a.fig, a.func_animation, **kwargs) |
| 302 | + ani.save(args.avi, fps=30, extra_args=["-vcodec", "libx264"]) |
297 | 303 |
|
298 | 304 |
|
299 | 305 | def gui_parser():
|
|
0 commit comments