Learn R Programming

climdex.pcic (version 0.6-2)

climdexInput.raw, climdexInput.csv: Methods for Creating climdexInput Objects

Description

These functions create climdexInput objects for use with the climdex methods.

Usage

climdexInput.raw(tmax, tmin, prec, tmax.dates, tmin.dates,prec.dates, base.range=c(1961, 1990), n=5, northern.hemisphere=TRUE,pad.data.with.first.last.values=FALSE, tavg=NULL, tavg.dates=NULL, temp.quantiles.notbase=NULL, prec.quantiles=NULL, temp.quantiles.base=NULL)

climdexInput.csv(tmax.file, tmin.file, prec.file, data.columns=list(tmin="tmin", tmax="tmax", prec="prec"), base.range=c(1961, 1990), na.strings=NULL, cal="gregorian", date.types=NULL, n=5, northern.hemisphere=TRUE, pad.data.with.first.last.values=FALSE, tavg.file=NULL, temp.quantiles.notbase=NULL, prec.quantiles=NULL, temp.quantiles.base=NULL)

get.outofbase.quantiles(tmax, tmin, prec, tmax.dates, tmin.dates, prec.dates, base.range=c(1961, 1990), n=5, pad.data.with.first.last.values=FALSE)

Arguments

tmax
Daily maximum temperature data.
tmin
Daily minimum temperature data.
prec
Daily total precipitation data.
tavg
Daily mean temperature 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.
tavg.dates
Dates for the daily mean temperature data.
tmax.file
Name of file containing daily maximum temperature data.
tmin.file
Name of file containing daily minimum temperature data.
prec.file
Name of file containing daily total precipitation data.
tavg.file
Name of file containing daily mean temperature data.
data.columns
Column names for tmin, tmax, and prec data.
date.types
Column names for tmin, tmax, and prec data (see notes).
na.strings
Strings used for NA values; passed to read.csv.
cal
The calendar type used in the input files.
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.
pad.data.with.first.last.values
Base data padding option (see notes).
temp.quantiles.notbase
Out of base quantiles (see notes).
prec.quantiles
Precipitation quantiles (see notes).
temp.quantiles.base
In-base quantiles (see notes).

Value

Details

These functions take input climate data at daily resolution, and produce as output a ClimdexInput data structure. This data structure is then passed to each of the routines used to compute the Climdex indices. The indices themselves are specified on the webpage cited in the references section. climdexInput.csv should be used when your data is already in a CSV file. climdexInput.raw should be used in all other circumstances, as it is much more flexible. climdexInput.csv takes as arguments three input filenames: one for each of daily maximum temperature, minimum temperature, and total preciptation. climdexInput.raw takes as arguments the input daily maximum temperature, minimum temperature, and total precipitation data along with the associated series of dates.

Daily mean temperature data can optionally be supplied; if it is not supplied, it will be computed by taking the mean of the minimum and maximum daily temperature for each day.

References

http://cccma.seos.uvic.ca/ETCCDMI/list_27_indices.shtml

See Also

climdex.pcic-package, strptime.

Examples

Run this code
## 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))

## Alternatively, one could load the data in directly using
## climdexInput.csv from CSV files. This would create a climdexInput
## object from a set of filenames (already stored as variables), with a
## different date format.
ci.csv <- climdexInput.csv(tmax.filename, tmin.filename,
prec.filename, date.types=list(list(fields=c("date"), format="%Y-%m-%d")))

Run the code above in your browser using DataLab