A Python library for computing and analyzing various drought indices, designed for researchers and practitioners in climate and hydrology. This package aims to provide robust and scientifically verifiable implementations of key drought indicators.
Currently under active development.
Kumar Puran Tripathy (PhD Student, Texas A&M University) Email: tripathypuranbdk@gmail.com
The drought_indices_python
package offers a growing suite of essential drought indices:
- Potential Evapotranspiration (PET):
calculate_pet_thornthwaite
: Estimates PET using the widely recognized Thornthwaite (1948) method, based on temperature and daylight hours.
- Standardized Precipitation Index (SPI):
calculate_spi
: Quantifies precipitation deficit or surplus over various timescales, utilizing a calibration period for robust statistical fitting.
- Standardized Precipitation Evapotranspiration Index (SPEI):
calculate_spei
: A powerful drought indicator based on the difference between precipitation and potential evapotranspiration, aggregated and transformed to a standard normal variate using a defined calibration period.
- Data Utilities:
- Functions for loading, preprocessing, and saving meteorological and hydrological data.
You can install drought_indices_python
directly from PyPI using pip:
pip install drought_indices_python
For development purposes, or to work with the latest unreleased features, you can install it locally in editable mode:
cd /path/to/your/DROUGHT_INDICES_PYTHON/project # Navigate to the outer DROUGHT_INDICES_PYTHON folder
pip install -e .
Once installed, you can easily import and utilize the functions within your Python scripts:
import numpy as np
from drought_indices_python import calculate_pet_thornthwaite, calculate_spi, calculate_spei, load_data
# Example: Calculate PET (assuming you have annual_heat_index_I)
# annual_I = 50.0 # This would come from your long-term temperature data
# pet_value = calculate_pet_thornthwaite(monthly_temperature=18.5, latitude=40.0, month=7, annual_heat_index_I=annual_I)
# print(f"Calculated PET: {pet_value:.2f} mm")
# Example: Calculate SPI (using dummy data for illustration)
# precip_data_example = np.random.rand(360) * 150 # 30 years of monthly data
# spi_values = calculate_spi(
# precipitation_data=precip_data_example,
# scale_months=6,
# data_start_year=1990,
# calibration_start_year=1990,
# calibration_end_year=2019
# )
# print(f"First 5 SPI values (6-month): {spi_values[:5]}")
# Example: Calculate SPEI (using dummy data for illustration)
# pet_data_example = np.random.rand(360) * 80 # 30 years of monthly PET
# spei_values = calculate_spei(
# precipitation_data=precip_data_example,
# pet_data=pet_data_example,
# scale_months=12,
# data_start_year=1990,
# calibration_start_year=1990,
# calibration_end_year=2019
# )
# print(f"First 5 SPEI values (12-month): {spei_values[:5]}")
# Data Loading (placeholder for your implementation)
# data = load_data('path/to/your/climate_data.csv')
We welcome contributions to drought_indices_python
! Whether you're fixing bugs, adding new features, or improving documentation, your help is greatly appreciated. Please feel free to fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details. """