Learn R Programming

climatrends (version 0.1.0)

rainfall: Rainfall indices

Description

Compute rainfall indices over a timespan

Usage

rainfall(
  object,
  day.one = NULL,
  span = 150,
  timeseries = FALSE,
  intervals = 5,
  ...
)

Arguments

object

a numeric vector of geographic coordinates (lonlat) or a matrix containing the precipitation data. When lonlat is used, the function makes a call to nasapower::get_power to fetch and concatenate environmental data from NASA POWER (https://power.larc.nasa.gov/) for the parameter PRECTOT (precipitation)

day.one

a vector of class Date for the starting date to capture the environmental data (YYYY-MM-DD)

span

an integer or a vector with integers for the duration of the timespan to be captured

timeseries

logical, FALSE for a single point time series observation or TRUE for a time series based on intervals

intervals

integer no lower than 5, for the days intervals when timeseries = TRUE

...

additional arguments passed to get_power methods

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)

When timeseries = TRUE, an id is created, which is the index for the rownames of the provided object.

References

Aguilar E., et al. (2005). Journal of Geophysical Research, 110(D23), D23107. https://doi.org/10.1029/2005JD006119

Sparks A. H. (2018). Journal of Open Source Software, 3(30), 1035. https://doi.org/10.21105/joss.01035

See Also

Other climatology functions: ETo(), GDD(), temperature()

Examples

Run this code
# NOT RUN {
# Using local sources
data("chirp", package = "climatrends")

day <- as.Date("2013-10-28", format = "%Y-%m-%d")

rainfall(chirp,
         day.one = day,
         span = 11)

# }
# NOT RUN {
# Using NASA POWER
library("nasapower")

# random points within bbox(11, 12, 55, 58)
set.seed(123)
lonlat <- data.frame(lon = runif(3, 11, 12),
                     lat = runif(3, 55, 58))

# random dates within 2018-05-15 and 2018-05-20
set.seed(321)
dates <- as.integer(runif(3, 17666, 17670))
dates <- as.Date(dates, origin = "1970-01-01")

# calculate rainfall for the first 50 days after day.one
rainfall(lonlat,
         day.one = dates,
         span = 50)


# include the first 15 days before day.one (residual precipitation)
rainfall(lonlat,
         day.one = dates,
         span = 50,
         days.before = 15)

# rainfall indices over a time series          
rainfall(lonlat,
         day.one = dates,
         span = 50,
         timeseries = TRUE,
         intervals = 7)
# }
# NOT RUN {
         
# }

Run the code above in your browser using DataLab