speiGrid: Computation of Standardized...

View source: R/speiGrid.R

speiGridR Documentation

Computation of Standardized Precipitation(-Evapotranspiration) Index Grids

Description

Returns SPI/SPEI grid using precipitation (and PET for SPEI) input grids

Usage

speiGrid(
  pr.grid,
  et0.grid = NULL,
  scale = 3,
  params = NULL,
  return.coefficients = FALSE,
  ...
)

Arguments

pr.grid

Precipitation grid (monthly accumulated values, in mm)

et0.grid

Potential evapotranspiration grid (same units as pr.grid)

scale

Integer. Time scale at which the SPEI/SPI are computed. Default to 3 (months)

params

A multi-member grid with the distribution parameter coefficients for computing the spei. Each member corresponds to a parameter. The time dimension length must be 12 (months of the year). This grid is generated when the argument return.coefficients is set as TRUE (See examples).

return.coefficients

Logical (Default to FALSE). If TRUE, the function returns the parameter coefficients of the distribution that can be further used for computing the index, thus avoiding parameter fitting in subsequent applications of the function (See examples).

...

Further arguments passed to spei

Details

The function is a wrapper of function spei from package SPEI adapted to climate4R input grids

Value

A climate4R grid with SPEI/SPI data

See Also

petGrid, for PET calculation

Examples

# By default, et0.grid is null, and SPI is computed from precipitation: 
data("pr.cru.iberia")
spi3 <- speiGrid(pr.grid = pr.cru.iberia, scale = 3, na.rm = TRUE)
## If PET is used, then SPEI is calculated
data("tas.cru.iberia")
et0.grid <- petGrid(tas = tas.cru.iberia, method = "thornthwaite")
spei3 <- speiGrid(pr.cru.iberia, et0.grid = et0.grid, scale = 3, na.rm = TRUE)
## Extract the parameter coefficients of the distribution fist and compute the index afterwards:
spei3.params <- speiGrid(pr.cru.iberia, et0.grid = et0.grid, scale = 3, return.coefficients = TRUE, na.rm = TRUE)
spei3 <- speiGrid(pr.cru.iberia, et0.grid = et0.grid, scale = 3, params = spei3.params, na.rm = TRUE)

SantanderMetGroup/drought4R documentation built on Feb. 7, 2024, 1:59 a.m.