diff options
| author | Elisabeth Lutz <168072575+Lutzeli@users.noreply.github.com> | 2026-02-05 13:38:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-05 13:38:13 +0100 |
| commit | 8fd8f9c04492cce60c1cd1e6b9a53057990ec31e (patch) | |
| tree | 16d002e76c4fbfcdf353d60fc19830d4dd61cae2 /R | |
| parent | 560b2dbf139015633b0807613884cbfa4d3f4e95 (diff) | |
Add unit check for rate and set units for PEC calculation
without this change PEC units will apear as [g/ha] when the rate input is given in [g/ha]
Diffstat (limited to 'R')
| -rw-r--r-- | R/PEC_sw_drainage_UK.R | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/R/PEC_sw_drainage_UK.R b/R/PEC_sw_drainage_UK.R index 4b3111e..2c7e28f 100644 --- a/R/PEC_sw_drainage_UK.R +++ b/R/PEC_sw_drainage_UK.R @@ -33,7 +33,8 @@ PEC_sw_drainage_UK <- function(rate, interception = 0, Koc, model = NULL, model_parms = NULL) { percentage_lost <- SSLRC_mobility_classification(Koc)[[2]] - amount_available <- rate * (1 - interception) # g/ha + if (inherits(rate, "units") && !identical(as.character(units(rate)), "g/ha")) stop("rate must have units g/ha, not ", units(rate)) + amount_available <- as.numeric(rate) * (1 - interception) # g/ha if (!missing(latest_application)) { lct <- Sys.getlocale("LC_TIME") @@ -62,6 +63,6 @@ PEC_sw_drainage_UK <- function(rate, interception = 0, Koc, } volume = 130000 # L/ha - PEC = 1e6 * (percentage_lost/100) * amount_available / volume + PEC = set_units(1e6 * (percentage_lost/100) * amount_available / volume, "µg/L") return(PEC) } |
