get_reference_precipitation | R Documentation |
The reference rainfall corresponds to the (usually) 95th or 99th percentile of rainfall within the reference period.
get_reference_precipitation(precipitation, date = NULL,
reference_period = NULL, percentile = 95L, wet_day_threshold = 1)
precipitation |
vector with rainfall values |
date |
date for each rain value. Must be the same lentgth of rainfall and must be the same type as the reference period. I.e if date is numeric (e.g. year) then the reference period must be given as numeric as well. If date is a date or a date-time ("date" or "POSIX.ct") then the reference period must be also a date or a date-time |
reference_period |
vector of length 2 with the beginning and end of the reference period |
percentile |
percentile for the reference period. Defaults to the 95th percentile |
wet_day_threshold |
Numeric. Amount of precipitation at which the day is considered a wet day. Defaults to 1. |
the 95th percentile for the reference period.
Other rainfall functions: precipitation_above_reference
library(dplyr)
# Simulate one measurement of rain per day for 10 years
rainfall <- rlnorm(10*365)
years <- rep(2001:2010, each = 365)
rain_data <- tibble(rainfall = rainfall, year = years)
# We chose a climate normal
climate_normal <- c(2001, 2005)
rain_data %>%
# calculate reference rainfall
mutate(ref = get_reference_precipitation(rainfall,
year,
climate_normal,
percentile = 95L)) %>%
# calculate prorportion of rainfall above reference
group_by(year) %>%
summarise(prop_above = precipitation_above_reference(rainfall, ref))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.