Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGR
Commits
488e9a40
Commit
488e9a40
authored
Aug 04, 2021
by
Delaigue Olivier
Browse files
test(PE_oudin): add test on Julian days
Refs
#134
parent
9d8f8b91
Pipeline
#26041
passed with stage
in 9 minutes and 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/testthat/test-evap.R
View file @
488e9a40
context
(
"Test evaporation"
)
context
(
"Test evaporation"
)
rm
(
list
=
ls
())
data
(
L0123001
);
BasinObs_L0123001
<-
BasinObs
data
(
L0123002
);
BasinObs_L0123002
<-
BasinObs
comp_evap
<-
function
(
BasinObs
,
comp_evap
<-
function
(
BasinObs
,
Lat
,
LatUnit
,
Lat
,
LatUnit
,
TimeStepIn
=
"daily"
,
TimeStepIn
=
"daily"
,
...
@@ -16,12 +21,9 @@ comp_evap <- function(BasinObs,
...
@@ -16,12 +21,9 @@ comp_evap <- function(BasinObs,
all
(
range
(
PotEvap
-
PotEvapFor
)
<
0.000001
)
all
(
range
(
PotEvap
-
PotEvapFor
)
<
0.000001
)
}
}
test_that
(
"PE_Oudin works"
,
{
test_that
(
"PE_Oudin works"
,
{
skip_on_cran
()
skip_on_cran
()
rm
(
list
=
ls
())
data
(
L0123001
);
BasinObs_L0123001
<-
BasinObs
data
(
L0123002
);
BasinObs_L0123002
<-
BasinObs
expect_true
(
comp_evap
(
BasinObs
=
BasinObs_L0123001
,
expect_true
(
comp_evap
(
BasinObs
=
BasinObs_L0123001
,
Lat
=
0.8
,
LatUnit
=
"rad"
,
Lat
=
0.8
,
LatUnit
=
"rad"
,
...
@@ -59,3 +61,28 @@ test_that("PE_Oudin works", {
...
@@ -59,3 +61,28 @@ test_that("PE_Oudin works", {
expect_equal
(
PotEvapFor
,
c
(
PotEvapFor1
,
PotEvapFor2
))
expect_equal
(
PotEvapFor
,
c
(
PotEvapFor1
,
PotEvapFor2
))
})
})
test_that
(
"Inconsitent time series"
,
{
skip_on_cran
()
warnDaily
<-
"each day should have only one identical value of julian days. The time series is not sorted, or contains duplicate or missing dates"
# duplicated dates
DatesFor1Dupl
<-
BasinObs_L0123001
$
DatesR
DatesFor1Dupl
[
5L
]
<-
DatesFor1Dupl
[
4L
]
expect_warning
(
object
=
PE_Oudin
(
JD
=
as.POSIXlt
(
DatesFor1Dupl
)
$
yday
+
1
,
Temp
=
BasinObs_L0123001
$
T
,
Lat
=
0.8
,
LatUnit
=
"rad"
),
regexp
=
warnDaily
)
# not ordered dates
DatesFor1Messy
<-
sample
(
BasinObs_L0123001
$
DatesR
)
expect_warning
(
object
=
PE_Oudin
(
JD
=
as.POSIXlt
(
DatesFor1Messy
)
$
yday
+
1
,
Temp
=
BasinObs_L0123001
$
T
,
Lat
=
0.8
,
LatUnit
=
"rad"
),
regexp
=
warnDaily
)
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment