percent.days.op.threshold: Lengths of strings of TRUE values

Description Usage Arguments Details Value Note See Also Examples

View source: R/climdex.r

Description

Computes fraction of days above or below the baseline threshold for each day, and averages them using the date factor passed in.

Usage

1
2
3
percent.days.op.threshold(temp, dates, jdays, date.factor,
  threshold.outside.base, base.thresholds, base.range, op = "<",
  max.missing.days)

Arguments

temp

Sequence of temperature values.

dates

Sequence of associated dates.

jdays

Sequence of associated days of year.

date.factor

Factor to aggregate data using.

threshold.outside.base

Sequence of thresholds to be used for data outside the base period.

base.thresholds

Data structure containing sets of thresholds to be used inside the base period; see climdexInput-class.

base.range

Date range (type PCICt) of the baseline period.

op

Comparison operator to use.

max.missing.days

Maximum number of NA values per time period.

Details

This function computes fractions of days above or below baseline thresholds for each day, then aggregates them using date.factor. It is used to implement TN/TX 10/90p.

Value

A vector consisting of the mean fraction of days above or below the supplied set of thresholds.

Note

If date.factor is omitted, daily series will be returned.

See Also

climdexInput-class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 monthly tx90p.
tx90p <- percent.days.op.threshold(ci@data$tmax, ci@dates, ci@jdays,
                                   ci@date.factors$monthly,
                                   ci@quantiles$tmax$outbase$q90,
                                   ci@quantiles$tmax$inbase$q90,
                                   ci@base.range, ">",
                                   ci@max.missing.days['monthly']) *
         ci@namasks$monthly$tmax

climdex.pcic documentation built on March 26, 2020, 7:17 p.m.