View source: R/helpfunctions.R
percent.days.op.threshold | R Documentation |
Computes fraction of days above or below the baseline threshold for each day, and averages them using the date factor passed in.
percent.days.op.threshold(temp, dates, jdays, date.factor, threshold.outside.base, base.thresholds, base.range, op = "<", max.missing.days)
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. |
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.
A vector consisting of the mean fraction of days above or below the supplied set of thresholds.
If date.factor is omitted, daily series will be returned.
climdexInput-class.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.