
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "tutorials/dynamics/plot_dimensionless_numbers.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_tutorials_dynamics_plot_dimensionless_numbers.py>`
        to download the full example code or to run this example in your browser via Binder.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_tutorials_dynamics_plot_dimensionless_numbers.py:


Dimensionless numbers of the Gulf Stream
========================================

In this tutorial, we show how to:

* compute the Rossby number of the surface currents,
* compute the Burger number from the deformation radius of the vertical modes,
  or from the stratification,
* compute the internal Froude number of the upper ocean,
* compute the Ekman number of the surface layer.

The data are 3D fields of the GLORYS12 reanalysis of the Copernicus Marine Service,
averaged over 2 x 2 grid cells, on the 1st of October 2019, in the region of the Gulf Stream.

The concepts are explained in the :ref:`indepth.dyn` guide.
See also: :ref:`sphx_glr_tutorials_dynamics_plot_vertical_modes.py`, :ref:`sphx_glr_tutorials_dynamics_plot_gulfstream_dynamics.py`.

.. GENERATED FROM PYTHON SOURCE LINES 22-24

Initialisations
---------------

.. GENERATED FROM PYTHON SOURCE LINES 24-44

.. code-block:: Python


    import cmocean  # noqa
    import matplotlib.pyplot as plt
    import numpy as np
    import xarray as xr

    import xoa
    import xoa.dyn as xdyn
    import xoa.grid as xgrid
    import xoa.meta as xmeta
    import xoa.numbers as xnum
    import xoa.thermdyn as xthermdyn
    from xoa.plot import plot_fields

    xr.set_options(display_style="text")
    plt.rcParams.update({"font.size": 9, "axes.titlesize": 10, "axes.titleweight": "bold"})
    xmeta.register_meta_specs(xoa.get_meta_config_file("mercator"))

    MAP_KW = {"gridlines_labels_on": ["bottom", "left"], "land": True}








.. GENERATED FROM PYTHON SOURCE LINES 45-47

Read the reanalysis
-------------------

.. GENERATED FROM PYTHON SOURCE LINES 47-54

.. code-block:: Python


    ds = xoa.open_data_sample("MODELS/CMEMS-GLORYS/glorys_gulfstream_3d.nc")
    ds = ds.xoa.decode().isel(time=0)
    temp, sal, u, v = ds.temp, ds.sal, ds.u, ds.v
    n2 = xthermdyn.get_n2(temp, sal)
    open_ocean = n2.notnull().all("depth")








.. GENERATED FROM PYTHON SOURCE LINES 55-61

Rossby number
-------------

The Rossby number :math:`Ro = \zeta / f` compares the relative vorticity to the planetary
one. It is positive for cyclonic rotation and negative for anticyclonic rotation, and
it is of order one for the strongest eddies and meanders.

.. GENERATED FROM PYTHON SOURCE LINES 61-65

.. code-block:: Python


    rossby = xnum.get_rossby(u.isel(depth=0), v.isel(depth=0))
    print(rossby)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    <xarray.DataArray 'rossby' (lat: 48, lon: 60)> Size: 23kB
    array([[-0.03992086, -0.01717691,  0.0136684 , ..., -0.05924675,
            -0.04096741, -0.03333688],
           [-0.03002976,  0.00193462,  0.03910285, ..., -0.06549972,
            -0.0549946 , -0.04780497],
           [-0.01321435,  0.00754309,  0.04554493, ..., -0.04029969,
            -0.07858748, -0.09149936],
           ...,
           [        nan,         nan,         nan, ...,  0.08514452,
             0.04761352,  0.02044885],
           [        nan,         nan,         nan, ...,  0.02098586,
             0.02880013,  0.03931305],
           [        nan,         nan,         nan, ..., -0.02415734,
            -0.00296856,  0.02649398]], shape=(48, 60))
    Coordinates:
      * lat      (lat) float32 192B 34.04 34.21 34.38 34.54 ... 41.54 41.71 41.88
      * lon      (lon) float32 240B -71.96 -71.79 -71.62 ... -62.46 -62.29 -62.12
        depth    float32 4B 0.494
        time     datetime64[ns] 8B 2019-10-01
    Attributes:
        long_name:  Rossby number
        units:      1




.. GENERATED FROM PYTHON SOURCE LINES 66-75

Burger number
-------------

The Burger number :math:`Bu = (R_d / L)^2` compares the deformation radius to the scale
of the flow. We take here a scale of 50 km for the eddies. The deformation radius is either
the one of the first baroclinic vertical mode, the quick WKB estimate of
:func:`xoa.dyn.get_rossby_radius`, or the approximation :math:`N H / |f|` with
the mean stratification of the upper 1000 m, weighted by the layer thicknesses with
:func:`xoa.grid.vmean`.

.. GENERATED FROM PYTHON SOURCE LINES 75-86

.. code-block:: Python


    L = 50e3
    vm = xdyn.VerticalModes(n2, nmodes=2)
    burger = xnum.get_burger(L, rd=vm.rd.isel(mode=1)).where(open_ocean)
    burger_wkb = xnum.get_burger(L, rd=xdyn.get_rossby_radius(n2)).where(open_ocean)

    H = 1000.0
    n_mean = xgrid.vmean(np.sqrt(n2.where(n2 > 0)), zmin=-H)
    n2_mean = n_mean**2
    burger_nh = xnum.get_burger(L, n2=n2_mean, h=H).where(open_ocean)








.. GENERATED FROM PYTHON SOURCE LINES 87-93

Froude number
-------------

The internal Froude number :math:`Fr = U / (N H)` is the speed over the speed of the
internal waves. It is small, i.e. the flow is subcritical, except where the stratification is
weak, like in the mixed layers.

.. GENERATED FROM PYTHON SOURCE LINES 93-97

.. code-block:: Python


    speed = np.hypot(u, v).isel(depth=0)
    froude = xnum.get_froude(speed, n2_mean, H).where(open_ocean)








.. GENERATED FROM PYTHON SOURCE LINES 98-104

Ekman number
------------

The vertical Ekman number :math:`Ek = \nu / (|f| H^2)` is computed for a surface layer of
50 m and a constant eddy viscosity of :math:`10^{-2}` m2 s-1, so it only depends on the
latitude.

.. GENERATED FROM PYTHON SOURCE LINES 104-108

.. code-block:: Python


    ekman = xnum.get_ekman(1e-2, 50.0, u.lat)
    print(float(ekman.min()), float(ekman.max()))





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    0.04120098426938057 0.049128592014312744




.. GENERATED FROM PYTHON SOURCE LINES 109-111

Maps
----

.. GENERATED FROM PYTHON SOURCE LINES 111-134

.. code-block:: Python


    fig, axes = plot_fields(
        [
            (rossby, {"cmap": "cmo.balance", "levels": np.linspace(-0.6, 0.6, 25)}),
            (burger, {"cmap": "cmo.matter", "levels": np.linspace(0, 1, 21)}),
            (burger_wkb, {"cmap": "cmo.matter", "levels": np.linspace(0, 1, 21)}),
            (burger_nh, {"cmap": "cmo.matter", "levels": np.linspace(0, 2, 21)}),
            (froude, {"cmap": "cmo.amp", "levels": np.linspace(0, 0.4, 21)}),
        ],
        titles=[
            "Rossby",
            "Burger from the modes",
            "Burger from the WKB radius",
            "Burger from N H / f",
            "Froude",
        ],
        ncols=3,
        figsize=(10, 6.2),
        map_kw=MAP_KW,
        method="contourf",
        extend="both",
    )




.. image-sg:: /tutorials/dynamics/images/sphx_glr_plot_dimensionless_numbers_001.png
   :alt: Rossby, Burger from the modes, Burger from the WKB radius, Burger from N H / f, Froude
   :srcset: /tutorials/dynamics/images/sphx_glr_plot_dimensionless_numbers_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 135-142

The Rossby number reaches 0.5 along the stream and its eddies, and the Burger number
of the first mode is of order 0.1 to 0.5 for eddies of 50 km, and the WKB radius gives about
the same. The :math:`N H / |f|` estimate has the same spatial pattern but is
several times larger, since the first baroclinic radius is
close to :math:`N H / (\pi |f|)` for a constant stratification: use the radius of the modes
when it is available. The Froude number stays below one, i.e. the flow is subcritical,
and it is largest where the stratification is weak.


.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_tutorials_dynamics_plot_dimensionless_numbers.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/shom-fr/xoa/master?urlpath=lab/tree/notebooks/tutorials/dynamics/plot_dimensionless_numbers.ipynb
        :alt: Launch binder
        :width: 150 px

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_dimensionless_numbers.ipynb <plot_dimensionless_numbers.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_dimensionless_numbers.py <plot_dimensionless_numbers.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_dimensionless_numbers.zip <plot_dimensionless_numbers.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
