precip-index is a lightweight set of Python scripts for calculating precipitation-based climate indices (SPI and SPEI) and analyzing dry and wet extremes using run theory, designed for gridded xarray workflows.
📚 Documentation: https://bennyistanto.github.io/precip-index/
- SPI / SPEI at 1, 3, 6, 12, 24-month scales (xarray + CF-compliant NetCDF outputs)
- Bidirectional extremes: drought (dry) and flood-prone (wet) conditions in one framework
- Multi-distribution fitting: Gamma, Pearson Type III, Log-Logistic
- Run theory events: duration, magnitude, intensity, peak, interarrival + gridded summaries
- Operational mode: save fitted parameters, load and apply to new data without refitting
- Scalable processing: chunked tiling, memory estimation, streaming I/O for global datasets
- Visualization: event-highlighted time series, 11-category WMO classification, spatial maps
- Dry + wet symmetry: same API and methodology for negative (drought) and positive (wet) thresholds
- Distribution-aware SPI/SPEI: choose the best-fit distribution per workflow (Gamma / P-III / Log-Logistic)
- Production-ready monitoring: calibrate once, save parameters, apply consistently to new observations
- Event analytics included: run theory metrics beyond simple threshold exceedance
- Designed for large grids: practical for CHIRPS / ERA5-Land / TerraClimate via chunked processing
SPI-12 (Gamma) calculated from CHIRPS v3 at 0.05° resolution.
SPEI-12 (Pearson III) calculated from TerraClimate at 0.0417° ~ 4km resolution.
Benny Istanto, GOST/DEC Data Group, The World Bank
Built upon the foundation of climate-indices by James Adams, with substantial additions for multi-distribution support, bidirectional event analysis, operational mode (parameter persistence), and scalable processing.
BSD-3-Clause — see LICENSE for details.


