climdexInput.raw: Method for creating climdexInput object from vectors of data

Description Usage Arguments Details Value Note References See Also Examples

View source: R/climdex.r

Description

This function creates a climdexInput object from data already ingested into R.

Usage

1
2
3
4
5
6
climdexInput.raw(tmax = NULL, tmin = NULL, prec = NULL,
  tmax.dates = NULL, tmin.dates = NULL, prec.dates = NULL,
  base.range = c(1961, 1990), n = 5, northern.hemisphere = TRUE,
  tavg = NULL, tavg.dates = NULL, quantiles = NULL, temp.qtiles = c(0.1,
  0.9), prec.qtiles = c(0.95, 0.99), max.missing.days = c(annual = 15,
  monthly = 3), min.base.data.fraction.present = 0.1)

Arguments

tmax

Daily maximum temperature data.

tmin

Daily minimum temperature data.

prec

Daily total precipitation data.

tmax.dates

Dates for the daily maximum temperature data.

tmin.dates

Dates for the daily minimum temperature data.

prec.dates

Dates for the daily total precipitation data.

base.range

Years to use for the baseline.

n

Number of days to use as window for daily quantiles.

northern.hemisphere

Whether this point is in the northern hemisphere.

tavg

Daily mean temperature data.

tavg.dates

Dates for the daily mean temperature data.

quantiles

Threshold quantiles for supplied variables.

temp.qtiles

Quantiles to calculate for temperature variables

prec.qtiles

Quantiles to calculate for precipitation

max.missing.days

Vector containing thresholds for number of days allowed missing per year (annual) and per month (monthly).

min.base.data.fraction.present

Minimum fraction of base data that must be present for quantile to be calculated for a particular day

Details

Any of tmin (daily minimum temperature), tmax (daily maximum temperature), tavg (daily mean temperature), and prec (daily precipitation) can be passed in. tavg will be derived from the mean of tmax and tmin if it is not supplied. If any of tmin, tmax, and prec are not supplied, the set of indices which can be calculated will be limited to indices which do not involve the missing variables.

For all data supplied, the associated dates must also be supplied.

This function takes input climate data at daily resolution, and produces as output a ClimdexInput data structure. This data structure can then be passed to any of the routines used to compute the Climdex indices. The indices themselves are specified on the webpage cited in the references section. The base.range argument is a pair of 4 digit years which bound the data on which the base percentiles are calculated.

The tmax, tmin, and prec arguments are numeric vectors containing the data on which the indices are to be computed. The units are assumed to be degrees C for temperature, and mm/day for precipitation.

The tmax.dates, tmin.dates, and prec.dates arguments are vectors of type PCICt.

The n argument specifies the size of the window used when computing the percentiles used in climdex.tx10p, climdex.tn10p, climdex.tx90p, and climdex.tn90p.

The northern.hemisphere argument specifies whether the data came from the northern hemisphere. If FALSE, data is assumed to have come from the southern hemisphere. This is used when computing growing season length; if the data is from the southern hemisphere, growing season length is the growing season starting in the beginning of July of the year indicated, running to the end of June of the following year.

The quantiles argument allows the user to supply pre-computed quantiles. This is a list consisting of quantiles for each variable.

For each temperature variable, there are separate lists of quantiles for inbase and outbase, with these names. In both cases, quantiles within these lists are named q10 for the 10th percentile and q90 for the 90th percentile. Other percentiles would be named qnn for the nnth percentile. For the outbase quantiles, each element in the list is a vector of length 365 (or 360 in the case of 360-day calendars), corresponding to one value for each day of the year. For the inbase quantiles, each element in the list is an array of dimensions [365 or 360, nyr, nyr - 1], where nyr is the number of years in the base period. Each value corresponds to a quantile for each day, for each year, with a particular year replaced.

For precipitation variables, there is a named vector of quantiles, consisting of at least q95 and q99.

The temp.qtiles and prec.qtiles arguments allow the user to modify the quantiles calculated. For example, specifying temp.qtiles=c(0.10, 0.50, 0.90) would calculate the 10th, 50th, and 90th percentiles for temperature.

The min.base.fraction.present argument specifies the minimum fraction of data which must be present for a quantile to be calculated for a particular day. If the fraction of data present is less than this threshold, the quantile for that day will be set to NA.

The max.missing.days argument is a vector consisting of 'annual' (the number of days that can be missing in a year) and 'monthly' (the number of days that can be missing in a month. If one month in a year fails the test, the corresponding year will be omitted.

Value

An object of class climdexInput-class for use with other climdex methods.

Note

Units are assumed to be mm/day for precipitation and degrees Celsius for temperature. No units conversion is performed internally.

References

http://etccdi.pacificclimate.org/list_27_indices.shtml

See Also

climdex.pcic-package, strptime.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(PCICt)

## Create a climdexInput object from some data already loaded in and
## ready to go.

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

Example output

Loading required package: PCICt

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