Py-ART: Python ARM Radar Toolkit
Py-ART is an open-source Python library designed for working with weather radar data. It provides tools for reading, processing, visualizing, and analyzing data from a variety of radar formats, including NEXRAD, UF, and ODIM_H5. Version 2.2.0, released recently, continues to build on its foundation with improvements in data handling and integration with other scientific libraries like xradar and cmweather. The project maintains an active release cadence with minor releases and bug fixes.
Common errors
-
ImportError: No module named 'pyart'
cause The Py-ART library is not installed in your active Python environment.fixRun `pip install arm-pyart` to install the library. -
ModuleNotFoundError: No module named 'cartopy'
cause A core dependency of Py-ART, `cartopy` (or `netCDF4`, `xarray`, etc.), is missing or failed to install correctly due to underlying system dependencies.fixInstall the missing package directly (e.g., `pip install cartopy`). If `pip` fails due to binary issues, consider using `conda install -c conda-forge pyart` which often resolves complex dependency chains by providing pre-built binaries. -
AttributeError: 'Radar' object has no attribute 'gate_altitude'
cause Changes in the internal data model or how data attributes are exposed, particularly after the `xradar` integration in v2.0.0, may mean previously accessible attributes have moved or been renamed.fixConsult the Py-ART v2.0.0 release notes and updated documentation regarding changes to the `Radar` object's attributes and methods. Use helper functions or updated methods if available, or access data through the `xarray` dataset wrapped by the `Radar` object. -
TypeError: plot() got an unexpected keyword argument 'cmap'
cause Py-ART transitioned to using `cmweather` for colormaps in v2.0.0, which may alter how colormaps are passed to plotting functions or require specific `cmweather` colormap objects.fixVerify how colormaps are now handled with `cmweather`. You might need to import colormaps from `cmweather.colormaps` or ensure your custom colormaps are compatible with the new plotting interface.
Warnings
- breaking Py-ART v2.0.0 introduced significant internal changes, primarily adopting `xradar` as the main backend for reading radar datasets and utilizing `cmweather` for colormaps. Code relying on direct internal reader implementations or Py-ART's older colormap handling may break.
- breaking As of v1.19.3, Py-ART officially requires Python 3.10 or newer. Installations on older Python versions will fail or result in `ImportError`.
- gotcha Installation of geospatial dependencies like `cartopy` and `netCDF4` can be challenging, often requiring system-level libraries (e.g., GEOS, PROJ, HDF5). `pip` installations might fail without these prerequisites.
Install
-
pip install arm-pyart
Imports
- Radar
from pyart.core import Radar
import pyart; radar = pyart.io.read('file.nc') - RadarDisplay
from pyart.graph.radardisplay import RadarDisplay
import pyart; display = pyart.graph.RadarDisplay(radar)
- read
import pyart; radar = pyart.io.read('file.nc')
Quickstart
import pyart
import matplotlib.pyplot as plt
# Create a dummy radar object for demonstration
radar = pyart.testing.make_empty_ppi_radar(10, 10, 10)
# Initialize a RadarDisplay object
display = pyart.graph.RadarDisplay(radar)
# Plot a PPI (Plan Position Indicator) slice of reflectivity
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111)
display.plot('reflectivity', 0, title='Simulated Reflectivity (PPI)', ax=ax)
plt.show()