.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/climate/plot_13_hansen_ocean_heat_uptake.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_climate_plot_13_hansen_ocean_heat_uptake.py: Hansen's ocean heat uptake (1981) ================================= James Hansen and colleagues projected the warming from rising CO2 with a one-dimensional model whose ocean mixed layer stores heat. They showed that the depth of ocean in contact with the surface sets how fast the warming appears. Until equilibrium, part of the forcing goes into the ocean rather than back to space. The heat stored at any time equals the integrated imbalance between forcing and the radiative restoring. .. GENERATED FROM PYTHON SOURCE LINES 12-37 .. image-sg:: /api/gallery/climate/images/sphx_glr_plot_13_hansen_ocean_heat_uptake_001.png :alt: plot 13 hansen ocean heat uptake :srcset: /api/gallery/climate/images/sphx_glr_plot_13_hansen_ocean_heat_uptake_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.climate import heat_capacity_column, heat_uptake, simulate_one_box from earthsciencekit.units import convert forcing, restoring = 3.7, 1.2 years = np.linspace(0, 60, 601) time = convert(years, "year", "s") fig, (left, right) = plt.subplots(1, 2, figsize=(10, 4)) for depth in [50, 100, 200]: capacity = heat_capacity_column(1025, 3990, depth) anomaly = simulate_one_box(forcing, restoring, capacity, time).values[:, 0] imbalance = forcing - restoring * anomaly stored = np.concatenate([[0], np.cumsum((imbalance[1:] + imbalance[:-1]) / 2 * np.diff(time))]) np.testing.assert_allclose(stored[-1], heat_uptake(capacity, anomaly[-1]), rtol=1e-4) left.plot(years, anomaly, label=f"{depth} m mixed layer") right.plot(years, imbalance, label=f"{depth} m mixed layer") left.set(xlabel="years after step", ylabel="surface warming [K]") right.set(xlabel="years after step", ylabel="heat flux into the ocean [W/m²]") left.legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.206 seconds) .. _sphx_glr_download_api_gallery_climate_plot_13_hansen_ocean_heat_uptake.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/climate/plot_13_hansen_ocean_heat_uptake.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_13_hansen_ocean_heat_uptake.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_13_hansen_ocean_heat_uptake.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_13_hansen_ocean_heat_uptake.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_