.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "python_module/08_tracking_manipulation/pet_track_anim_matplotlib_animation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_python_module_08_tracking_manipulation_pet_track_anim_matplotlib_animation.py: Track animation with standard matplotlib ======================================== Run in a terminal this script, which allow to watch eddy evolution. You could use also *EddyAnim* script to display/save animation. .. GENERATED FROM PYTHON SOURCE LINES 10-22 .. code-block:: Python import re from matplotlib.animation import FuncAnimation from numpy import arange import py_eddy_tracker_sample from py_eddy_tracker.appli.gui import Anim from py_eddy_tracker.observations.tracking import TrackEddiesObservations # sphinx_gallery_thumbnail_path = '_static/no_image.png' .. GENERATED FROM PYTHON SOURCE LINES 23-41 .. code-block:: Python class VideoAnimation(FuncAnimation): def _repr_html_(self, *args, **kwargs): """To get video in html and have a player""" content = self.to_html5_video() return re.sub( r'width="[0-9]*"\sheight="[0-9]*"', 'width="100%" height="100%"', content ) def save(self, *args, **kwargs): if args[0].endswith("gif"): # In this case gif is used to create thumbnail which is not used but consume same time than video # So we create an empty file, to save time with open(args[0], "w") as _: pass return return super().save(*args, **kwargs) .. GENERATED FROM PYTHON SOURCE LINES 42-43 Load experimental atlas, and we select one eddy .. GENERATED FROM PYTHON SOURCE LINES 43-50 .. code-block:: Python a = TrackEddiesObservations.load_file( py_eddy_tracker_sample.get_demo_path( "eddies_med_adt_allsat_dt2018/Anticyclonic.zarr" ) ) eddy = a.extract_ids([9672]) .. GENERATED FROM PYTHON SOURCE LINES 51-52 Run animation .. GENERATED FROM PYTHON SOURCE LINES 52-61 .. code-block:: Python a = Anim(eddy, intern=True, figsize=(8, 3.5), cmap="magma_r", nb_step=5, dpi=50) a.txt.set_position((17, 34.6)) a.ax.set_xlim(16.5, 23) a.ax.set_ylim(34.5, 37) # arguments to get full animation kwargs = dict(frames=arange(*a.period)[300:800], interval=90) ani = VideoAnimation(a.fig, a.func_animation, **kwargs) .. container:: sphx-glr-animation .. raw:: html .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 12.284 seconds) .. _sphx_glr_download_python_module_08_tracking_manipulation_pet_track_anim_matplotlib_animation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/AntSimi/py-eddy-tracker/master?urlpath=lab/tree/notebooks/python_module/08_tracking_manipulation/pet_track_anim_matplotlib_animation.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pet_track_anim_matplotlib_animation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pet_track_anim_matplotlib_animation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: pet_track_anim_matplotlib_animation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_