.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/elliptic_oecs/plot_qge_elliptic_oecs.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_elliptic_oecs_plot_qge_elliptic_oecs.py: Quasi-geostrophic Elliptic OECS =============================== Compute the IVD-based elliptic OECS for the QGE. .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. code-block:: Python # Author: ajarvis # Data: We thank Changhong Mou and Traian Iliescu for providing us with this dataset # and allowing it to be used here. import numpy as np import matplotlib.pyplot as plt from numbacs.diagnostics import ivd_grid_2D from numbacs.extraction import rotcohvrt from numbacs.utils import curl_vel .. GENERATED FROM PYTHON SOURCE LINES 19-22 Get flow data -------------- Load velocity data, set up domain, and set initial time .. GENERATED FROM PYTHON SOURCE LINES 22-39 .. code-block:: Python # load in qge velocity data u = np.load("../data/qge/qge_u.npy") v = np.load("../data/qge/qge_v.npy") # set up domain nt, nx, ny = u.shape x = np.linspace(0, 1, nx) y = np.linspace(0, 2, ny) t = np.linspace(0, 1, nt) dx = x[1] - x[0] dy = y[1] - y[0] # set initial time t0 = 0.5 k0 = np.argwhere(t == t0)[0][0] .. GENERATED FROM PYTHON SOURCE LINES 40-43 Vorticity --------- Copmute vorticity on the grid and over the times for which the flowmap was returned. .. GENERATED FROM PYTHON SOURCE LINES 43-48 .. code-block:: Python # compute vorticity and create interpolant for it vort = curl_vel(u[k0, :, :], v[k0, :, :], dx, dy) vort_avg = np.mean(vort) .. GENERATED FROM PYTHON SOURCE LINES 49-52 IVD --- Compute IVD from vorticity. .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: Python # compute lavd ivd = ivd_grid_2D(vort, vort_avg) .. GENERATED FROM PYTHON SOURCE LINES 57-60 IVD-based elliptic OECS ----------------------- Compute elliptic OECS from IVD. .. GENERATED FROM PYTHON SOURCE LINES 60-66 .. code-block:: Python # set parameters and compute lavd-based elliptic oecs r = 0.2 convexity_deficiency = 1e-3 min_len = 0.25 elcs = rotcohvrt(ivd, x, y, r, convexity_deficiency=convexity_deficiency, min_len=min_len) .. GENERATED FROM PYTHON SOURCE LINES 67-70 Plot ---- Plot the elliptic OECS over the IVD field. .. GENERATED FROM PYTHON SOURCE LINES 70-79 .. code-block:: Python # sphinx_gallery_thumbnail_number = 1 fig, ax = plt.subplots(dpi=200) ax.contourf(x, y, ivd.T, levels=80) ax.set_aspect("equal") for rcv, c in elcs: ax.plot(rcv[:, 0], rcv[:, 1], lw=1.5) ax.scatter(c[0], c[1], 1.5) plt.show() .. image-sg:: /auto_examples/elliptic_oecs/images/sphx_glr_plot_qge_elliptic_oecs_001.png :alt: plot qge elliptic oecs :srcset: /auto_examples/elliptic_oecs/images/sphx_glr_plot_qge_elliptic_oecs_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.730 seconds) .. _sphx_glr_download_auto_examples_elliptic_oecs_plot_qge_elliptic_oecs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_qge_elliptic_oecs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_qge_elliptic_oecs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_qge_elliptic_oecs.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_