.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/oceanography/plot_07_sandstrom_helland_hansen_dynamic_method.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 JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_oceanography_plot_07_sandstrom_helland_hansen_dynamic_method.py: Sandström and Helland-Hansen's dynamic method (1903) ==================================================== Johan Sandström and Bjørn Helland-Hansen showed how to compute currents from temperature and salinity alone. Light water stands higher than dense water, so the sea surface above a warm station rises relative to a cold one until the pressure at a deep level of no motion is the same under both. The surface slope then drives a geostrophic current. .. GENERATED FROM PYTHON SOURCE LINES 11-42 .. image-sg:: /api/gallery/oceanography/images/sphx_glr_plot_07_sandstrom_helland_hansen_dynamic_method_001.png :alt: Dynamic method: surface current 0.68 m/s :srcset: /api/gallery/oceanography/images/sphx_glr_plot_07_sandstrom_helland_hansen_dynamic_method_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none surface height difference 58 cm, current 0.68 m/s | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.atmosphere import coriolis_parameter from earthsciencekit.constants import GRAVITY from earthsciencekit.oceanography import geostrophic_current, hydrostatic_pressure, linear_density reference, distance = 1027.0, 100e3 depth = np.linspace(0, 1000, 2001) stations = {"warm": 15 * np.exp(-depth / 300), "cold": 5 * np.exp(-depth / 300)} density = {name: linear_density(reference, anomaly, 0, 2e-4, 7.6e-4) for name, anomaly in stations.items()} height = {name: np.trapezoid(reference - rho, depth) / reference for name, rho in density.items()} bottom = { name: hydrostatic_pressure(reference, height[name], GRAVITY) + GRAVITY * np.trapezoid(rho, depth) for name, rho in density.items() } assert np.isclose(bottom["warm"], bottom["cold"]) slope = (height["warm"] - height["cold"]) / distance speed = geostrophic_current(slope, coriolis_parameter(np.radians(35)), GRAVITY) assert 0.3 < speed < 2 print(f"surface height difference {100 * (height['warm'] - height['cold']):.0f} cm, current {speed:.2f} m/s") fig, ax = plt.subplots() for name, rho in density.items(): ax.plot(rho, depth, label=f"{name} station") ax.invert_yaxis() ax.set(xlabel="density [kg/m^3]", ylabel="depth [m]", title=f"Dynamic method: surface current {speed:.2f} m/s") ax.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.085 seconds) .. _sphx_glr_download_api_gallery_oceanography_plot_07_sandstrom_helland_hansen_dynamic_method.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../lite/lab/index.html?path=api/gallery/oceanography/plot_07_sandstrom_helland_hansen_dynamic_method.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_07_sandstrom_helland_hansen_dynamic_method.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_07_sandstrom_helland_hansen_dynamic_method.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_07_sandstrom_helland_hansen_dynamic_method.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_