Skip to main content
v2026.11,986 entries · CC-BY 4.0

MetPy: Python Weather Data Library Guide

MetPy is an open-source Python library for reading weather data formats, unit-aware calculations and meteorological plots; here is what each module does.

Written and maintained by CASRAI Editorial Board

Published

On this page

MetPy is an open-source Python library for working with weather data: it reads common meteorological file formats, performs unit-aware atmospheric calculations, and draws standard meteorological plots. Its documentation describes it as “a collection of tools in Python for reading, visualizing, and performing calculations with weather data”, developed with support from Unidata and the U.S. National Science Foundation, and released under the BSD 3-Clause license.

What MetPy is and what it covers

MetPy sits in the scientific Python ecosystem rather than replacing it. The project’s GitHub page says it aims to provide “GEMPAK-like functionality” in Python, so analysts who learned weather workflows in GEMPAK can reproduce them with NumPy, SciPy, Matplotlib, pandas, Pint and xarray. Those six packages are its required dependencies; pyproj is optional and is used for cross sections, grid spacing and reading GINI satellite files.

The documentation is organised as a User Guide (including xarray and units support), a Reference Guide, an Example Gallery and a Developer’s Guide. The PyPI listing shows the release 1.7.1, published 2025-08-29, which requires Python 3.10 or later; the project documentation also states Python 3.10 or later. The project follows semantic versioning, so a pinned version number carries a defined meaning about compatibility.

The scope is meteorology and atmospheric science: observations, soundings, radar and satellite products, and gridded model fields. It is not a general weather-forecasting system and it does not supply data itself; it reads files and arrays you already have, from your own downloads or institutional archives.

How MetPy is organised in practice

The API reference groups the library into modules. Knowing which module a task belongs to is the quickest way to find the right function.

Module Role according to the API reference
metpy.calc Unit-aware meteorological calculations
metpy.io Reading a variety of meteorological data formats
metpy.plots Meteorological plotting built on Matplotlib
metpy.interpolate Interpolation of data
metpy.units Unit handling with Pint
metpy.xarray Accessors for working with xarray objects

The units layer matters most for correctness. Because MetPy is built on Pint, quantities carry their units, and calculation functions are documented as unit-aware. In a lab or research group this removes a common failure in atmospheric scripts: a pressure in hectopascals passed to a function that expects pascals. A unit mismatch becomes an error or an explicit conversion rather than a silently wrong number. The xarray accessors extend the same idea to labelled gridded datasets, such as those stored in NetCDF files and opened through xarray.

Reading data with metpy.io

The metpy.io module is where raw files enter an analysis. Its documented readers cover several distinct data products, which is the main thing a newcomer needs to match to their own source. The data table below maps each documented reader to the product it reads. In short, GEMPAK files have grid, sounding and surface readers; satellite images in the NWS GINI format use GiniFile; NEXRAD radar data use Level2File for Level 2 and Level3File for Level 3 (NIDS) products; METAR surface reports are parsed by parse_metar_file or parse_metar_to_dataframe; and Weather Prediction Center surface bulletins are handled by parse_wpc_surface_bulletin.

Station-oriented helpers sit alongside the readers: StationLookup, add_station_lat_lon and is_precip_mode. The METAR parser can return a pandas DataFrame directly, so observation tables can move on into time-series work such as pandas time-series operations such as resampling.

Gridded model output is usually not read by metpy.io at all. Model fields typically arrive as NetCDF or similar files opened with xarray, and MetPy then adds units and coordinate handling through its accessor. If your files follow the CF conventions, the metadata that identifies variables, units and coordinates is already in a standard form; command-line tools such as the Climate Data Operators are a common way to subset or regrid such files before analysis.

Calculations in metpy.calc

The calc module documents its functions in named groups. Each entry below is a function listed in the API reference with its one-line description.

Thermodynamics

Dry thermodynamics includes potential_temperature, dry_lapse, density, geopotential_to_height and height_to_geopotential. Moist thermodynamics includes dewpoint, dewpoint_from_relative_humidity, mixing_ratio, equivalent_potential_temperature, saturation_vapor_pressure, precipitable_water, moist_lapse and wet_bulb_temperature (documented as using Normand’s rule).

Soundings

For vertical profiles the module offers lcl (lifted condensation level), lfc (level of free convection), ccl (convective condensation level and convective temperature), cape_cin, lifted_index, total_totals_index, bulk_shear and bunkers_storm_motion, which calculates right-mover and left-mover supercell storm motions with the Bunkers method.

Dynamics and kinematics

Wind and flow functions include wind_speed, wind_direction, wind_components, vorticity, absolute_vorticity, divergence, advection and geostrophic_wind.

Other groups

The boundary-layer and turbulence group has brunt_vaisala_frequency, gradient_richardson_number, friction_velocity and tke (turbulence kinetic energy). Mathematical functions include gradient, laplacian, first_derivative, second_derivative and projection-aware versions such as geospatial_gradient and geospatial_laplacian, with lat_lon_grid_deltas for the real spacing between latitude and longitude grid points. Apparent-temperature functions are apparent_temperature, heat_index and windchill. Smoothing functions include smooth_gaussian, smooth_window, smooth_rectangular, smooth_circular and smooth_n_point, and standard-atmosphere helpers convert altimeter settings to station and sea-level pressure.

Plotting with metpy.plots

The plots module is documented as covering both classic diagrams and map plotting. Diagram classes include SkewT (Skew-T log-P plots), Stuve, Emagram and Hodograph (wind data). StationPlot makes a standard meteorological station plot, and StationPlotLayout encapsulates a reusable layout. A declarative layer (PanelContainer, MapPanel, Plots2D with ContourPlot, FilledContourPlot, RasterPlot, ImagePlot, BarbPlot, ArrowPlot and PlotObs) builds map panels from traits. Front symbols such as ColdFront, WarmFront, OccludedFront and StationaryFront are provided as Matplotlib path effects for surface analysis charts, and convert_gempak_color translates GEMPAK colour numbers to Matplotlib colours, which eases migration of older GEMPAK-style plots.

Where MetPy matters for research groups and instrument-data workflows

For a group that processes atmospheric observations, MetPy’s value is mostly procedural. Reader choice is determined by the file type you hold, so a mixed archive of surface reports, radar volumes and satellite images needs several readers from the same module rather than several separate libraries. The data table below lists them side by side. A worked scenario, offered as an illustration rather than a case study: a student receives a folder of METAR text reports and a set of NEXRAD Level 3 products. The METAR files go through parse_metar_to_dataframe to obtain a table, the radar products go through Level3File, and the derived quantities, such as dewpoint or wind components, come from metpy.calc with units attached. Each step is a documented function, so the pipeline can be described in a methods section and repeated by a colleague.

For procurement and lab-management purposes the library has no licence fee, since it is distributed under the BSD 3-Clause license, and its source is public on GitHub, which makes institutional software review straightforward.

A reproducibility checklist for labs and research groups

This checklist is an editorial synthesis of the project’s published facts, not an official MetPy procedure. It applies the general idea of computational reproducibility to this library.

  1. Record the MetPy version. The release listed on PyPI when checked was 1.7.1, and semantic versioning means a version number tells collaborators what compatibility to expect.
  2. Record the Python version. Documentation and PyPI both state Python 3.10 or later.
  3. Record the dependencies. NumPy, SciPy, Matplotlib, pandas, Pint and xarray are required; note pyproj too if you use cross sections, grid spacing or GiniFile. A pinned environment file is the usual way to do this; see sharing a reproducible conda environment. The PyPI page links a conda-forge package for conda users.
  4. Keep units attached to quantities rather than stripping them early, so that calculation inputs are checkable in code review.
  5. Cite the software. The GitHub repository carries a CITATION.cff file, which citation tools can read.
  6. Note the license. The repository is BSD 3-Clause, which is permissive for reuse in institutional and commercial projects; confirm any obligations with your own technology-transfer or legal office.

Common misunderstandings

MetPy is not a data provider

It reads and processes files; it does not host or deliver weather data. You still need to obtain the radar, satellite, observation or model files from the relevant source.

MetPy does not replace the rest of the stack

Plots are Matplotlib figures and arrays are NumPy or xarray objects. Customisation, saving and export use those libraries’ normal interfaces.

The Python requirement is a floor, not a recommendation

The GitHub page and the PyPI and documentation pages do not state the minimum identically; the documentation and PyPI both say 3.10 or later. Check the metadata of the exact release you install.

Unit-aware does not mean error-proof

Pint can catch dimensional mistakes, but it cannot know whether the right field was passed to a function. Reading each function’s documentation for its expected inputs remains necessary.

Sources

Data: MetPy metpy.io readers and the data products they read

Compiled from the metpy.io module reference and the API index of the MetPy documentation: each documented file reader or parser, the meteorological data product it reads, and the module that provides it. Each row is one named reader; no values were estimated.

MetPy metpy.io readers and the data products they read
Reader or parserData product readModule
GempakGridGEMPAK gridded data filesmetpy.io
GempakSoundingGEMPAK sounding filesmetpy.io
GempakSurfaceGEMPAK surface filesmetpy.io
GiniFileNWS GINI satellite imagesmetpy.io
Level2FileNEXRAD Level 2 radar datametpy.io
Level3FileNEXRAD Level 3 (NIDS) radar productsmetpy.io
parse_metar_fileMETAR surface observation reports (from a file)metpy.io
parse_metar_to_dataframeMETAR surface observation reports (returned as a pandas DataFrame)metpy.io
parse_wpc_surface_bulletinWeather Prediction Center surface bulletinsmetpy.io

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about MetPy: Python Weather Data Library Guide

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →