.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "python_module/07_cube_manipulation/pet_particles_drift.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_07_cube_manipulation_pet_particles_drift.py: Build path of particle drifting =============================== .. GENERATED FROM PYTHON SOURCE LINES 6-16 .. code-block:: Python from matplotlib import pyplot as plt from numpy import arange, meshgrid from py_eddy_tracker import start_logger from py_eddy_tracker.data import get_demo_path from py_eddy_tracker.dataset.grid import GridCollection start_logger().setLevel("ERROR") .. GENERATED FROM PYTHON SOURCE LINES 17-18 Load data cube .. GENERATED FROM PYTHON SOURCE LINES 18-26 .. code-block:: Python c = GridCollection.from_netcdf_cube( get_demo_path("dt_med_allsat_phy_l4_2005T2.nc"), "longitude", "latitude", "time", unset=True, ) .. GENERATED FROM PYTHON SOURCE LINES 27-28 Advection properties .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python nb_days, step_by_day = 10, 6 nb_time = step_by_day * nb_days kw_p = dict(nb_step=1, time_step=86400 / step_by_day) t0 = 20210 .. GENERATED FROM PYTHON SOURCE LINES 34-35 Get paths .. GENERATED FROM PYTHON SOURCE LINES 35-39 .. code-block:: Python x0, y0 = meshgrid(arange(32, 35, 0.5), arange(32.5, 34.5, 0.5)) x0, y0 = x0.reshape(-1), y0.reshape(-1) t, x, y = c.path(x0, y0, h_name="adt", t_init=t0, **kw_p, nb_time=nb_time) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/py-eddy-tracker/conda/latest/lib/python3.12/site-packages/numpy/ma/core.py:1020: RuntimeWarning: overflow encountered in multiply result = self.f(da, db, *args, **kwargs) /home/docs/checkouts/readthedocs.org/user_builds/py-eddy-tracker/conda/latest/lib/python3.12/site-packages/numpy/ma/core.py:4365: RuntimeWarning: invalid value encountered in multiply self._data.__imul__(other_data) .. GENERATED FROM PYTHON SOURCE LINES 40-41 Plot paths .. GENERATED FROM PYTHON SOURCE LINES 41-47 .. code-block:: Python ax = plt.figure(figsize=(9, 6)).add_subplot(111, aspect="equal") ax.plot(x0, y0, "k.", ms=20) ax.plot(x, y, lw=3) ax.set_title("10 days particle paths") ax.set_xlim(31, 35), ax.set_ylim(32, 34.5) ax.grid() .. image-sg:: /python_module/07_cube_manipulation/images/sphx_glr_pet_particles_drift_001.png :alt: 10 days particle paths :srcset: /python_module/07_cube_manipulation/images/sphx_glr_pet_particles_drift_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.808 seconds) .. _sphx_glr_download_python_module_07_cube_manipulation_pet_particles_drift.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/07_cube_manipulation/pet_particles_drift.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pet_particles_drift.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pet_particles_drift.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: pet_particles_drift.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_