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(dat)
precip.norm(dat)
# all options
seas.norm(dat, start, end, var, norm = "days",
fun = "median", ann.only = FALSE, precip.norm = FALSE)
precip.norm(dat, start, end, fun="median",...)
Arguments
start
start year; if omitted minimum year will be used
end
end year; if omitted will use same as start
, and if
start
is omitted, will use maximum year
var
variable name for the normal; if omitted will
use dat$prime
(the prime variable of the
seas.sum
object), or if precip.norm=TRUE
will
be "prec
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
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,
dat$var
must include "rain", ...
parameters to pass to seas.norm
from
precip.norm
synopsis
seas.norm(dat, start, end, var, norm = "days",
fun = "median", ann.only = FALSE, precip.norm = FALSE)
precip.norm(dat, start, end, fun="median", ...)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:
function(i,na.rm)(quantile(i,.2,na.rm=na.rm,names=F))
for
the 20\% quantile, orfunction(i,na.rm)(mean(i,na.rm=na.rm)/(sd(i,na.rm=na.rm)^3))
for 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.
Returns a precip.norm
object, which is a list
with the following properties:
- $seas
{
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.
}
- $ann
{
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.
}
- $fun
{function
used in analysis}
- $width
{from dat
}
- $precip.only
{from dat
}
- $range
{c(start,end)
years from dat
}
- $bins
{from dat
}
- $id
{from dat
}
- $name
{from dat
; unless overrided by name
argument}
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.
[object Object]
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.
plot.seas.norm
, plot.seas.var
,
precip.dep
data(mscdata)
# calculate precipitation normal
dat.ss <- seas.sum(mscdata,id=1108447)
dat.nm <- precip.norm(dat.ss,fun="mean")
# use precipitation normal
dat.dep <- precip.dep(mscdata, dat.nm, id=1108447)
plot(dep ~ date, dat.dep, type="l",
main="CPD from mean normals")
# plot precipitation normal
plot(dat.nm) # this is the same as plot.precip.norm(dat.nm)
datagen