.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/atmosphere/plot_08_buys_ballot_law.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_atmosphere_plot_08_buys_ballot_law.py: Buys Ballot's law (1857) ======================== Christophorus Buys Ballot stated the rule from weather maps: in the Northern Hemisphere, stand with your back to the wind and low pressure is on your left. The wind is geostrophic, blowing along the isobars rather than down the pressure gradient, counter-clockwise round a northern low. The geostrophic components are ``v = (dp/dx) / (rho f)`` and ``u = -(dp/dy) / (rho f)``. The check is that, at every point, the wind is perpendicular to the gradient and the low lies to its left. .. GENERATED FROM PYTHON SOURCE LINES 13-36 .. image-sg:: /api/gallery/atmosphere/images/sphx_glr_plot_08_buys_ballot_law_001.png :alt: Geostrophic wind round a low at 50 °N :srcset: /api/gallery/atmosphere/images/sphx_glr_plot_08_buys_ballot_law_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.atmosphere import coriolis_parameter, geostrophic_speed x = np.linspace(-1500e3, 1500e3, 31) X, Y = np.meshgrid(x, x) pressure = 101325 - 2000 * np.exp(-(X**2 + Y**2) / (2 * (500e3) ** 2)) dpdy, dpdx = np.gradient(pressure, x, x) f = coriolis_parameter(np.deg2rad(50)) u, v = -geostrophic_speed(dpdy, 1.2, f), geostrophic_speed(dpdx, 1.2, f) np.testing.assert_allclose(u * dpdx + v * dpdy, 0, atol=1e-12) to_low = -np.stack([dpdx, dpdy]) assert np.all(u * to_low[1] - v * to_low[0] >= 0) fig, ax = plt.subplots(figsize=(5.5, 5)) contours = ax.contour(X / 1e3, Y / 1e3, pressure / 100, levels=10, colors="0.5") ax.clabel(contours, fmt="%.0f") ax.quiver(X[::3, ::3] / 1e3, Y[::3, ::3] / 1e3, u[::3, ::3], v[::3, ::3]) ax.set(xlabel="east [km]", ylabel="north [km]", title="Geostrophic wind round a low at 50 °N", aspect="equal") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.098 seconds) .. _sphx_glr_download_api_gallery_atmosphere_plot_08_buys_ballot_law.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/atmosphere/plot_08_buys_ballot_law.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_08_buys_ballot_law.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_08_buys_ballot_law.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_08_buys_ballot_law.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_