Use functions from
metpy.calc as well as pint’s unit support to perform calculations.
The code below uses example data from our test suite to calculate the hydrostatic thickness between the surface and 500-hPa level for the provided sounding data.
Upper air data can be obtained using the siphon package, but for this example we will use some of MetPy’s sample data.
Drop any rows with all NaN values for T, Td, winds
Isolate pressure, temperature, and dewpoint and add units
Calculate the relative humidity to compute the mixing ratio
Calculate the thickness from the pressure, temperature, and mixing ratio for the layer from the surface pressure to 500-hPa
Total running time of the script: (0 minutes 0.010 seconds)