Skip to content

SPEIbase v2.13.0

Latest

Choose a tag to compare

@sbegueria sbegueria released this 07 Nov 10:21

SPEIbase v2.13.0

This release fixes a bug in how potential evapotranspiration (PET) was converted from mm/day to mm/month. The bug affects all SPEI datasets from v2.6 to v2.12.0. This release contains the corrected code only. The corrected SPEI dataset will be published separately on https://spei.csic.es.

Input data and dependencies are unchanged from v2.12.0: CRU TS 4.10 (January 1901 to December 2025) and SPEI package v1.8.1.

Bug fix: PET days-in-month conversion (#19)

CRU TS PET is in mm/day and precipitation is in mm/month, so PET must be multiplied by the number of days in each month before computing the climatic water balance. Since v2.6 this was done with:

x <- ncvar_get(etp.nc, ...) * ndays

x is a lon × lat × time array, so R recycled ndays along longitude instead of time. Each grid cell's PET was multiplied by one fixed number (28, 29, 30 or 31) in every month, instead of the length of each month. The conversion is now applied along the time dimension:

x <- sweep(ncvar_get(etp.nc, ...), 3, ndays, "*")

Affected: all SPEI datasets from v2.6 to v2.12.0, at all time scales.
Not affected: SPI, which does not use PET.

Impact. @arnabkdey checked SPEI-3 at 30 grid cells in Africa against the published v2.9 data. The median correlation between the published and corrected values was 0.998, and the median mean absolute difference was 0.03 SPEI units. The differences were largest in hyper-arid cells, where PET dominates the water balance. At one cell (30.75E, 15.75N) the mean absolute difference was 0.31 and the maximum 1.23. Other regions and time scales were not measured, but they are processed by the same code. Users working in arid regions should switch to the corrected dataset once it is released.

Other changes

  • spei.nc() now stops with an error if the precipitation and PET files do not share the same time axis over the period being processed.
  • README: new section, "Known issue: PET unit conversion". It also notes that the v2.5/v2.5.1 code (the earlier Zenodo release) computes the days per month but never applies them, so it subtracts mm/day PET from mm/month precipitation.
  • Added NEWS.md as a changelog.

Thanks

Thanks to @arnabkdey for finding and documenting the bug and for checking it against the published data.

Full changelog: v2.12.0...v2.13.0