Calculates annual and seasonal ‘normal’ statistics on a
seas.sum
object, including precipitation normals for
rain, snow and total precipitation.
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)
seas.sum
object
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"
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
filter specific years for analysis
only annual statistics returned (saves time from other calculations)
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", "snow" and "precip" summed
variables
Returns a precip.norm
object, which is a list
with the following elements:
An 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.
Annual 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.
from x
from x
maximum number of days in each bin
from x
from x
same as input parameter
units for var
, usnig attr
long name for var
, using attr
ann.only same as input parameter
from same as input parameter
from x
function
used in analysis
from x
from x
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 |
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.
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.
# NOT RUN {
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