climate_indices
Reference implementations of climate indices for drought, wildfire, flood, and energy monitoring, for NumPy arrays and Dask-backed xarray grids.
What it does
climate_indices implements published climate index algorithms. Each one cites its source, and VALIDATION.md records, index by index, what its results are checked against.
The code is a fork of work originally developed by NIDIS/NCEI/NOAA for drought monitoring. It now also covers wildfire (fire weather), flood potential, and the climate-driven part of energy supply and demand, plus power-system reliability and compound-hazard statistics.
Most functions accept NumPy arrays or xarray.DataArray input. The reliability indices take an interruption log instead. With Dask-backed DataArray input, most index routes stay lazy, so large grids can be written to NetCDF or Zarr chunk by chunk. A few routes compute eagerly, such as energy.energy_drought_events() on a one-dimensional series. compound.compound_events_xarray() differs: it rejects a Dask-backed Dataset without computing it, so call .compute() on a bounded subset first. The compatibility matrix lists each route.
An optional compiled Rust backend runs the numerical kernels of many indices behind the same API. Without it, the Python implementation runs.
The library computes indices from data you supply, and index computation makes no network request. The optional aws extra fetches third-party soil rasters for available-water-capacity ingest; treat those tiles as untrusted input.
Quickstart
pip install "climate-indices>=3.2.0"
# or
uv pip install "climate-indices>=3.2.0"
Compute a 3-month Standardized Precipitation Index (SPI) from 30 years of synthetic monthly precipitation:
import numpy as np
import pandas as pd
import xarray as xr
from climate_indices import spi
from climate_indices.vocabulary import Distribution
time = pd.date_range("1990-01-01", periods=360, freq="MS") # 30 years, monthly
precip = xr.DataArray(np.random.default_rng(42).gamma(2.0, 40.0, 360), coords={"time": time}, dims="time")
print(spi(precip, scale=3, distribution=Distribution.gamma)[-12:].values.round(2))
The script prints the last 12 monthly values:
[-0.12 0.37 0.37 0.22 -1.02 -2.19 -0.49 -0.21 0.62 -0.49 -0.34 -0.9 ]
With a DataArray, the function reads the start year, the periodicity, and the calibration period from the time coordinate. The result is a DataArray on the same coordinates.
The first scale - 1 values are missing because the 3-month window is not yet full. Values are standard-normal scores: negative means drier than the calibration period, and positive means wetter.
The library logs progress to stderr; see logging to change the level.
With a plain NumPy array, the same function needs the time information stated explicitly. It returns the same values:
import numpy as np
from climate_indices import spi
from climate_indices.vocabulary import Distribution, Periodicity
precip_mm = np.random.default_rng(42).gamma(2.0, 40.0, 360) # 30 years of monthly values, from 1990
spi_3 = spi(
precip_mm, scale=3, distribution=Distribution.gamma, data_start_year=1990,
calibration_year_initial=1990, calibration_year_final=2019, periodicity=Periodicity.monthly,
)
For a longer walkthrough, open the xarray getting-started notebook or read the quickstart tutorial. To compute indices for many grid cells from NetCDF files, see the command-line examples.
Key features
- NumPy and xarray APIs. DataArray results keep coordinates and carry CF metadata. See the compatibility matrix.
- Gridded computation. SPI, SPEI, EDDI, PNP, PET, and PDSI process a whole
(time, *cells)block in one call. See performance and chunking guidance. - NetCDF, Zarr, and Icechunk output. See writing outputs.
- Fit diagnostics and event extraction.
fit_diagnostics()reports the fitted distribution parameters, andclimate_indices.runsextracts events with duration, magnitude, and peak. - Optional Rust backend. The same public API, checked against the Python implementation. See the architecture notes and the benchmarks.
- Evidence-classified results.
VALIDATION.mdseparates external validation from regression-only coverage. - Command-line interface.
climate_indices --index spi ...computes indices from NetCDF files. See the CLI reference.
Supported indices
Most indices are NumPy functions, and most of those also accept DataArray input. The reliability indices take an interruption log instead. Beta marks an interface that may still change; see API stability.
| Category | Index | Description | Docs |
|---|---|---|---|
| Drought | SPI | Standardized Precipitation Index | algorithms |
| Drought | SPEI | Standardized Precipitation Evapotranspiration Index, from the precipitation minus PET balance | algorithms |
| Drought | SPAI (Beta) | Standardized Precipitation Anomaly Index, for strongly seasonal precipitation | algorithms |
| Drought | Standardized index | The SPI fitting pipeline for any non-negative series, such as streamflow | hydrologic indices |
| Drought | PNP, PCI | Percentage of Normal Precipitation; Precipitation Concentration Index | algorithms |
| Drought | EDDI | Evaporative Demand Drought Index | EDDI |
| Drought | Palmer | PDSI, PHDI, PMDI, Z-Index, and self-calibrating PDSI (scPDSI) | Palmer |
| Evapotranspiration | PET | Potential evapotranspiration: Thornthwaite, Hargreaves-Samani, and FAO-56 Penman-Monteith (the last two estimate reference ETo) | PET |
| Wildfire | KBDI | Keetch-Byram Drought Index, a fuel-dryness index from daily precipitation and maximum temperature | wildfire |
| Wildfire | CFFWIS | Canadian Forest Fire Weather Index System: FFMC, DMC, DC, ISI, BUI, FWI, DSR | wildfire |
| Wildfire | FFWI, HDW, Haines | Fosberg Fire Weather Index, Hot-Dry-Windy Index, Haines Index | wildfire |
| Flood potential | PE, EDI | Effective Precipitation and the Effective Drought Index (not EDDI) | EDI |
| Flood potential | Flood Index, API | Daily accumulated-wetness measures that indicate flood potential, not flooding; flood-event extraction | flood index, flood applications |
| Energy | Degree days, wind | Heating, cooling, and energy degree days; hub-height wind speed | energy |
| Energy | Capacity factors | Wind and temperature-derated PV capacity factor (NumPy only) | energy |
| Energy | SREPI, demand index, SRLI | Standardized energy production, demand, and residual-load indices; run-theory energy-drought events | energy |
| Reliability | SAIFI, SAIDI, CAIDI, MAIFI, MAIFI_E, ASAI | IEEE Std 1366 distribution reliability indices from an interruption log | reliability |
| Compound | Compound hazards | Joint counts, likelihood multiplication factor, conditional probability, event matching, block bootstrap | compound hazards |
Scope notes
- Flood indices measure accumulated wetness that indicates flood potential. They do not model flooding.
- Energy indices describe the climate-driven part of supply and demand, not actual generation or load.
- Reliability indices (IEEE Std 1366) describe past service interruptions. They are not resilience metrics.
- Compound counts and probabilities describe co-occurrence. They make no causal claim. Block-bootstrap p-values are supported only within the scope that
VALIDATION.mdcharacterizes. - Distribution choices, time-scale limits, and per-index validation caveats are in the linked docs and in
VALIDATION.md.
Installation
pip install "climate-indices>=3.2.0" # into the current environment
uv pip install "climate-indices>=3.2.0" # uv, into the current environment
uv add "climate-indices>=3.2.0" # uv, as a dependency of a uv project
python -c "import climate_indices._native" # succeeds when the Rust extension is installed
A missing Rust extension is not an error. climate_indices still imports, and every computation runs the Python implementation.
Upgrading from 2.x? 3.0.0 changes some computed values and exception types without a deprecation period. Each change, and how to detect it, is in docs/deprecations/api-changes.md.
Supported Python versions
Supports Python 3.11–3.15.
Installation details: Rust wheels, source builds, extras, and version history
Version history. 3.0.0 added the fire, flood, and runs modules and the optional Rust backend. 3.1.0 added the compound module and the energy family, promoted the DataArray index APIs to Stable, and added optional Icechunk I/O. 3.1.1 added Output Provenance and requires Python 3.11 or later. 3.2.0 added the reliability module, SPAI, and its pooled-anomaly fit. 3.3.0 adds the drought and suitability namespaces, GEV for SPEI, and Icechunk 2 support. See the CHANGELOG.
Rust wheels. Wheels for Linux (x86-64 and aarch64, manylinux_2_28, so glibc 2.28 or newer), macOS (Apple silicon and Intel), and Windows (x86-64) include the Rust backend. Every other platform, including a Linux system with older glibc, installs the pure-Python wheel. Both carry the same version and the same public API. Results agree within the cross-backend parity tolerance, not necessarily bit for bit.
Source builds. pip install --no-binary climate_indices climate_indices installs from the sdist, which builds the pure-Python wheel and needs no Rust toolchain. To build the extension from a checkout, run uv run maturin develop --release; see the Rust backend notes.
Icechunk. For 3.3.0 and later, use pip install "climate_indices[icechunk]>=3.3.0" to add Icechunk-backed reads and writes. The extra installs icechunk>=2.2,<3 on Python 3.12 or later. See writing outputs and the Icechunk notebook.
Other extras. earthengine adds the xee and earthengine-api packages that some notebooks use, and aws adds the raster dependencies for available-water-capacity ingest. See Earth Engine and Climate Engine.
Documentation
The full documentation is on Read the Docs.
Learn
- Quickstart tutorial and tutorials
- Data requirements: the inputs and units each index expects
- Choosing parameters and checking distribution fit
- Troubleshooting
Notebooks (in notebooks/)
- SPI with xarray, Zarr and Dask, Icechunk
- Palmer indices and EDDI
- Fire weather, flood event, energy, and reliability
Reference and project
- API and CLI reference and algorithm descriptions
- Validation status, benchmarks, and architecture decision records
- Changelog
- Rust crate: the numerical kernels as a standalone crate on crates.io
- License, disclaimer, and citation metadata
API stability
The NumPy index functions and the xarray index functions that accept a DataArray are Stable, except the Beta routes below. Stable routes follow semantic versioning, with no breaking changes in minor releases. The Beta routes are the compound Dataset routes, the eager compound event catalogs, SPAI (NumPy and DataArray), and energy.energy_drought_events() with DataArray input. Their interfaces may change in minor releases but not in patch releases, and most of them emit BetaFeatureWarning. See the compatibility matrix.
Contributing
Contributions are welcome. CONTRIBUTING.md describes the workflow, the scientific standards for new indices, and the checks a pull request must pass. docs/development-guide.md covers the local setup.
To report a bug or suggest an index, open an issue.
Citation
You can cite climate_indices in your projects and research papers via the BibTeX
entry below.
@misc {climate_indices,
author = "James Adams",
title = "climate_indices, an open source Python library providing reference implementations of commonly used climate indices",
url = "https://github.com/monocongo/climate_indices",
month = "may",
year = "2017--"
}
License and disclaimer
Released under the BSD 3-Clause license, with some third-party components under their own terms; see licensing. This repository is a scientific product and is not official communication of NOAA or the U.S. Department of Commerce; read the full disclaimer. The code originated at NIDIS/NCEI/NOAA; see drought.gov.
Metadata
Release files for climate-indices 3.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| climate_indices-3.3.0.tar.gz | 3.3 MB | With provenance | Details for climate_indices-3.3.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| climate_indices-3.3.0-py3-none-any.whl | Python 3 | none | any | Details for climate_indices-3.3.0-py3-none-any.whl |
| climate_indices-3.3.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details for climate_indices-3.3.0-cp311-abi3-win_amd64.whl |
| climate_indices-3.3.0-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details for climate_indices-3.3.0-cp311-abi3-manylinux_2_28_x86_64.whl |
| climate_indices-3.3.0-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details for climate_indices-3.3.0-cp311-abi3-manylinux_2_28_aarch64.whl |
| climate_indices-3.3.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for climate_indices-3.3.0-cp311-abi3-macosx_11_0_arm64.whl |
| climate_indices-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details for climate_indices-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl |
Total release size: 9.4 MB
Release files / climate_indices-3.3.0.tar.gz
| Download URL | climate_indices-3.3.0.tar.gz |
|---|---|
| Size | 3.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07a28340cd344b28b534638a5c72afbb4d9a9f392043ceb6cc0678d5dd9d1fbd
|
|
BLAKE2b-256 checksum How to use checksums |
229defc13770f7cb12cd6fc62262f0b1c1ae7a07b2570989c85d0a1e2c267f53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-py3-none-any.whl
| Download URL | climate_indices-3.3.0-py3-none-any.whl |
|---|---|
| Size | 589.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e82baaf162197bed46140421de3d28c061b9cb6069711a9e8021e3b2f778d6e0
|
|
BLAKE2b-256 checksum How to use checksums |
5d5d063631c42d0d9779354761f57f5ff54bbd81695a6cf03d6e530e4a21bfad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-cp311-abi3-win_amd64.whl
| Download URL | climate_indices-3.3.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8289d8bb7283b9571984d97ae88ce36e143c1d48d6d8f6f4c06fdfb53425ff42
|
|
BLAKE2b-256 checksum How to use checksums |
4b159408b723fba21507bfe8245ff913cbe680dfde07f3b34b54d8ed8b05a1fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | climate_indices-3.3.0-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4c9d2577b4d0d5b8eadf7837d5317169a2e3b68660096d9f973c1f4ee5c98a8e
|
|
BLAKE2b-256 checksum How to use checksums |
a50c51c6319fa4cbc93e817e7121a58620ed3c2fb0aeec0e691914a128282e5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | climate_indices-3.3.0-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
582eb8558a7f6175353a6d7e6af11de5b6a6d7d15b8c8cca4c4ce09c2f6e3044
|
|
BLAKE2b-256 checksum How to use checksums |
1e2fd31486811b5df7610517622c717ff55b8852107a9afd5fd8709fb95c1422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | climate_indices-3.3.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aab5f210763fa364e5825d9218ff06f16121b98c4387db7e2441ab937ebb3c0c
|
|
BLAKE2b-256 checksum How to use checksums |
a5bd661950d261696da1ff8a69ae7bd527f1e96e79317e2db695c49a03c3d7be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / climate_indices-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | climate_indices-3.3.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0a3f54e67c45412dc13cefa3c48dd01014534e1b740fc0172edad4c27d41dabc
|
|
BLAKE2b-256 checksum How to use checksums |
e6bc24f8f3d5cd711ef3e636cd5a79f5f4b630dfccd4d036e136e25414ae6810
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for climate-indices 3.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 7 files in this release have been uploaded with provenance metadata.
Attestation for climate_indices-3.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.