get_reference_precipitation: Calculate reference precipitation for a reference...

View source: R/rainfall.R

get_reference_precipitationR Documentation

Calculate reference precipitation for a reference period/climate normal

Description

The reference rainfall corresponds to the (usually) 95th or 99th percentile of rainfall within the reference period.

Usage

get_reference_precipitation(precipitation, date = NULL,
  reference_period = NULL, percentile = 95L, wet_day_threshold = 1)

Arguments

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.

Value

the 95th percentile for the reference period.

See Also

Other rainfall functions: precipitation_above_reference

Examples

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

StatisticsNZ/er.helpers documentation built on Oct. 2, 2023, 7:24 a.m.