summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRanke Johannes <johannes.ranke@agroscope.admin.ch>2026-02-13 16:13:46 +0100
committerRanke Johannes <johannes.ranke@agroscope.admin.ch>2026-02-13 16:34:09 +0100
commit24328f0fabc1982db01132bafb4dc65dd85b13e9 (patch)
tree8be05ef33a2f932662841d323ab8e3fd924caf05 /tests
parenta59124dd18106f35e8a965bd173ab80d33ba9c84 (diff)
Fix UK drainage for very early applications
Create a function `drainage_date_UK` that does not only respect the beginning of the drainage period on 1 October, but also the end of the drainage period on 30 April, and use it for determining the degradation time. Applications early in the year before 1 May will now correctly be calculated without degradation time.
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/test_UK_drainage.R7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/testthat/test_UK_drainage.R b/tests/testthat/test_UK_drainage.R
index 75d9c98..0286eb4 100644
--- a/tests/testthat/test_UK_drainage.R
+++ b/tests/testthat/test_UK_drainage.R
@@ -1,4 +1,5 @@
library(pfm)
+library(units)
context("UK drainage PEC calculations")
test_that("The mobility classification and the drained percentage are correct", {
@@ -41,6 +42,12 @@ test_that("UK drainflow PECs are correct", {
latest_application = "01 July",
soil_DT50 = 200), 2),
as_units(0.84, "\u00B5g/L"))
+
+ # Check and example with early application before the end of the drainage period
+ expect_equal(round(PEC_sw_drainage_UK(90, interception = 0, Koc = 10,
+ latest_application = "01 February",
+ soil_DT50 = 200), 4),
+ as_units(13.1538, "\u00B5g/L"))
expect_error(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550,
latest_application = "100 July",

Contact - Imprint