water_balance: Climatic water balance from temperature and precipitation

View source: R/spei.R

water_balanceR Documentation

Climatic water balance from temperature and precipitation

Description

Calculates the climatic water balance, i.e. precipitation minus potential evapotranspiration (P - PET), from daily or monthly precipitation and minimum and maximum temperatures. The result is the input for aggregate_function = "SPEI" in daily_response, monthly_response, daily_response_seascorr and monthly_response_seascorr. PET is estimated with the Hargreaves equation (Hargreaves and Samani 1985; Allen et al. 1998), using the equations of SPEI::hargreaves().

Usage

water_balance(prec, tmin, tmax, lat, tmean = NULL)

Arguments

prec, tmin, tmax

data frames of precipitation sums (mm) and of minimum and maximum temperatures (degrees Celsius), with years as row names. Daily data have 366 columns, one per day of year (DOY); monthly data have 12 columns, January to December. This is the layout of env_data in daily_response and monthly_response; daily data with a date column can be converted with data_transform. All data frames must have the same dimensions and row names, and for monthly data the row names must be calendar years.

lat

latitude of the site in decimal degrees, negative in the southern hemisphere

tmean

optional data frame of mean temperatures in the same layout. If NULL (default), the mean temperature is (tmin + tmax) / 2, as in SPEI::hargreaves().

Details

Daily PET (mm per day) is

PET = 0.0023 \cdot 0.408 \cdot R_a (T_{mean} + 17.8) \sqrt{T_{max} - T_{min}}

where R_a is the extraterrestrial radiation of the day of year (MJ m-2 day-1) and 0.408 converts it into mm of evaporation per day (Allen et al. 1998, equations 20, 21 and 52). For monthly data, the same equation is applied to the middle day of each month and multiplied by the number of days of the month, which gives the values of SPEI::hargreaves() for a monthly time series. Negative temperature ranges and negative PET are set to 0. Beyond the polar circles, the sunset hour angle is pi during the polar day and 0 during the polar night (SPEI::hargreaves() uses the largest angle of the series for the polar day). Missing values are kept missing.

Value

a data frame of the climatic water balance (mm), with the dimensions, row names and column names of prec

References

Allen, R.G., Pereira, L.S., Raes, D., Smith, M. (1998) Crop evapotranspiration - Guidelines for computing crop water requirements. FAO Irrigation and drainage paper 56. FAO, Rome.

Hargreaves, G.H., Samani, Z.A. (1985) Reference crop evapotranspiration from temperature. Applied Engineering in Agriculture, 1(2), 96-99.

Begueria, S., Vicente-Serrano, S.M. (2023) SPEI: Calculation of the Standardized Precipitation-Evapotranspiration Index. R package version 1.8.1.

Examples

# daily climatic water balance of the black pine site Sezana
prec <- data_transform(SEZ_daily_psum, format = "daily")
tmin <- data_transform(SEZ_daily_tmin, format = "daily")
tmax <- data_transform(SEZ_daily_tmax, format = "daily")
tmean <- data_transform(SEZ_daily_tavg, format = "daily")

wb <- water_balance(prec = prec, tmin = tmin, tmax = tmax, lat = 45.71,
                    tmean = tmean)
wb[1:5, 1:5]

# monthly climatic water balance
monthly_wb <- water_balance(
  prec = data_transform(SEZ_daily_psum, format = "monthly",
                        monthly_aggregate_function = "sum"),
  tmin = data_transform(SEZ_daily_tmin, format = "monthly",
                        monthly_aggregate_function = "mean"),
  tmax = data_transform(SEZ_daily_tmax, format = "monthly",
                        monthly_aggregate_function = "mean"),
  lat = 45.71)
round(colMeans(monthly_wb), 1)

dendroTools documentation built on Nov. 23, 2026, 9:07 a.m.