Commit 41654f89 authored by Dorchies David's avatar Dorchies David
Browse files

v1.6.8.19 doc: use SeriesAggreg.InputsModel in RunModel_GR2M example

- include RunModel_GR2M example in SeriesAggreg example
- add SeriesAggreg.OutputsModel use in SeriesAggreg example

Refs #41
Showing with 24 additions and 16 deletions
+24 -16
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.8.18
Version: 1.6.8.19
Date: 2020-12-01
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -68,22 +68,16 @@ library(airGR)
## loading catchment data
data(L0123001)
## conversion of example data from daily to monthly time step
TabSeries <- data.frame(DatesR = BasinObs$DatesR,
P = BasinObs$P,
E = BasinObs$E,
Qmm = BasinObs$Qmm)
TimeFormat <- "\%Y\%m"
ConvertFun <- c("sum", "sum", "sum")
BasinObs <- SeriesAggreg(TabSeries = TabSeries, Format = TimeFormat, ConvertFun = ConvertFun)
## preparation of the InputsModel object
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR2M, DatesR = BasinObs$DatesR,
## preparation of the InputsModel object with daily time step data
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR,
Precip = BasinObs$P, PotEvap = BasinObs$E)
## conversion of InputsModel to monthly time step
InputsModel <- SeriesAggreg(InputsModel, Format = "\%Y\%m")
## run period selection
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m")=="1990-01"),
which(format(BasinObs$DatesR, format = "\%Y-\%m")=="1999-12"))
Ind_Run <- seq(which(format(InputsModel$DatesR, format = "\%Y-\%m")=="1990-01"),
which(format(InputsModel$DatesR, format = "\%Y-\%m")=="1999-12"))
## preparation of the RunOptions object
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR2M,
......@@ -93,12 +87,18 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR2M,
Param <- c(X1 = 265.072, X2 = 1.040)
OutputsModel <- RunModel_GR2M(InputsModel = InputsModel, RunOptions = RunOptions, Param = Param)
## conversion of observed discharge to monthly time step
Qobs <- SeriesAggreg(data.frame(BasinObs$DatesR, BasinObs$Qmm),
Format = "\%Y\%m",
ConvertFun = "sum")
Qobs <- Qobs[Ind_Run, 2]
## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])
plot(OutputsModel, Qobs = Qobs)
## efficiency criterion: Nash-Sutcliffe Efficiency
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
RunOptions = RunOptions, Obs = Qobs)
OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
}
......
......@@ -102,6 +102,14 @@ NewTabSeries <- SeriesAggreg(TabSeries = TabSeries,
Format = "\%m",
ConvertFun = c("sum", "sum", "mean", "sum"))
str(NewTabSeries)
# Conversion of InputsModel
example("RunModel_GR2M")
# Monthly regime on OutputsModel object
SimulatedMonthlyRegime <- SeriesAggreg(OutputsModel, Format = "\%m")
str(SimulatedMonthlyRegime)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment