Mean Pressure Weighted#
metpy.calc.mean_pressure_weighted as well as pint’s unit support to perform calculations.
The code below uses example data from our test suite to calculate the pressure-weighted mean temperature over a depth of 500 hPa.
import pandas as pd from metpy.calc import mean_pressure_weighted from metpy.cbook import get_test_data from metpy.units import units
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 height and add units
Calculate the mean pressure weighted temperature over a depth of 500 hPa
Total running time of the script: ( 0 minutes 0.020 seconds)