Skip to content

Model to calculate various drought indices from precipitation/temperature data

License

Notifications You must be signed in to change notification settings

mintproject/droughtIndices

Repository files navigation

PyPI license

droughtIndices

Model to calculate various drought indices from precipitation/temperature data.

Table of contents

This Python routine calculates three climate indices based on NetCDF input data from CHIRPS, GLDAS, FLDAS, ECMWF:

  • SPI: Standardized Precipitation Index, utilizing both gamma and Pearson Type III distributions. - CHIRPS, GLDAS, FLDAS, ECMWF
  • SPEI: Standardized Precipitation Evapotranspiration Index, utilizing both gamma and Pearson Type III distributions. - GLDAS, FLDAS, ECMWF
  • PET: Potential Evapotranspiration, utilizing Thornthwaite equation. - GLDAS, FLDAS, ECMWF

This package is based upon Climate Indices in Python. The Climate Indices in Python project contains implementations of various algorithms which provide a geographical and temporal picture of the severity of precipitation and temperature anomalies for climate monitoring and research.

This project builds upon this software package to include additional sources of climate data.

  • v1.2.0: Support for non-dynamic naming of output files.
  • v1.1.0: Support for datasets from ECMWF, use JSON for configuration, optimization using xarray
  • v1.0.0: Support for datasets from FLDAS and combined netcdf file. Visualization support for SPI and SPEI. - First release
  • v0.0.1: Support for three indices and datasets from CHIRPS and GLDAS

Command line implementations:

python WM_climate_indices.py config.json

The config.json file contains the following fields:

  • dataset_type: the type of NetCDF files. Valid entries are GLDAS, ECMWF, CHIRPS or CESM
  • dataset_name: Name of dataset file or parent folder
  • dynamic_name: Whether to choose a constant name (results) or allow to infer it from parameters.
  • path: The out directory to write the index files. Index files are in NetCDF format, visualization in mp4. All years contained in a single file. Two folders will be created: figures (which contains each frame for the movie) and results, which will include both the netcdf and mp4 files. Each dataset is given a unique ID, which can be used to match data and visualization.
  • fig (bool): If True, will generate a movie.
  • name: The name of the index to be calculated. Valid entries include:
    • SPI: Standardized Precipitation Index, utilizing both gamma and Pearson Type III distributions
    • PET: Potential Evapotranspiration, utilizing Thornthwaite equations
    • SPEI: Standardized Precipitation Evapotranspiration Index, utilizing both gamma and Pearson Type III distributions.
  • distribution: Either 'gamma' or 'pearson'
  • periodicity: 'monthly'. Daily calculations are not supported in the current version
  • scales: Either '6' or '12' month
  • data_start_year: The year for which to start calculating the Index
  • data_end_year: The year for which to end the calculation
  • calibration_start_year: The start year for the calibration
  • calibration_end_year: The end year for the calibration.
  • global: Bool to consider the full geographical extent of the dataset. bounding_box information will be ignored in this case.
  • bounding_box: List of [min_lon,max_lon,min_lat,max_lat]

Note:

  • A list of sample data and associated links can be in the data folder in this repository
  • SPEI and PET require temperature inputs, not present in the CHIRPS dataset.
  • The recommended length of time for calibration is 30 years
  • PET calculation requires an entire year of data for both calibration and computation. If not present, will adjust to last/first complete year on record.
  • An example config file is given in this repository

Tested under Python 3.8

Package requirements:

  • xarray
  • dask
  • netcdf4
  • bottleneck
  • pandas
  • numpy
  • climate-indices
  • cftime
  • cartopy
  • matplotlib
  • imageio
  • imageio-ffmpeg

Files

  • WM_climate_indices.py: Executable (climate indices calculation)
  • config.json: JSON file containing configurable inputs data and parameters

Folders

  • Data: Link to relevant datasets for use with the software
  • Docs: Simulation Matrix for the mint mint project
  • ExampleResults: Examples of outputs
  • Utils: Utilities to cut and concatenate netcdf files from FLDAS and GLDAS

Please report issues to khider@usc.edu

The project is licensed under the Apache v2.0 License. Please refer to the file call license.