.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "python_module/02_eddy_identification/pet_interp_grid_on_dataset.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_02_eddy_identification_pet_interp_grid_on_dataset.py: Get mean of grid in each eddies =============================== .. GENERATED FROM PYTHON SOURCE LINES 6-14 .. code-block:: Python from matplotlib import pyplot as plt from py_eddy_tracker import data from py_eddy_tracker.dataset.grid import RegularGridDataset from py_eddy_tracker.observations.observation import EddiesObservations .. GENERATED FROM PYTHON SOURCE LINES 15-31 .. code-block:: Python def start_axes(title): fig = plt.figure(figsize=(13, 5)) ax = fig.add_axes([0.03, 0.03, 0.90, 0.94]) ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46) ax.set_aspect("equal") ax.set_title(title) return ax def update_axes(ax, mappable=None): ax.grid() ax.legend() if mappable: plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9])) .. GENERATED FROM PYTHON SOURCE LINES 32-33 Load detection files and data to interp .. GENERATED FROM PYTHON SOURCE LINES 33-43 .. code-block:: Python a = EddiesObservations.load_file(data.get_demo_path("Anticyclonic_20160515.nc")) c = EddiesObservations.load_file(data.get_demo_path("Cyclonic_20160515.nc")) aviso_map = RegularGridDataset( data.get_demo_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude", ) aviso_map.add_uv("adt") .. rst-class:: sphx-glr-script-out .. code-block:: none File was created with py-eddy-tracker version 'None' but software version is '0.0' File was created with py-eddy-tracker version 'None' but software version is '0.0' We assume pixel position of grid is centered for /home/docs/checkouts/readthedocs.org/user_builds/py-eddy-tracker/conda/latest/lib/python3.12/site-packages/py_eddy_tracker/data/dt_med_allsat_phy_l4_20160515_20190101.nc .. GENERATED FROM PYTHON SOURCE LINES 44-45 Compute and store eke in cm²/s² .. GENERATED FROM PYTHON SOURCE LINES 45-57 .. code-block:: Python aviso_map.add_grid( "eke", (aviso_map.grid("u") ** 2 + aviso_map.grid("v") ** 2) * 0.5 * (100**2) ) eke_kwargs = dict(vmin=1, vmax=1000, cmap="magma_r") ax = start_axes("EKE (cm²/s²)") m = aviso_map.display(ax, "eke", **eke_kwargs) a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10) c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10) update_axes(ax, m) .. image-sg:: /python_module/02_eddy_identification/images/sphx_glr_pet_interp_grid_on_dataset_001.png :alt: EKE (cm²/s²) :srcset: /python_module/02_eddy_identification/images/sphx_glr_pet_interp_grid_on_dataset_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 58-59 Get mean of eke in each effective contour .. GENERATED FROM PYTHON SOURCE LINES 59-68 .. code-block:: Python ax = start_axes("EKE mean (cm²/s²)") a.display(ax, color="r", linewidth=0.5, label="Anticyclonic ({nb_obs} eddies)", ref=-10) c.display(ax, color="b", linewidth=0.5, label="Cyclonic ({nb_obs} eddies)", ref=-10) eke = a.interp_grid(aviso_map, "eke", method="mean", intern=False) a.filled(ax, eke, ref=-10, **eke_kwargs) eke = c.interp_grid(aviso_map, "eke", method="mean", intern=False) m = c.filled(ax, eke, ref=-10, **eke_kwargs) update_axes(ax, m) .. image-sg:: /python_module/02_eddy_identification/images/sphx_glr_pet_interp_grid_on_dataset_002.png :alt: EKE mean (cm²/s²) :srcset: /python_module/02_eddy_identification/images/sphx_glr_pet_interp_grid_on_dataset_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.510 seconds) .. _sphx_glr_download_python_module_02_eddy_identification_pet_interp_grid_on_dataset.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/02_eddy_identification/pet_interp_grid_on_dataset.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pet_interp_grid_on_dataset.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pet_interp_grid_on_dataset.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: pet_interp_grid_on_dataset.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_