.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_sounding_comparison.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_sounding_comparison.py: Comparing Two Soundings ======================= Two ascents from the same station on the same day, each a :term:`sounding`, framed together so the change between them is the only thing that moves. Norman, Oklahoma on 2013-05-20: the 12Z ascent, and the 17Z :term:`special ` released about three hours before the Moore EF5 tornado. Over those five hours the :term:`cap` erodes from -271 J/kg to nothing while :term:`CAPE` nearly triples. Everything that changed between them lies in the lower troposphere, so ``fit`` is clamped to that layer: both ascents run out the top of the view near 300 hPa, and neither one's own data decides the frame the comparison is read in. .. GENERATED FROM PYTHON SOURCE LINES 19-52 .. code-block:: Python from __future__ import annotations from typing import TYPE_CHECKING import matplotlib.pyplot as plt from tephpy import samples if TYPE_CHECKING: from matplotlib.figure import Figure def main() -> Figure: """Overlay the 12Z and 17Z ascents. Returns ------- matplotlib.figure.Figure The composed figure. """ morning = samples.sounding("norman-12z") afternoon = samples.sounding("norman-17z") fig, ax = plt.subplots(figsize=(8.0, 4.0), subplot_kw={"projection": "tephigram"}) ax.fit(morning, afternoon, pressure=(950.0, 300.0)) ax.plot_sounding(morning, linestyle="--") ax.plot_sounding(afternoon) # The default "best" placement lands on the data where the two traces # converge near the top of the clamped view; the lower left stays open. ax.legend(loc="lower left") return fig .. GENERATED FROM PYTHON SOURCE LINES 54-65 Saving the Figure ----------------- The diagram is drawn as vectors, so it saves at publication quality: .. code-block:: python fig.savefig("sounding-comparison.pdf") It is shown rather than run, so that browsing the gallery writes no files. .. GENERATED FROM PYTHON SOURCE LINES 65-69 .. code-block:: Python if __name__ == "__main__": main() plt.show() .. image-sg:: /gallery/images/sphx_glr_plot_sounding_comparison_001.png :alt: plot sounding comparison :srcset: /gallery/images/sphx_glr_plot_sounding_comparison_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.180 seconds) .. rst-class:: sphx-glr-example-tags 🏷 Tags: overlay, sounding .. _sphx_glr_download_gallery_plot_sounding_comparison.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sounding_comparison.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sounding_comparison.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sounding_comparison.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_