number.days.op.threshold: Number of days (less than, greater than, etc) a threshold

View source: R/helpfunctions.R

number.days.op.thresholdR Documentation

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

Description

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

Usage

number.days.op.threshold(temp, date.factor, threshold, op = "<")

Arguments

temp

Sequence temperature values.

date.factor

Factor to aggregate by.

threshold

Threshold to use.

op

Operator to use for comparison.

Details

This function takes a data series, a threshold, an operator, and a factor to aggregate by. It uses the operator to compare the threshold to the data series, creating a series of booleans, then sums the booleans according to the factor.

Value

A vector consisting of the number of values that meet the criteria in the given time period (as specified by date.factor).

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

## Calculate frost days.
fd <- number.days.op.threshold(ci@data$tmin,
                               ci@date.factors$annual, 0, "<")


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