.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/oceanography/plot_06_knudsen_equation_of_state.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_06_knudsen_equation_of_state.py: Knudsen's equation of state (1901) ================================== Martin Knudsen, with Carl Forch and Søren Sørensen, measured seawater density against temperature and salinity and published the Hydrographical Tables used for the next 70 years. Near a reference state the density is linear in both: warming makes water lighter and salt makes it heavier, so lines of equal density in the temperature-salinity plane have slope ``alpha / beta``. .. GENERATED FROM PYTHON SOURCE LINES 11-28 .. image-sg:: /api/gallery/oceanography/images/sphx_glr_plot_06_knudsen_equation_of_state_001.png :alt: Isopycnals of the linear equation of state [kg/m^3] :srcset: /api/gallery/oceanography/images/sphx_glr_plot_06_knudsen_equation_of_state_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.oceanography import linear_density alpha, beta = 2e-4, 7.6e-4 temperature, salinity = np.meshgrid(np.linspace(-10, 15, 101), np.linspace(-3, 3, 101)) density = linear_density(1027, temperature, salinity, alpha, beta) assert np.isclose(linear_density(1027, 1.0, alpha / beta, alpha, beta), 1027) fig, ax = plt.subplots() contours = ax.contour(salinity, temperature, density, levels=12, cmap="viridis") ax.clabel(contours, fmt="%.1f", fontsize=7) ax.set(xlabel="salinity anomaly [g/kg]", ylabel="temperature anomaly [K]", title="Isopycnals of the linear equation of state [kg/m^3]") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.106 seconds) .. _sphx_glr_download_api_gallery_oceanography_plot_06_knudsen_equation_of_state.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_06_knudsen_equation_of_state.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_06_knudsen_equation_of_state.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_06_knudsen_equation_of_state.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_06_knudsen_equation_of_state.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_