Learn R Programming

seas (version 0.3-3)

seas.norm: Calculate annual and seasonal `normal' statistics, including precipitation normals

Description

Calculates annual and seasonal normal statistics on a seas.sum object, including precipitation normals for rain, snow and total precipitation.

Usage

# minimum
seas.norm(x)

precip.norm(x)

# all options
seas.norm(x, var, fun = "median", norm = "days", year.filter,
          ann.only = FALSE, precip.norm = FALSE)

precip.norm(x, fun="median", norm = "days", year.filter)

Arguments

x
seas.sum object
var
variable name for the normal; if omitted will use x$prime (the prime variable of the seas.sum object), or if precip.norm=TRUE will be "precip
norm
variable for normalization of the sum, usually the number of "days" in each bin, but it can also be "active" to estimate the precipitation normal for days of active precipitation
year.filter
filter specific years for analysis
fun
character of an existing function object, or a function to operate across the number of years of observations, usually "mean"
ann.only
only annual statistics returned (saves time from other calculations)
precip.norm
logical; computes precipitation normal statistics, which is done slightly differently since it involves rain, snow and total precipitation; if TRUE, x$var must include "rain", "s

Value

  • Returns a precip.norm object, which is a list with the following elements:
  • seasAn array of seasonal precipitation statistics: precip, rain and snow (if precip.only = FALSE) are in mm/day; freq and na are the fraction of a day in which precipitation is occurring and that data is missing.
  • annAnnual precipitation statistics. precip, rain and snow (if precip.only = FALSE) are in mm/year; active and na are the number of days per year which are active (for example, days with precipitation) and that data are missing.
  • widthfrom x
  • binsfrom x
  • bin.lengthsmaximum number of days in each bin
  • year.rangefrom x
  • start.dayfrom x
  • varsame as input parameter
  • unitsunits for var, usnig attr
  • long.namelong name for var, using attr
  • ann.onlyann.only same as input parameter
  • precip.onlyfrom same as input parameter
  • a.cutfrom x
  • funfunction used in analysis
  • idfrom x
  • namefrom x

synopsis

seas.norm(x, var, fun = "median", norm = "days", year.filter, ann.only = FALSE, precip.norm = FALSE) precip.norm(x, fun="median", norm = "days", year.filter)

Details

This function calculates the statistics of precipitation data on an annual and seasonal scope from a seas.sum object. The seasonal input data are normalized by the number of days in each bin, to produce a precipitation rate in mm/day. This is because the number of days in each bin is not equal. The function fun is then applied to the normalized precipitation, and operates along each bin, across multiple years of data. The supplied function is usually "median" or "mean", but it can also be a built in Rfunction, such as "var" for variance, or a composite such as: ll{ function(i,na.rm)(quantile(i,.2,na.rm=na.rm,names=F)) the 20% quantile function(i,na.rm)(mean(i,na.rm=na.rm)/(sd(i,na.rm=na.rm)^3)) skewness } If fun = "mean", then the statistics are straightforward (using apply), however if fun = "median" and there are more than 2 years of data, a different approach is taken. The median is a special case of the quantile function, where the probability is 50% of the population. The median and quantile functions are more resistant to outliers than mean, and can have advantages on precipitation data. Precipitation occurring at a given time of year does not have a normal distribution since it is a value that is not always occurring. It often has a left-skewed distribution, consisting of many zero measurements, and few extreme precipitation events. In this function, if fun = "median" (default) the median function is only used to calculate the median annual precipitation. The quantile function is used to calculate the seasonal statistics, since the sum of medians applied in each bin are less than the median annual precipitation. This is because there are usually many measurements of no rain, which skew the distribution to the left. The percentile for the quantile function is found using a secant method (Cheny and Kincaid, 1999) such that the sum of the quantiles from each bin are equal to the median of the annual precipitation. Snow and rain (which are the two components of precipitation) are calculated similarly (if fun = "median"). The annual total rain and snow amounts are determined by finding the percentile of a quantile function where the sum is equal to the median of the annual precipitation. The seasonal snow and rain amounts are independently found using the same method to find the seasonal precipitation. The fraction of the snow in each bin, $snow.frac.b=snow.b/(snow.b+rain.b)$ is multiplied by the seasonal precipitation to determine the seasonal rain and snow amounts. This is because the sum of rain and snow in each bin does not equal the seasonal precipitation. This way, a figure with precip.only = TRUE and = FALSE will have identical daily precipitation rates in each bin. The pitfalls of calculating precipitation normals is that it assumes that precipitation occurs every day at a constant rate within each bin. This is not realistic, as the precipitation rates are much higher when it is actually occurring.

References

Cheny, E. W. and Kincaid, D. 1999, Numerical Mathematics and Computing, Pacific Grove: Brooks/Cole Pub., 671 p. Guttman, N.B. 1989, Statistical descriptors of climate, American Meteorological Society, 70, 602--607.

See Also

plot.seas.norm, plot.seas.var, precip.dep

Examples

Run this code
data(mscdata)

# calculate precipitation normal
dat <- mksub(mscdata,id=1108447)
dat.ss <- seas.sum(dat)
dat.nm <- precip.norm(dat.ss,fun="mean")

# plot precipitation normal
plot(dat.nm) # this is the same as plot.precip.norm(dat.nm)

# use precipitation normal
dat.dep <- precip.dep(dat, dat.nm)
plot(dep ~ date, dat.dep, type="l",
     main="CPD from mean normals")

Run the code above in your browser using DataLab