# seas.norm: Calculate annual and seasonal 'normal' statistics, including... In seas: Seasonal Analysis and Graphics, Especially for Climatology

## Description

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

## Usage

 ```1 2 3 4``` ```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"` or `"median"` (default); details described below `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", "snow" and "precip" summed variables

## 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 `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. `width` from `x` `bins` from `x` `bin.lengths` maximum number of days in each bin `year.range` from `x` `start.day` from `x` `var` same as input parameter `units` units for `var`, usnig `attr` `long.name` long name for `var`, using `attr` `ann.only` ann.only same as input parameter `precip.only` from same as input parameter `a.cut` from `x` `fun` `function` used in analysis `id` from `x` `name` from `x`

## 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.

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.

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

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```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") ```

### Example output

```
```

seas documentation built on May 2, 2019, 4:16 a.m.