Description Usage Arguments Details Examples
This function computes n-year averages from an existing NetCDF time series
read in with readNetCDF
1 | time_average(x, n, offset = NULL, type = "start")
|
x |
array of class 'NetCDF' |
n |
number of time steps to average over |
offset |
offset from which to start (in years) |
type |
Alternative to specifying offset, one of start (the default), even or end, see details |
The automated way to set the offset works as following.
start
starts the n
-year averages at the beginning
of the time series, end
sets the offset so that the last
average ends in the last year of the time series, even
sets the offset so that modulo(year, n) == 0
for the first year
in the first average (i.e. for n=5
averages such as 1910-1914).
The time attribute reflects the average over the same block as the average
of the data, that is n
-yearly averages will be centered.
1 2 3 4 5 6 7 8 9 10 11 | tas <- readNetCDF(system.file("extdata", "annual_CRUTEMv3_1961-90.nc", package="geoutils"), varname="temp")
## compute 5-yearly averages
tas.avg <- time_average(tas, 5, type='start')
## get a grid point with little missing values
si <- which.max(apply(!is.na(tas), 1, sum))
## plot the data
plot(tas, type='ts', si=si, lwd=1)
plot(tas.avg, type='ts', si=si, col=2, lwd=2, add=T)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.