py-eddy-tracker Logo
stable

Installation

  • How do I get set up ?

Toolbox gallery:

  • Py eddy tracker toolbox
  • General features
  • Eddy detection
  • Grid Manipulation
  • Time grid computation
  • Tracking Manipulation
  • Tracking diagnostics
  • External data
  • Polygon tools
  • Network
    • General features
    • Eddy detection
      • Display contour & circle
      • Display identification
      • Radius vs area
      • Shape error gallery
        • Shape error gallery
      • Get mean of grid in each eddies
      • Stastics on identification files
      • Eddy detection : Med
      • Eddy detection : Gulf stream
      • Eddy detection and filter
      • Eddy detection on SLA and ADT
      • Eddy detection : Antartic Circumpolar Current
    • Grid Manipulation
    • Time grid computation
    • Tracking Manipulation
    • Tracking diagnostics
    • External data
    • Polygon tools
    • Network

Grid manipulation

  • Eddy identification
  • Load, Display and Filtering
  • Spectrum

Tracking

  • Tracking
  • Customize tracking

Code

  • API reference
  • Source (Git)
  • Changelog
py-eddy-tracker
  • »
  • Py eddy tracker toolbox »
  • Eddy detection »
  • Shape error gallery
  • Edit on GitHub

Note

Click here to download the full example code or to run this example in your browser via Binder

Shape error gallery¶

Gallery of contours with shape error

from matplotlib import pyplot as plt
from numpy import arange, cos, linspace, radians, sin

from py_eddy_tracker import data
from py_eddy_tracker.dataset.grid import RegularGridDataset
from py_eddy_tracker.eddy_feature import Contours
from py_eddy_tracker.generic import local_to_coordinates

Method to built circle from center coordinates

def build_circle(x0, y0, r):
    angle = radians(linspace(0, 360, 50))
    x_norm, y_norm = cos(angle), sin(angle)
    return local_to_coordinates(x_norm * r, y_norm * r, x0, y0)

We iterate over closed contours and sort with regards of shape error

g = RegularGridDataset(
    data.get_demo_path("dt_med_allsat_phy_l4_20160515_20190101.nc"),
    "longitude",
    "latitude",
)
c = Contours(g.x_c, g.y_c, g.grid("adt") * 100, arange(-50, 50, 0.2))
contours = dict()
for coll in c.iter():
    for current_contour in coll.get_paths():
        _, _, _, aerr = current_contour.fit_circle()
        i = int(aerr // 4) + 1
        if i not in contours:
            contours[i] = list()
        contours[i].append(current_contour)
We assume pixel position of grid is centered for /home/docs/checkouts/readthedocs.org/user_builds/py-eddy-tracker/conda/stable/lib/python3.10/site-packages/pyEddyTracker-3.6.1+0.g9d408e5.dirty-py3.10.egg/py_eddy_tracker/data/dt_med_allsat_phy_l4_20160515_20190101.nc

Shape error gallery¶

For each contour display, we display circle fitted, we work at different latitude circle could have distorsion

fig = plt.figure(figsize=(12, 12))
for i in range(1, 26):
    e_min, e_max = (i - 1) * 4, i * 4
    ax = plt.subplot(5, 5, i, title=f" {e_min} < err < {e_max}")
    ax.xaxis.set_ticklabels([])
    ax.yaxis.set_ticklabels([])
    ax.set_aspect("equal")
    ax.grid()
    if i in contours:
        for contour in contours[i]:
            x, y = contour.lon, contour.lat
            x0, y0, radius, _ = contour.fit_circle()
            if x.shape[0] > 30 and 30000 < radius < 70000:
                # Plot only first contour found
                m = ax.plot(x, y, "r")[0]
                ax.plot(*build_circle(x0, y0, radius), "g--")
                ax.plot(x0, y0, "k.")
                break
plt.tight_layout()
0 < err < 4,  4 < err < 8,  8 < err < 12,  12 < err < 16,  16 < err < 20,  20 < err < 24,  24 < err < 28,  28 < err < 32,  32 < err < 36,  36 < err < 40,  40 < err < 44,  44 < err < 48,  48 < err < 52,  52 < err < 56,  56 < err < 60,  60 < err < 64,  64 < err < 68,  68 < err < 72,  72 < err < 76,  76 < err < 80,  80 < err < 84,  84 < err < 88,  88 < err < 92,  92 < err < 96,  96 < err < 100

Total running time of the script: ( 0 minutes 6.437 seconds)

Launch binder

Download Python source code: pet_shape_gallery.py

Download Jupyter notebook: pet_shape_gallery.ipynb

Gallery generated by Sphinx-Gallery

Previous Next

© Copyright 2019, A. Delepoulle & E. Mason. Revision 9d408e55.

Built with Sphinx using a theme provided by Read the Docs.