Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Plot a sounding using MetPy with more advanced features. This will use the same formatting and another dataset from MetPy’s sample data.

New additions

  • Lifted condensation level calculation (LCL)

  • Surface based parcel profile

  • Convective Available Potential Energy (CAPE) and Convective Inhibition (CIN) shaded

  • 0 degree isotherm distinguished

Imports

Obtain Data and Format

Upper air data can be obtained using the siphon package, but for this example we will use some of MetPy’s sample data. as_file_obj=False), skiprows=5, usecols=[0, 1, 2, 3, 6, 7], names=col_names) is necessary due to the formatting of the MetPy sample data. This formatting is not needed when using upper air data obtained via Siphon. Obtaining data with Siphon will be covered in a later notebook.

Downloading file 'may4_sounding.txt' from 'https://github.com/Unidata/MetPy/raw/v1.7.1/staticdata/may4_sounding.txt' to '/home/runner/.cache/metpy/v1.7.1'.

Assign Units

We will pull the data out of the example dataset into individual variables and assign units. This is explained in further detail in the Simple Sounding notebook and in the Metpy documentation.

Create Sounding Plot

/home/runner/micromamba/envs/metpy-cookbook/lib/python3.14/site-packages/scipy/integrate/_ivp/base.py:24: UserWarning: Saturation mixing ratio is undefined for some requested pressure/temperature combinations. Total pressure must be greater than the water vapor saturation pressure for liquid water to be in equilibrium.
  return np.asarray(fun(t, y), dtype=dtype)
<Figure size 900x900 with 1 Axes>