.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ftle/plot_dg_ftle.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_ftle_plot_dg_ftle.py: Double gyre FTLE ================ Compute the FTLE field for the double gyre. .. GENERATED FROM PYTHON SOURCE LINES 9-18 .. code-block:: Python # Author: ajarvis import numpy as np from math import copysign import matplotlib.pyplot as plt from numbacs.flows import get_predefined_flow from numbacs.integration import flowmap_grid_2D from numbacs.diagnostics import ftle_grid_2D .. GENERATED FROM PYTHON SOURCE LINES 19-22 Get flow -------------- Set the integration span and direction, retrieve the flow, and set up domain. .. GENERATED FROM PYTHON SOURCE LINES 22-38 .. code-block:: Python # set initial time, integration time, and integration direction t0 = 0.0 T = -10.0 int_direction = copysign(1, T) # retrieve function pointer, parameters, and domain for double gyre flow. funcptr, params, domain = get_predefined_flow("double_gyre", int_direction=int_direction) # set up domain nx, ny = 401, 201 x = np.linspace(domain[0][0], domain[0][1], nx) y = np.linspace(domain[1][0], domain[1][1], ny) dx = x[1] - x[0] dy = y[1] - y[0] .. GENERATED FROM PYTHON SOURCE LINES 39-42 Integrate --------- Integrate grid of particles and return final positions. .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: Python flowmap = flowmap_grid_2D(funcptr, t0, T, x, y, params) .. GENERATED FROM PYTHON SOURCE LINES 45-48 FTLE ---- Compute FTLE field from final particle positions. .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: Python ftle = ftle_grid_2D(flowmap, T, dx, dy) .. GENERATED FROM PYTHON SOURCE LINES 51-54 Plot ---- Plot the results. .. GENERATED FROM PYTHON SOURCE LINES 54-58 .. code-block:: Python fig, ax = plt.subplots(dpi=200) ax.contourf(x, y, ftle.T, levels=80) ax.set_aspect("equal") plt.show() .. image-sg:: /auto_examples/ftle/images/sphx_glr_plot_dg_ftle_001.png :alt: plot dg ftle :srcset: /auto_examples/ftle/images/sphx_glr_plot_dg_ftle_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.745 seconds) .. _sphx_glr_download_auto_examples_ftle_plot_dg_ftle.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dg_ftle.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dg_ftle.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_dg_ftle.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_