Learn R Programming

ClimMobTools (version 0.2-7)

rainfall: Rainfall indices

Description

Compute rainfall indices over a timespan

Usage

rainfall(object, day.one = NULL, span = NULL, index = NULL, ...)

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/)

day.one

a vector of class 'Date' for the starting date to capture the environmental data

span

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

index

optional, a character or a vector with characters for the indices to be computed. All indices are given by default

...

additional arguments passed to methods

Value

A dataframe with selected indices. Options are:

MLDS

maximum length of consecutive dry days (r < 1 mm)

MLWS

maximum length of consecutive wet days (r >= 1 mm)

R10mm

number of heavy precipitation days (10 >= r < 20 mm)

R20mm

number of very heavy precipitation days (r >= 20)

SDII

simple daily intensity index (mean of wet days / total rainfall)

Rx1day

maximum 1-day rainfall (mm)

Rx5day

maximum 5-day rainfall (mm)

Rtotal

total rainfall (mm) in wet days (R >= 1)

Examples

Run this code
# NOT RUN {
library("ClimMobTools")
library("nasapower")

# random geographic locations around bbox(11, 12, 55, 58)
lonlat <- data.frame(lon = runif(10, 11, 12),
                     lat = runif(10, 55, 58))

# random planting dates around 2018-05-15 and 2018-05-20
pdates <- as.integer(runif(10, 17666, 17670))
pdates <- as.Date(pdates, origin = "1970-01-01")

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


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

# }
# NOT RUN {
         
# }

Run the code above in your browser using DataLab