Commit b9d55e29 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.4.4.1 style: minor typo revisions in PE_Oudin and test-evap

Refs #62
parent c9036a46
Pipeline #16641 passed with stages
in 10 minutes and 43 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.4.4.0
Version: 1.4.4.1
Date: 2020-10-14
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,7 +4,7 @@
### 1.4.4.0 Release Notes (2020-10-14)
### 1.4.4.1 Release Notes (2020-10-14)
#### New features
......
PE_Oudin <- function(JD, Temp,
Lat, LatUnit = c("rad", "deg"),
TimeStepIn = "daily", TimeStepOut = "daily",
RunFortran = F) {
RunFortran = FALSE) {
## ---------- check arguments
......@@ -33,7 +33,7 @@ PE_Oudin <- function(JD, Temp,
stop("'Lat' must be comprised between -pi/2 and +pi/2 degrees")
}
if (LatUnit[1L] == "deg" & (all(Lat >= 90) | all(Lat <= -90))) {
stop("'Lat' must be comprised between -90 and +90 degrees")
stop("'Lat' must be comprised between -90 and +90 degrees")
}
if (!RunFortran & LatUnit[1L] == "rad") {
FI <- Lat
......
context("Test evaporation")
comp_evap = function(BasinObs,
Lat, LatUnit,
TimeStepIn = "daily",
TimeStepOut = "daily")
{
comp_evap <- function(BasinObs,
Lat, LatUnit,
TimeStepIn = "daily",
TimeStepOut = "daily") {
PotEvap <- PE_Oudin(JD = as.POSIXlt(BasinObs$DatesR)$yday + 1,
Temp = BasinObs$T,
Lat, LatUnit,
TimeStepIn, TimeStepOut)
Lat = Lat, LatUnit = LatUnit,
TimeStepIn = TimeStepIn, TimeStepOut = TimeStepOut)
PotEvapFor <- PE_Oudin(JD = as.POSIXlt(BasinObs$DatesR)$yday + 1,
Temp = BasinObs$T,
Lat, LatUnit,
TimeStepIn, TimeStepOut,
RunFortran = T)
Lat = Lat, LatUnit = LatUnit,
TimeStepIn = TimeStepIn, TimeStepOut = TimeStepOut,
RunFortran = TRUE)
all(range(PotEvap - PotEvapFor) < 0.000001)
}
......@@ -24,18 +23,18 @@ test_that("PE_Oudin works", {
data(L0123001); BasinObs_L0123001 <- BasinObs
data(L0123002); BasinObs_L0123002 <- BasinObs
expect_true(comp_evap(BasinObs_L0123001,
0.8, "rad",
"daily", "daily"))
expect_true(comp_evap(BasinObs_L0123001,
0.8, "rad",
"daily", "hourly"))
expect_true(comp_evap(BasinObs_L0123002,
0.9, "rad",
"daily", "daily"))
expect_true(comp_evap(BasinObs_L0123002,
0.9, "rad",
"daily", "hourly"))
expect_true(comp_evap(BasinObs = BasinObs_L0123001,
Lat = 0.8, LatUnit = "rad",
TimeStepIn = "daily", TimeStepOut = "daily"))
expect_true(comp_evap(BasinObs = BasinObs_L0123001,
Lat = 0.8, LatUnit = "rad",
TimeStepIn = "daily", TimeStepOut = "hourly"))
expect_true(comp_evap(BasinObs = BasinObs_L0123002,
Lat = 0.9, LatUnit = "rad",
TimeStepIn = "daily", TimeStepOut = "daily"))
expect_true(comp_evap(BasinObs = BasinObs_L0123002,
Lat = 0.9, LatUnit = "rad",
TimeStepIn = "daily", TimeStepOut = "hourly"))
## check with several catchments using different values for Lat
......@@ -43,11 +42,11 @@ test_that("PE_Oudin works", {
PotEvapFor1 <- PE_Oudin(JD = as.POSIXlt(BasinObs_L0123001$DatesR)$yday + 1,
Temp = BasinObs_L0123001$T,
Lat = 0.8, LatUnit = "rad",
RunFortran = T)
RunFortran = TRUE)
PotEvapFor2 <- PE_Oudin(JD = as.POSIXlt(BasinObs_L0123002$DatesR)$yday + 1,
Temp = BasinObs_L0123002$T,
Lat = 0.9, LatUnit = "rad",
RunFortran = T)
RunFortran = TRUE)
## all in one
BasinObs_L0123001$Lat <- 0.8
......@@ -56,7 +55,7 @@ test_that("PE_Oudin works", {
PotEvapFor <- PE_Oudin(JD = as.POSIXlt(BasinObs$DatesR)$yday + 1,
Temp = BasinObs$T,
Lat = BasinObs$Lat, LatUnit = "rad",
RunFortran = T)
RunFortran = TRUE)
expect_equal(PotEvapFor, c(PotEvapFor1, PotEvapFor2))
......
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