.. 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_radius_vs_area.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_radius_vs_area.py: Radius vs area ============== .. GENERATED FROM PYTHON SOURCE LINES 6-14 .. code-block:: Python from matplotlib import pyplot as plt from numpy import array, pi from py_eddy_tracker import data from py_eddy_tracker.generic import coordinates_to_local from py_eddy_tracker.observations.observation import EddiesObservations from py_eddy_tracker.poly import poly_area .. GENERATED FROM PYTHON SOURCE LINES 15-16 Load detection files .. GENERATED FROM PYTHON SOURCE LINES 16-26 .. code-block:: Python a = EddiesObservations.load_file(data.get_demo_path("Anticyclonic_20190223.nc")) areas = list() # For each contour area will be compute in local reference for i in a: x, y = coordinates_to_local( i["contour_lon_s"], i["contour_lat_s"], i["lon"], i["lat"] ) areas.append(poly_area(x, y)) areas = array(areas) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Radius provided by eddy detection is computed with :func:`~py_eddy_tracker.poly.fit_circle` method. This radius will be compared with an equivalent radius deduced from polygon area. .. GENERATED FROM PYTHON SOURCE LINES 29-38 .. code-block:: Python ax = plt.subplot(111) ax.set_aspect("equal") ax.grid() ax.set_xlabel("Speed radius computed with fit_circle") ax.set_ylabel("Radius deduced from area\nof contour_lon_s/contour_lat_s") ax.set_title("Area vs radius") ax.plot(a["radius_s"] / 1000.0, (areas / pi) ** 0.5 / 1000.0, ".") ax.plot((0, 250), (0, 250), "r") .. image-sg:: /python_module/02_eddy_identification/images/sphx_glr_pet_radius_vs_area_001.png :alt: Area vs radius :srcset: /python_module/02_eddy_identification/images/sphx_glr_pet_radius_vs_area_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 39-40 Fit circle give a radius bigger than polygon area .. GENERATED FROM PYTHON SOURCE LINES 42-43 When error is tiny, radius are very close. .. GENERATED FROM PYTHON SOURCE LINES 43-49 .. code-block:: Python ax = plt.subplot(111) ax.grid() ax.set_xlabel("Radius ratio") ax.set_ylabel("Shape error") ax.set_title("err = f(radius_ratio)") ax.plot(a["radius_s"] / (areas / pi) ** 0.5, a["shape_error_s"], ".") .. image-sg:: /python_module/02_eddy_identification/images/sphx_glr_pet_radius_vs_area_002.png :alt: err = f(radius_ratio) :srcset: /python_module/02_eddy_identification/images/sphx_glr_pet_radius_vs_area_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.435 seconds) .. _sphx_glr_download_python_module_02_eddy_identification_pet_radius_vs_area.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_radius_vs_area.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pet_radius_vs_area.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pet_radius_vs_area.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: pet_radius_vs_area.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_