Learn R Programming

airGR (version 1.0.15.2)

SeriesAggreg: Conversion of time series to another time step (aggregation only)

Description

Conversion of time series to another time step (aggregation only). Warning : on the aggregated outputs, the dates correspond to the beginning of the time step (e.g. for daily time-series 01/03/2005 00:00 = value for period 01/03/2005 00:00 - 01/03/2005 23:59) (e.g. for monthly time-series 01/03/2005 00:00 = value for period 01/03/2005 00:00 - 31/03/2005 23:59) (e.g. for yearly time-series 01/03/2005 00:00 = value for period 01/03/2005 00:00 - 28/02/2006 23:59)

Usage

SeriesAggreg(TabSeries, TimeFormat, NewTimeFormat, ConvertFun,
  YearFirstMonth = 1, TimeLag = 0, verbose = TRUE)

Arguments

TabSeries

[POSIXt+numeric] data.frame containing the vector of dates (POSIXt) and the time series values numeric)

TimeFormat

[character] desired format (i.e. "hourly", "daily", "monthly" or "yearly")

NewTimeFormat

[character] desired format (i.e. "hourly", "daily", "monthly" or "yearly")

ConvertFun

[character] names of aggregation functions (e.g. for P[mm], T[degC], Q[mm] : ConvertFun = c("sum", "mean", "sum"))

YearFirstMonth

(optional) [numeric] integer used when NewTimeFormat = "yearly" to set when the starting month of the year (e.g. 01 for calendar year or 09 for hydrological year starting in September)

TimeLag

(optional) [numeric] numeric indicating a time lag (in seconds) for the time series aggregation (especially useful to aggregate hourly time series in daily time series)

verbose

(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = FALSE

Value

[POSIXct+numeric] data.frame containing a vector of aggregated dates (POSIXct) and time series values numeric)

Examples

Run this code
# NOT RUN {
library(airGR)

## loading catchment data
data(L0123002)

## preparation of the initial time series data frame at the daily time step
TabSeries  <- data.frame(BasinObs$DatesR, BasinObs$P, BasinObs$E, BasinObs$T, BasinObs$Qmm)
TimeFormat <- "daily"

## conversion at the monthly time step
NewTimeFormat <- "monthly"
ConvertFun    <- c("sum", "sum", "mean", "sum")
NewTabSeries  <- SeriesAggreg(TabSeries = TabSeries, TimeFormat, NewTimeFormat, ConvertFun)

## conversion at the yearly time step
NewTimeFormat <- "yearly"
ConvertFun <- c("sum", "sum", "mean", "sum")
NewTabSeries <- SeriesAggreg(TabSeries = TabSeries, TimeFormat, NewTimeFormat, ConvertFun)

# }

Run the code above in your browser using DataLab