Commit 4e3fb7b5 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

test(SeriesAggreg): use LengthHydro in km and do not replace NA value in...

test(SeriesAggreg): use LengthHydro in km and do not replace NA value in Qupstream in the use of CreateInputsModel
parent 91eab32a
Pipeline #22749 passed with stages
in 9 minutes and 12 seconds
...@@ -182,24 +182,22 @@ test_that("Check SeriesAggreg.outputsModel", { ...@@ -182,24 +182,22 @@ test_that("Check SeriesAggreg.outputsModel", {
}) })
test_that("Check data.frame handling in SeriesAggreg.list", { test_that("Check data.frame handling in SeriesAggreg.list", {
QObsUp <- imputeTS::na_interpolation(BasinObs$Qmm)
InputsModelDown1 <- CreateInputsModel( InputsModelDown1 <- CreateInputsModel(
FUN_MOD = RunModel_GR4J, FUN_MOD = RunModel_GR4J,
DatesR = BasinObs$DatesR, DatesR = BasinObs$DatesR,
Precip = BasinObs$P, Precip = BasinObs$P,
PotEvap = BasinObs$E, PotEvap = BasinObs$E,
Qupstream = matrix(QObsUp, ncol = 1), Qupstream = matrix(BasinObs$Qmm, ncol = 1),
# Upstream observed flow # Upstream observed flow
LengthHydro = 100 * 1000, LengthHydro = 100,
# Distance between upstream catchment outlet and the downstream one in m # Distance between upstream catchment outlet and the downstream one in km
BasinAreas = c(180, 180) # Upstream and downstream areas in km² BasinAreas = c(180, 180) # Upstream and downstream areas in km²
) )
expect_warning(SeriesAggreg(InputsModelDown1, "%Y%m"), expect_warning(SeriesAggreg(InputsModelDown1, "%Y%m"),
regexp = NA) regexp = NA)
I2 <- SeriesAggreg(InputsModelDown1, "%Y%m") I2 <- SeriesAggreg(InputsModelDown1, "%Y%m")
expect_equal(length(I2$DatesR), nrow(I2$Qupstream)) expect_equal(length(I2$DatesR), nrow(I2$Qupstream))
InputsModelDown1$Qupstream <- InputsModelDown1$Qupstream <- InputsModelDown1$Qupstream[-1, , drop = FALSE]
InputsModelDown1$Qupstream[-1, , drop = FALSE] # https://stackoverflow.com/a/7352287/5300212
expect_warning(SeriesAggreg(InputsModelDown1, "%Y%m"), expect_warning(SeriesAggreg(InputsModelDown1, "%Y%m"),
regexp = "it will be ignored in the aggregation") regexp = "it will be ignored in the aggregation")
}) })
......
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