{"id":5994,"library":"metpy","title":"MetPy","description":"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.","status":"active","version":"1.7.1","language":"en","source_language":"en","source_url":"https://github.com/Unidata/MetPy","tags":["meteorology","weather data","geospatial","data analysis","visualization","units","atmospheric science"],"install":[{"cmd":"pip install metpy","lang":"bash","label":"PyPI"},{"cmd":"conda install -c conda-forge metpy","lang":"bash","label":"Conda"}],"dependencies":[{"reason":"Core numerical operations.","package":"numpy","optional":false},{"reason":"Scientific computing operations.","package":"scipy","optional":false},{"reason":"Plotting and visualization.","package":"matplotlib","optional":false},{"reason":"Data structures and analysis.","package":"pandas","optional":false},{"reason":"Unit management.","package":"pint","optional":false},{"reason":"Labeled multi-dimensional arrays for data.","package":"xarray","optional":false},{"reason":"Geographic projections, used with cross sections and GiniFile interface.","package":"pyproj","optional":true}],"imports":[{"note":"Required for unit-aware calculations.","symbol":"units","correct":"from metpy.units import units"},{"note":"Common alias for meteorological calculations.","symbol":"mpcalc","correct":"import metpy.calc as mpcalc"},{"note":"For reading meteorological data formats like METARs or NEXRAD.","symbol":"io","correct":"from metpy import io"},{"note":"For specialized meteorological plots like Skew-T diagrams.","symbol":"plots","correct":"from metpy import plots"}],"quickstart":{"code":"from metpy.units import units\nimport metpy.calc as mpcalc\nimport numpy as np\n\n# Define temperature and relative humidity with units\ntemperature = 25 * units.degC\nrelative_humidity = 75 * units.percent\n\n# Calculate dewpoint\ndewpoint = mpcalc.dewpoint_from_relative_humidity(temperature, relative_humidity)\n\nprint(f\"Temperature: {temperature:.1f}\")\nprint(f\"Relative Humidity: {relative_humidity:.1f}\")\nprint(f\"Dewpoint: {dewpoint:.1f}\")\n\n# Example of converting units\ntemp_f = temperature.to('degF')\nprint(f\"Temperature in Fahrenheit: {temp_f:.1f}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Adjust code expectations for return types from `metpy.calc` functions when using xarray inputs. Leverage xarray's capabilities for coordinate-aware analysis.","message":"Prior 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always attach appropriate units from `metpy.units` (e.g., `from metpy.units import units`) to your data when calling MetPy functions.","message":"MetPy 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade `typing_extensions` to its latest version: `pip install --upgrade typing_extensions`.","message":"Import 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}