Registry / data / metpy
library1.7.1pypypi✓ verified 85d ago

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 metpy
INSTALL
IMPORT
SIG · METPY
M
metpy
datapythonv1.7.1
Install
17.9s avg
Import
3124ms
Disk
455MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 17.5s
py 3.11
✓ —
✓ 17.03s
py 3.12
✓ —
✓ 17.25s
py 3.13
✓ —
✓ 17.58s
py 3.9
✕ build_error
✓ 20.13s
455MB installed
● package 455MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

units
from metpy.units import units
Required for unit-aware calculations.
mpcalc
import metpy.calc as mpcalc
Common alias for meteorological calculations.
io
from metpy import io
For reading meteorological data formats like METARs or NEXRAD.
plots
from metpy import plots
For specialized meteorological plots like Skew-T diagrams.

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.

from metpy.units import units import metpy.calc as mpcalc import numpy as np # Define temperature and relative humidity with units temperature = 25 * units.degC relative_humidity = 75 * units.percent # Calculate dewpoint dewpoint = mpcalc.dewpoint_from_relative_humidity(temperature, relative_humidity) print(f"Temperature: {temperature:.1f}") print(f"Relative Humidity: {relative_humidity:.1f}") print(f"Dewpoint: {dewpoint:.1f}") # Example of converting units temp_f = temperature.to('degF') print(f"Temperature in Fahrenheit: {temp_f:.1f}")
Debug
Known issues
breakingThe MetPy 1.0 release introduced significant API changes, particularly in `metpy.calc` functions. Many argument names were changed for consistency (e.g., `rh` to `relative_humidity`, `dewpt` to `dewpoint`). Functions like `geostrophic_wind()` and `ageostrophic_wind()` now expect `latitude` instead of the `coriolis_parameter f`. Code using keyword arguments with old names will break.
fix
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.
affects: >=1.0.0
breakingPrior to MetPy 1.0, many `metpy.calc` functions consistently returned `pint.Quantity` objects even when provided `xarray.DataArray` inputs. From MetPy 1.0 onwards, these functions will now properly return an `xarray.DataArray` when given `xarray.DataArray` input, preserving xarray's coordinate information.
fix
Adjust code expectations for return types from `metpy.calc` functions when using xarray inputs. Leverage xarray's capabilities for coordinate-aware analysis.
affects: >=1.0.0
gotchaMetPy heavily relies on unit-aware quantities provided by the `pint` library. Most MetPy functions explicitly require inputs to have units attached (e.g., `25 * units.degC`). Passing raw numerical arrays without units will often result in a `UnitsError` or incorrect calculations.
fix
Always attach appropriate units from `metpy.units` (e.g., `from metpy.units import units`) to your data when calling MetPy functions.
affects: All versions
gotchaImport errors related to `pint` (MetPy's unit library) can occur if the `typing_extensions` package in your environment is outdated. This conflict prevents proper loading of MetPy's dependencies.
fix
Upgrade `typing_extensions` to its latest version: `pip install --upgrade typing_extensions`.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'MaskedArray' object has no attribute 'units'
MetPy's calculation functions and unit operations require input data to have associated units from the `pint` library. When using NumPy masked arrays, units must be explicitly multiplied on the left side due to a limitation in the ecosystem.
fix
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(...)`).
AttributeError: module 'metpy' has no attribute 'calc'
Importing the top-level `metpy` package does not automatically import all of its submodules, such as `metpy.calc`, `metpy.io`, or `metpy.plots`, to keep the initial import streamlined.
fix
Explicitly import the specific submodule you intend to use, for example: `import metpy.calc as mpcalc`.
UndefinedUnitError: 'mb' is not defined in the unit registry
The unit string provided, 'mb', is not recognized by MetPy's default `pint` unit registry for meteorological contexts; 'mb' often refers to 'millibarn' in particle physics, not 'millibar'.
fix
Use the correct meteorological unit string, such as `units.mbar` or `units.hPa` for millibars/hectopascals, after importing `units` from `metpy.units`.
AttributeError: 'Dataset' object has no attribute 'metpy'
The `metpy` xarray accessor, which provides convenient methods like `.metpy.parse_cf()`, is not registered or activated for the xarray Dataset or DataArray object.
fix
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.
Upgrade
Version history
1.7.1latest on PyPI · released Aug 29, 2025
Audit
Dependencies
numpyrequiredCore numerical operations.
scipyrequiredScientific computing operations.
matplotlibrequiredPlotting and visualization.
pandasrequiredData structures and analysis.
pintrequiredUnit management.
xarrayrequiredLabeled multi-dimensional arrays for data.
pyprojoptionalGeographic projections, used with cross sections and GiniFile interface.
Agent activity
2 hits · last 30 days
node
2
Resources