Commit 5083d45a authored by Delaigue Olivier's avatar Delaigue Olivier

v1.6.1.9 style: minor typo revisions in RunModel #34

parent 61d9a74a
Pipeline #12823 passed with stages
in 11 minutes and 22 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.1.8
Version: 1.6.1.9
Date: 2020-04-07
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -2,7 +2,7 @@
### 1.6.1.8 Release Notes (2020-04-07)
### 1.6.1.9 Release Notes (2020-04-07)
#### New features
......
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)])
OutputsModelDown$QsimDown <- OutputsModelDown$Qsim
if (inherits(InputsModel, "daily")) {
TimeStep <- 60 * 60 * 24
}
if (inherits(InputsModel, "hourly")) {
TimeStep <- 60 * 60
}
AreaTot <- sum(InputsModel$BasinAreas) # total area
# total area
AreaTot <- sum(InputsModel$BasinAreas)
# 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))
nb_up_basins <- length(InputsModel$LengthHydro)
length_ts <- length(OutputsModelDown$QsimDown)
OutputsModelDown$Qsim <- OutputsModelDown$QsimDown * InputsModel$BasinAreas[length(InputsModel$BasinAreas)] / AreaTot
for (upstream_basin in 1:nb_up_basins) {
NbUpBasins <- length(InputsModel$LengthHydro)
LengthTs <- length(OutputsModelDown$QsimDown)
OutputsModelDown$Qsim <- OutputsModelDown$QsimDown * InputsModel$BasinAreas[length(InputsModel$BasinAreas)] / AreaTot
for (upstream_basin in seq_len(NbUpBasins)) {
OutputsModelDown$Qsim <- OutputsModelDown$Qsim +
c(rep(0, floor(PT[upstream_basin])),
InputsModel$QobsUpstr[(1 + floor(PT[upstream_basin])) : length_ts, upstream_basin]) *
InputsModel$QobsUpstr[(1 + floor(PT[upstream_basin])):LengthTs, upstream_basin]) *
HUTRANS[1, upstream_basin] * InputsModel$BasinAreas[upstream_basin] / AreaTot +
c(rep(0, floor(PT[upstream_basin] + 1)),
InputsModel$QobsUpstr[(2 + floor(PT[upstream_basin])) : length_ts, upstream_basin]) *
InputsModel$QobsUpstr[(2 + floor(PT[upstream_basin])):LengthTs, upstream_basin]) *
HUTRANS[2, upstream_basin] * InputsModel$BasinAreas[upstream_basin] / 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