seas.norm {seas} | R Documentation |
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
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 |
|
var |
variable name for the ‘normal’; if omitted will
use |
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 |
|
ann.only |
only annual statistics returned (saves time from other calculations) |
precip.norm |
|
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 R function, such as "var"
for variance, or a composite such as:
function(i, na.rm)(quantile(i, 0.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.
Value
Returns a precip.norm
object, which is a list
with the following elements:
seas |
An |
ann |
Annual precipitation statistics. |
width |
from |
bins |
from |
bin.lengths |
maximum number of days in each bin |
year.range |
from |
start.day |
from |
var |
same as input parameter |
units |
units for |
long.name |
long name for |
ann.only |
ann.only same as input parameter |
precip.only |
from same as input parameter |
a.cut |
from |
fun |
|
id |
from |
name |
from |
Note
Seasonal data are explicitly normalized to a rate per day (i.e., mm/day), and not per month (i.e., mm/month). This is because a time-derivative per month has unequal intervals of time, ranging between 28 to 31 days. This directly creates up to 10% error in the analysis between months.
Units for annual normals, however, remain per year, since a year is a suitable time derivative.
Author(s)
Mike Toews
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
, seas.var.plot
,
precip.dep
Examples
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")