Commit 0035e63c authored by Dorchies David's avatar Dorchies David
Browse files

feat(Lag): allow NAs in Qupstream

- Correct bug on warning trigger in RunModel_Lag
- Add test for warning in SImulation and no warning in calibration

Refs #100
parent 68ce1825
Pipeline #21650 passed with stages
in 15 minutes and 40 seconds
......@@ -84,7 +84,7 @@ RunModel_Lag <- function(InputsModel, RunOptions, Param) {
Qupstream[1:LengthTs] * HUTRANS[2, upstream_basin]
}
# Warning for negative flows or NAs only in extended outputs
if(length(RunOptions$Outputs_Sim <3)) {
if(length(RunOptions$Outputs_Sim) > 2) {
if (any(OutputsModel$Qsim[!is.na(OutputsModel$Qsim)] < 0)) {
warning(length(which(OutputsModel$Qsim < 0)), " time steps with negative flow, set to zero.")
OutputsModel$Qsim[OutputsModel$Qsim < 0] <- 0
......
......@@ -97,11 +97,17 @@ test_that("'Qupstream' contain NA values", {
InputsModel = InputsModel,
IndPeriod_Run = Ind_Run))
InputsModel$OutputsModel <- OutputsGR4JOnly
# Warning with RunModel
expect_warning(
RunModel_Lag(InputsModel = InputsModel, RunOptions = RunOptions, Param = 1),
regexp = "time steps with NA values"
)
# No warning during calibration
RunOptions$Outputs_Sim <- RunOptions$Outputs_Cal
expect_warning(
RunModel_Lag(InputsModel = InputsModel, RunOptions = RunOptions, Param = 1),
regexp = NA
)
})
test_that("Upstream basin with nil area should return same Qdown as GR4J alone", {
......
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