.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/atmosphere/plot_11_bjerknes_forecasting_programme.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_11_bjerknes_forecasting_programme.py: Bjerknes's forecasting programme (1904) ======================================= Vilhelm Bjerknes argued that weather forecasting is a problem of mechanics and physics: seven variables (pressure, density, temperature, humidity and three wind components) and seven equations. The equation of state is the diagnostic one that ties pressure, density and temperature together. Moist air obeys it with the virtual temperature in place of temperature, so it is lighter than dry air at the same pressure and temperature. The check is that the result equals the sum of Dalton's partial densities. .. GENERATED FROM PYTHON SOURCE LINES 13-36 .. image-sg:: /api/gallery/atmosphere/images/sphx_glr_plot_11_bjerknes_forecasting_programme_001.png :alt: Equation of state at 1013 hPa :srcset: /api/gallery/atmosphere/images/sphx_glr_plot_11_bjerknes_forecasting_programme_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.atmosphere import dry_air_density, mixing_ratio, saturation_vapor_pressure, specific_humidity, virtual_temperature from earthsciencekit.constants import R_DRY_AIR, R_VAPOR pressure = 101325.0 temperature = np.linspace(260, 310, 101) vapor = saturation_vapor_pressure(temperature) q = specific_humidity(mixing_ratio(vapor, pressure)) moist = dry_air_density(pressure, virtual_temperature(temperature, q)) dry = dry_air_density(pressure, temperature) np.testing.assert_allclose(moist, (pressure - vapor) / (R_DRY_AIR * temperature) + vapor / (R_VAPOR * temperature)) assert np.all(moist < dry) fig, ax = plt.subplots() ax.plot(temperature, dry, label="dry air") ax.plot(temperature, moist, ls="--", label="saturated air") ax.set(xlabel="temperature [K]", ylabel="density [kg/m^3]", title=f"Equation of state at {pressure / 100:.0f} hPa") ax.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.077 seconds) .. _sphx_glr_download_api_gallery_atmosphere_plot_11_bjerknes_forecasting_programme.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_11_bjerknes_forecasting_programme.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_11_bjerknes_forecasting_programme.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_11_bjerknes_forecasting_programme.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_11_bjerknes_forecasting_programme.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_