MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data. It provides meteorological calculations, data input/output, and specialized plotting capabilities like Skew-T diagrams and station plots. Following semantic versioning, MetPy 1.x releases are backward compatible, with breaking changes reserved for major version increments. The current version is 1.7.1 and it requires Python >= 3.10.
pip install metpyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define quantities with units using `metpy.units`, perform a common meteorological calculation (dewpoint) using `metpy.calc`, and convert units. MetPy's strong unit handling ensures correct calculations.
Consult the MetPy 1.0 API Changes and Upgrade Guide in the official documentation to update argument names. Pass latitude instead of the Coriolis parameter where required.
Adjust code expectations for return types from `metpy.calc` functions when using xarray inputs. Leverage xarray's capabilities for coordinate-aware analysis.
Always attach appropriate units from `metpy.units` (e.g., `from metpy.units import units`) to your data when calling MetPy functions.
Upgrade `typing_extensions` to its latest version: `pip install --upgrade typing_extensions`.
Import the units registry (`from metpy.units import units`) and attach units to your data by multiplying on the left (e.g., `data_array = units.meter * numpy.ma.MaskedArray(...)`).
Explicitly import the specific submodule you intend to use, for example: `import metpy.calc as mpcalc`.
Use the correct meteorological unit string, such as `units.mbar` or `units.hPa` for millibars/hectopascals, after importing `units` from `metpy.units`.
Ensure that `import metpy` (which registers the accessor) or `import metpy.xarray` is executed at the beginning of your script before attempting to use the `.metpy` accessor on an xarray object.