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.
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)
an index table object
the variable to be transformed, see [tidyindex::variable_trans()] and [SPEI::thornthwaite()]
see [SPEI::thornthwaite]
an id_tbl
object
the distribution used for distribution fit, see [tidyindex::distribution_fit()]
the temporal aggregation scale, see [tidyindex::temporal_aggregation()]
variables to be used in the index calculation, see Details
the method used for calculating potential
evapotranspitation, currently only trans_thornthwaite()
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
, and
a 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
, and
a 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
, and
a 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
, and
a rescaling step to rescale .ep
by zscore to obtain
.index
.
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)
Run the code above in your browser using DataLab