resample_xts: Functions to resample an xts time series

Description Usage Arguments Details Value Examples

View source: R/xts_utilities.R

Description

Takes an xts time series object and resamples then to a new time step.

Usage

1
resample_xts(obs, dt, is.rate = FALSE)

Arguments

obs

A times series (xts) object with a POSIXct index.

dt

New time interval in seconds

is.rate

If TRUE then these are rates i.e m/hr. Otherwise they are absolute values accumulated within the preceeding time interval. Values are scaled before returning so resampling is conservative.

Details

Time series of observation data are often of different temporal resolutions, however the input to most hydrological models, as is the case with the Dynamic TOPMODEL, requires those data at the same interval. This provides a method to resample a collection of such data to a single interval.

Because of the methods used the results: - are not accurate when the input data does not have a constant timestep. The code issued a warnign and proceeds assuming the data are equally spaced with the modal timestep. - do not guarentee the requested time step but returns a series with the timestep computed from an integer rounding the ratio of the current and requested time step.

Value

An xts object with the new timestep

Examples

1
2
3
4
5
6
7
8
9
# Resample Brompton rainfall to 15 minute intervals
require(dynatop)
data("Swindale")

obs <- resample_xts(Swindale$obs, dt=60*60) # hourly data

# check totals
sum(obs$Rainfall*15/60, na.rm=TRUE)
sum(Swindale$obs$Rainfall, na.rm=TRUE)

waternumbers/dynatop documentation built on April 8, 2021, 5:55 a.m.