trans_thornthwaite {tidyindex} | R Documentation |
Drought-related index functions
Description
The functions are used for quick computing of some common drought indexes built from wrappers of the underlying modules. For more customised needs, users may build their own indexes from the modules.
Usage
trans_thornthwaite(var, lat, na.rm = FALSE, verbose = TRUE)
idx_spi(data, .prcp, .dist = dist_gamma(), .scale = 12)
idx_spei(
data,
.tavg,
.lat,
.prcp,
.pet_method = trans_thornthwaite(),
.scale = 12,
.dist = dist_glo()
)
idx_rdi(
data,
.tavg,
.lat,
.prcp,
.pet_method = trans_thornthwaite(),
.scale = 12
)
idx_edi(data, .tavg, .lat, .prcp, .scale = 12)
Arguments
var |
the variable to be transformed, see [tidyindex::variable_trans()] and [SPEI::thornthwaite()] |
lat , na.rm , verbose |
see [SPEI::thornthwaite] |
data |
an |
.dist |
the distribution used for distribution fit, see [tidyindex::distribution_fit()] |
.scale |
the temporal aggregation scale, see [tidyindex::temporal_aggregation()] |
.tavg , .lat , .prcp |
variables to be used in the index calculation, see Details |
.pet_method |
the method used for calculating potential
evapotranspitation, currently only |
Details
Below explains the steps wrapped in each index and the intermediate variables created.
The idx_spi()
function performs
a temporal aggregation on the input precipitation series,
.prcp
, as.agg
,a distribution fit step on the aggregated precipitation ,
.agg
, as.fit
, anda normalising step on the fitted values,
.fit
, as.index
The idx_spei()
function performs
a variable transformation step on the inut average temperature,
.tavg
, to obtain the potential evapotranspiration,.pet
,a dimension reduction step to calculate difference series,
.diff
, between the input precipitation series,.prcp
, and.pet
,a temporal aggregation step on the difference series,
.diff
, as.agg
,a distribution fit step on the aggregated series,
.agg
, as.fit
, anda normalising step on the fitted value,
.fit
, to obtain.index
.
The idx_rdi()
function performs
a variable transformation step on the input average temperature,
.tavg
, to obtain potential evapotranspiration.pet
,a dimension reduction step to calculate the ratio of input precipitation,
.prcp
, to.pet
as.ratio
,a temporal aggregation step on the ratio series,
.ratio
, as.agg
a variable transformation step to take the log10 of the aggregated series,
.agg
, as.y
, anda rescaling step to rescale
.y
by zscore to obtain.index
.
The idx_edi()
function performs
a dimension reduction step to aggregate the input precipitation series,
prcp
, as.mult
,a temporal aggregation step on the aggregated precipitation series (
.mult
) as.ep
, anda rescaling step to rescale
.ep
by zscore to obtain.index
.
Value
an index table object
Examples
library(dplyr)
library(lmomco)
dt <- tenterfield |>
mutate(month = lubridate::month(ym)) |>
init(id = id, time = ym, group = month)
dt |> idx_spi()
dt |> idx_spi(.scale = c(12, 24))
dt |> idx_spei(.lat = lat, .tavg = tavg)
dt |> idx_rdi(.lat = lat, .tavg = tavg)
dt |> idx_edi(.lat = lat, .tavg = tavg)