Commit 88363e7e authored by Delaigue Olivier's avatar Delaigue Olivier

v1.6.1.7 fix: the formula used in RunModel was wrong #34

parent dd7c0dbb
Pipeline #12812 passed with stages
in 11 minutes and 45 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.1.6
Date: 2020-04-05
Version: 1.6.1.7
Date: 2020-04-07
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
......
......@@ -2,7 +2,7 @@
### 1.6.1.6 Release Notes (2020-04-05)
### 1.6.1.7 Release Notes (2020-04-07)
#### New features
......
......@@ -2,7 +2,7 @@ RunModel <- function (InputsModel, RunOptions, Param, FUN_MOD) {
FUN_MOD <- match.fun(FUN_MOD)
if (inherits(InputsModel, "SD")) {
OutputsModelDown <- FUN_MOD(InputsModel = InputsModel, RunOptions = RunOptions,
Param = Param[-length(Param)])
Param = Param[-length(Param)])
OutputsModelDown$QsimDown <- OutputsModelDown$Qsim
if (inherits(InputsModel, "daily")) {
TimeStep <- 60 * 60 * 24
......@@ -10,12 +10,18 @@ RunModel <- function (InputsModel, RunOptions, Param, FUN_MOD) {
if (inherits(InputsModel, "hourly")) {
TimeStep <- 60 * 60
}
AreaTot <- sum(InputsModel$BasinAreas)
AreaTot <- sum(InputsModel$BasinAreas) # total area
# propagation time from upstream meshes to outlet
PT <- InputsModel$LengthHydro[1, ] * 1000 / Param[length(Param)] / TimeStep
HUTRANS <- rbind(1 - (PT - floor(PT)), PT - floor(PT))
OutputsModelDown$Qsim <- OutputsModelDown$QsimDown * InputsModel$BasinAreas[length(InputsModel$BasinAreas)] / AreaTot +
1000 / Param[length(Param)] / TimeStep *
InputsModel$QobsUpstr %*% (InputsModel$LengthHydro[1, ] * InputsModel$BasinAreas[1:length(InputsModel$LengthHydro)])
InputsModel$QobsUpstr[(1 + floor(PT)) : length(OutputsModelDown$QsimDown), ] %*% HUTRANS[1, ] *
InputsModel$BasinAreas[1:length(InputsModel$LengthHydro)] / AreaTot +
InputsModel$QobsUpstr[(2 + floor(PT)) : length(OutputsModelDown$QsimDown), ] %*% HUTRANS[2, ] *
InputsModel$BasinAreas[1:length(InputsModel$LengthHydro)] / AreaTot
} else {
OutputsModelDown <- FUN_MOD(InputsModel = InputsModel, RunOptions = RunOptions, Param = Param)
}
return(OutputsModelDown)
}
}
\ No newline at end of file
Markdown is supported
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