SeriesAggreg | R Documentation |
Conversion of time series to another time step (aggregation only) and regime computation.
Warning: on the aggregated outputs, the dates correspond to the beginning of the time step
(e.g. for daily time series 2005-03-01 00:00 = value for period 2005-03-01 00:00 - 2005-03-01 23:59)
(e.g. for monthly time series 2005-03-01 00:00 = value for period 2005-03-01 00:00 - 2005-03-31 23:59)
(e.g. for yearly time series 2005-03-01 00:00 = value for period 2005-03-01 00:00 - 2006-02-28 23:59)
## S3 method for class 'data.frame'
SeriesAggreg(x,
Format,
ConvertFun,
TimeFormat = NULL,
NewTimeFormat = NULL,
YearFirstMonth = 1,
TimeLag = 0,
...)
## S3 method for class 'list'
SeriesAggreg(x,
Format,
ConvertFun,
NewTimeFormat = NULL,
simplify = FALSE,
except = NULL,
recursive = TRUE,
...)
## S3 method for class 'InputsModel'
SeriesAggreg(x, Format, ...)
## S3 method for class 'OutputsModel'
SeriesAggreg(x, Format, ...)
x |
[InputsModel], [OutputsModel], [list] or [data.frame] containing the vector of dates (POSIXt) and the time series of numeric values |
Format |
[character] output time step format (i.e. yearly times series: |
TimeFormat |
(deprecated) [character] input time step format (i.e. |
NewTimeFormat |
(deprecated) [character] output time step format (i.e. |
ConvertFun |
[character] names of aggregation functions (e.g. for P[mm], T[degC], Q[mm]: |
YearFirstMonth |
(optional) [numeric] integer used when |
TimeLag |
(optional) [numeric] numeric indicating a time lag (in seconds) for the time series aggregation (especially useful to aggregate hourly time series into daily time series) |
simplify |
(optional) [boolean] if set to |
except |
(optional) [character] the name of the items to skip in the aggregation (default = |
recursive |
(optional) [boolean] if set to |
... |
Arguments passed to |
SeriesAggreg.InputsModel
and SeriesAggreg.OutputsModel
call SeriesAggreg.list
which itself calls SeriesAggreg.data.frame
.
So, all arguments passed to any SeriesAggreg
method will be passed to SeriesAggreg.data.frame
.
Argument ConvertFun
also supports quantile calculation by using the syntax "Q[nn]" with [nn] the requested percentile.
E.g. use "Q90" for calculating 90th percentile in the aggregation.
The formula used is: quantile(x, probs = perc / 100, type = 8, na.rm = TRUE)
.
As there are multiple ways to take into account missing values in aggregation functions, NA
s are not supported by SeriesAggreg
and it provides NA
values when NA
s are present in the x
input.
[POSIXct+numeric] data.frame containing a vector of aggregated dates (POSIXct) and time series values numeric)
Olivier Delaigue, David Dorchies
library(airGR)
## loading catchment data
data(L0123002)
## preparation of the initial time series data frame at the daily time step
TabSeries <- BasinObs[, c("DatesR", "P", "E", "T", "Qmm")]
## monthly time series
NewTabSeries <- SeriesAggreg(TabSeries,
Format = "%Y%m",
ConvertFun = c("sum", "sum", "mean", "sum"))
str(NewTabSeries)
## monthly regimes
NewTabSeries <- SeriesAggreg(TabSeries,
Format = "%m",
ConvertFun = c("sum", "sum", "mean", "sum"))
str(NewTabSeries)
## conversion of InputsModel
example("RunModel_GR2M")
## monthly regimes on OutputsModel object
SimulatedMonthlyRegime <- SeriesAggreg(OutputsModel, Format = "%m")
str(SimulatedMonthlyRegime)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.