rainfall {climatrends} | R Documentation |
Rainfall indices
Description
Methods to compute rainfall indices over a time series
Usage
rainfall(object, ...)
## Default S3 method:
rainfall(object, ..., timeseries = FALSE)
## S3 method for class 'data.frame'
rainfall(object, day.one, span = NULL, ..., timeseries = FALSE)
## S3 method for class 'matrix'
rainfall(object, day.one, span = NULL, ..., timeseries = FALSE)
## S3 method for class 'sf'
rainfall(object, day.one, span = NULL, ..., timeseries = FALSE, as.sf = TRUE)
Arguments
object |
a numeric vector with precipitation data or a |
... |
additional arguments passed to methods. See details. |
timeseries |
logical, |
day.one |
a vector of class |
span |
an integer or a vector with integers (optional if last.day is given) for the length of the time series to be captured |
as.sf |
logical, to return an object of class 'sf' |
Details
#' Additional arguments:
intervals
: an integer (no lower than 5), for the days intervals when
timeseries = TRUE
last.day
: optional to span, an object of class Date
or
any other object that can be coerced to Date
(e.g. integer, character
YYYY-MM-DD) for the last day of the time series
dates
: a character (or Date or numeric) vector for the dates of tmax and tmin
in the default
method
data.from
: character for the source of remote data. Current remote source
is: 'nasapower'
pars
: character vector for the precipitation data to be fetched. If
data.from
is 'nasapower', the default precipitation parameter is "PRECTOTCORR".
days.before
: optional, an integer for the number of days before
day.one to be included in the timespan.
# S3 Methods
The matrix
method assumes that object contains climate data available in
your R section; see help("rain_dat", package = "climatrends") for an example on input
structure.
The data.frame
and the sf
methods assumes that the climate data
will e fetched from a remote (cloud) source that be adjusted using the argument
data.from.
When timeseries = TRUE
, an id is created,
which is the index for the rownames of the inputted object.
Value
A dataframe with rainfall indices:
MLDS |
maximum length of consecutive dry day, rain < 1 mm (days) |
MLWS |
maximum length of consecutive wet days, rain >= 1 mm (days) |
R10mm |
number of heavy precipitation days 10 >= rain < 20 mm (days) |
R20mm |
number of very heavy precipitation days rain >= 20 (days) |
Rx1day |
maximum 1-day precipitation (mm) |
Rx5day |
maximum 5-day precipitation (mm) |
R95p |
total precipitation when rain > 95th percentile (mm) |
R99p |
total precipitation when rain > 99th percentile (mm) |
Rtotal |
total precipitation (mm) in wet days, rain >= 1 (mm) |
SDII |
simple daily intensity index, total precipitation divided by the number of wet days (mm/days) |
References
Aguilar E., et al. (2005). Journal of Geophysical Research, 110(D23), D23107. doi:10.1029/2005JD006119
Examples
# A vector with precipitation data
set.seed(987219)
rain <- runif(50, min = 0, max = 6)
rainfall(rain)
# Return as timeseries with intervals of 7 days
dates <- 17650:17699
rainfall(rain, dates = dates, timeseries = TRUE, intervals = 7)
######################################################
# the matrix method
data("rain_dat", package = "climatrends")
rainfall(rain_dat,
day.one = "2013-10-28",
span = 12)