diff options
| -rw-r--r-- | NAMESPACE | 1 | ||||
| -rw-r--r-- | NEWS.md | 4 | ||||
| -rw-r--r-- | R/PEC_sw_drainage_UK.R | 39 | ||||
| -rw-r--r-- | log/build.log | 1 | ||||
| -rw-r--r-- | log/check.log | 4 | ||||
| -rw-r--r-- | man/PEC_sw_drainage_UK.Rd | 21 | ||||
| -rw-r--r-- | tests/testthat/test_UK_drainage.R | 7 |
7 files changed, 59 insertions, 18 deletions
@@ -28,6 +28,7 @@ export(SSLRC_mobility_classification) export(TOXSWA_cwa) export(TSCF) export(chent_focus_sw) +export(drainage_date_UK) export(drift_percentages_rautmann) export(endpoint) export(geomean) @@ -1,4 +1,6 @@ -## version 0.6.4 +## version 0.6.5 + +- R/PEC_sw_drainage_UK.R: 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. - R/PEC_sw_drift.R: Vectorise the function not only with respect to distances, rates and water depths, but also with respect to crop groups. Closes issue #2 reported by Julian Klein (@juklei). diff --git a/R/PEC_sw_drainage_UK.R b/R/PEC_sw_drainage_UK.R index d5f0bab..40835b2 100644 --- a/R/PEC_sw_drainage_UK.R +++ b/R/PEC_sw_drainage_UK.R @@ -1,7 +1,8 @@ #' Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method #' #' This implements the method specified in the UK data requirements handbook and was checked against the spreadsheet -#' published on the CRC website. Degradation before the start of the drainage period is taken into account if +#' published on the CRC website. Degradation between the end (30 April) and the start (1 October) of +#' the drainage period is taken into account if #' `latest_application` is specified and the degradation parameters are given either as a `soil_DT50` or a `model`. #' #' @param rate Application rate in g/ha or with a compatible unit specified @@ -18,12 +19,12 @@ #' @return The predicted concentration in surface water in µg/L #' @references HSE's Chemicals Regulation Division (CRD) Active substance #' PECsw calculations (for UK specific authorisation requests) -#' \url{https://www.hse.gov.uk/pesticides/topics/pesticide-approvals/pesticides-registration/data-requirements-handbook/fate/active-substance-uk.htm} -#' accessed 2019-09-27 +#' \url{https://www.hse.gov.uk/pesticides/data-requirements-handbook/fate/pecsw-sed-via-drainflow.htm} +#' accessed 2026-02-13 #' -#' Drainage PECs Version 1.0 (2015) Spreadsheet published at -#' \url{https://www.hse.gov.uk/pesticides/topics/pesticide-approvals/pesticides-registration/data-requirements-handbook/fate/pec-tools-2015/PEC\%20sw-sed\%20(drainage).xlsx} -#' accessed 2019-09-27 +#' PECsw/sed spray drift and tier 1 drainflow calculator Version 2.1.1 (2025) Spreadsheet published at +#' \url{https://www.hse.gov.uk/pesticides/assets/docs/PEC%20sw-sed%20(spraydrift).xlsx)} +#' accessed 2026-02-13 #' @export #' @author Johannes Ranke #' @examples @@ -61,12 +62,13 @@ PEC_sw_drainage_UK <- function(rate, latest <- as.Date(paste(latest_application, ref_year), "%d %b %Y") if (is.na(latest)) stop("Please specify the latest application in the format '%d %b', e.g. '01 July'") tmp <- Sys.setlocale("LC_TIME", lct) - degradation_time <- as.numeric(difftime(as.Date(paste0(ref_year,"-10-01")), units = "days", latest)) + + drainage_date <- drainage_date_UK(latest) + degradation_time <- as.numeric(difftime(drainage_date, latest, units = "days")) + if (degradation_time > 0) { if (!missing(soil_DT50)) { k = log(2)/soil_DT50_d - as.Date(paste(latest_application, "1999"), "%d %B %Y") - amount_available <- amount_available * exp(-k * degradation_time) if (!missing(model)) stop("You already supplied a soil_DT50 value, implying SFO kinetics") } @@ -82,3 +84,22 @@ PEC_sw_drainage_UK <- function(rate, PEC = set_units(1e6 * (percentage_lost/100) * amount_available / volume, "\u00B5g/L") return(PEC) } + +#' @rdname PEC_sw_drainage_UK +#' @param application_date Application date +#' @export +#' @examples +#' drainage_date_UK("2023-07-10") +#' drainage_date_UK("2020-12-01") +#' drainage_date_UK(as.Date("2022-01-15")) +drainage_date_UK <- function(application_date) { + year <- substr(application_date, 1, 4) + drainage_end <- as.Date(paste0(year, "-04-30")) + drainage_start <- as.Date(paste0(year, "-10-01")) + if (application_date <= drainage_end | application_date >= drainage_start) { + drainage_date <- application_date + } else { + drainage_date <- drainage_start + } + return(drainage_date) +} diff --git a/log/build.log b/log/build.log index fb1f5c2..4b09656 100644 --- a/log/build.log +++ b/log/build.log @@ -3,6 +3,7 @@ * checking DESCRIPTION meta-information ... OK * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories +Removed empty directory ‘pfm/tests/testthat/_snaps’ * re-saving image files * building ‘pfm_0.6.5.tar.gz’ diff --git a/log/check.log b/log/check.log index 8dfd612..8ba020c 100644 --- a/log/check.log +++ b/log/check.log @@ -14,7 +14,7 @@ * checking CRAN incoming feasibility ... NOTE Maintainer: ‘Johannes Ranke <johannes.ranke@agroscope.admin.ch>’ -Size of tarball: 8536724 bytes +Size of tarball: 8537003 bytes * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -62,7 +62,7 @@ Size of tarball: 8536724 bytes * checking data for non-ASCII characters ... OK * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK -* checking examples ... [17s/11s] OK +* checking examples ... [20s/12s] OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED * checking PDF version of manual ... OK diff --git a/man/PEC_sw_drainage_UK.Rd b/man/PEC_sw_drainage_UK.Rd index af020c6..b641114 100644 --- a/man/PEC_sw_drainage_UK.Rd +++ b/man/PEC_sw_drainage_UK.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/PEC_sw_drainage_UK.R \name{PEC_sw_drainage_UK} \alias{PEC_sw_drainage_UK} +\alias{drainage_date_UK} \title{Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method} \usage{ PEC_sw_drainage_UK( @@ -13,6 +14,8 @@ PEC_sw_drainage_UK( model = NULL, model_parms = NULL ) + +drainage_date_UK(application_date) } \arguments{ \item{rate}{Application rate in g/ha or with a compatible unit specified @@ -32,29 +35,35 @@ days or a time unit specified with the units package} "DFOP", "HS", or "IORE", or an mkinmod object} \item{model_parms}{A named numeric vector containing the model parameters} + +\item{application_date}{Application date} } \value{ The predicted concentration in surface water in µg/L } \description{ This implements the method specified in the UK data requirements handbook and was checked against the spreadsheet -published on the CRC website. Degradation before the start of the drainage period is taken into account if +published on the CRC website. Degradation between the end (30 April) and the start (1 October) of +the drainage period is taken into account if \code{latest_application} is specified and the degradation parameters are given either as a \code{soil_DT50} or a \code{model}. } \examples{ PEC_sw_drainage_UK(150, Koc = 100) PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, latest_application = "01 July", soil_DT50 = 200) +drainage_date_UK("2023-07-10") +drainage_date_UK("2020-12-01") +drainage_date_UK(as.Date("2022-01-15")) } \references{ HSE's Chemicals Regulation Division (CRD) Active substance PECsw calculations (for UK specific authorisation requests) -\url{https://www.hse.gov.uk/pesticides/topics/pesticide-approvals/pesticides-registration/data-requirements-handbook/fate/active-substance-uk.htm} -accessed 2019-09-27 +\url{https://www.hse.gov.uk/pesticides/data-requirements-handbook/fate/pecsw-sed-via-drainflow.htm} +accessed 2026-02-13 -Drainage PECs Version 1.0 (2015) Spreadsheet published at -\url{https://www.hse.gov.uk/pesticides/topics/pesticide-approvals/pesticides-registration/data-requirements-handbook/fate/pec-tools-2015/PEC\%20sw-sed\%20(drainage).xlsx} -accessed 2019-09-27 +PECsw/sed spray drift and tier 1 drainflow calculator Version 2.1.1 (2025) Spreadsheet published at +\url{https://www.hse.gov.uk/pesticides/assets/docs/PEC\%20sw-sed\%20(spraydrift).xlsx)} +accessed 2026-02-13 } \author{ Johannes Ranke 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", |
