nday.consec.prec.max: Number of days (less than, greater than, etc) a threshold

View source: R/indices.R

nday.consec.prec.maxR Documentation

Number of days (less than, greater than, etc) a threshold

Description

Produces sums of values that exceed (or are below) the specified threshold.

This function takes a data series, the number of days in the running window, a date factor to aggregate by, and an optional modifier parameter (center.mean.on.last.day). It computes the n-day running sum of precipitation and returns the maximum n-day total precipitation per unit time, as defined by date.factor.

Usage

nday.consec.prec.max(daily.prec, date.factor, ndays,
  center.mean.on.last.day = FALSE)

Arguments

daily.prec

Daily timeseries of precipitation.

date.factor

Factor to aggregate by.

ndays

Number of days in the running window.

center.mean.on.last.day

Whether to center the n-day running mean on the last day of the series, instead of the middle day.

Value

A vector consisting of the maximum n-day sum of precipitation per time interval.

Examples

library(PCICt)

## Parse the dates into PCICt.
tmax.dates <- as.PCICt(do.call(paste, ec.1018935.tmax[,c("year",
"jday")]), format="%Y %j", cal="gregorian")
tmin.dates <- as.PCICt(do.call(paste, ec.1018935.tmin[,c("year",
"jday")]), format="%Y %j", cal="gregorian")
prec.dates <- as.PCICt(do.call(paste, ec.1018935.prec[,c("year",
"jday")]), format="%Y %j", cal="gregorian")

## Load the data in.
ci <- climdexInput.raw(ec.1018935.tmax$MAX_TEMP,
ec.1018935.tmin$MIN_TEMP, ec.1018935.prec$ONE_DAY_PRECIPITATION,
tmax.dates, tmin.dates, prec.dates, base.range=c(1971, 2000))

## Compute rx5day on a monthly basis.
rx5day <- nday.consec.prec.max(ci@data$prec, ci@date.factors$monthly, 5)


ECA-D/climind documentation built on Nov. 26, 2022, 10:20 a.m.