From 904a86fa92f1577414f2fce2bdbfe21e12381106 Mon Sep 17 00:00:00 2001 From: Ranke Johannes Date: Thu, 1 Feb 2024 10:39:53 +0100 Subject: Calculate drift percentages and PECsw using the Rautmann formula --- .Rhistory | 4 + GNUmakefile | 2 - NAMESPACE | 1 + R/PEC_sw_drift.R | 66 +++++++++--- R/drift_parameters_focus.R | 6 ++ _pkgdown.yml | 1 + data/drift_parameters_focus.RData | Bin 1455 -> 1458 bytes docs/pkgdown.yml | 2 +- docs/reference/PEC_sw_drift.html | 30 ++++-- docs/reference/drift_parameters_focus.html | 26 +++-- .../drift_percentages_rautmann_formula.html | 114 +++++++++++++++++++++ docs/reference/index.html | 5 + docs/search.json | 2 +- docs/sitemap.xml | 3 + inst/data_generation/drift_parameters_focus.R | 3 +- log/check.log | 2 +- man/PEC_sw_drift.Rd | 16 ++- man/drift_parameters_focus.Rd | 7 ++ man/drift_percentages_rautmann_formula.Rd | 33 ++++++ 19 files changed, 284 insertions(+), 39 deletions(-) create mode 100644 docs/reference/drift_percentages_rautmann_formula.html create mode 100644 man/drift_percentages_rautmann_formula.Rd diff --git a/.Rhistory b/.Rhistory index cf5f28b..14fd957 100644 --- a/.Rhistory +++ b/.Rhistory @@ -19,3 +19,7 @@ rdkit <- py_import(rdkit) rdkit <- import("rdkit") rdkit chent$new("isopropanol") +library(pfm) +drift_data_JKI +EFSA_washoff_2017 +?officer::read_docx diff --git a/GNUmakefile b/GNUmakefile index b987f41..b5ae886 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,8 +62,6 @@ winbuilder: build curl -T $(TGZ) ftp://anonymous@win-builder.r-project.org/R-devel/ pd: roxy - # In earlier versions, we used suppressWarnings to get - # rid of mbcsToSbcs warnings when plotting the 'µ' character Rscript -e 'pkgdown::build_site(lazy = TRUE, run_dont_run = TRUE)' pd_all: roxy diff --git a/NAMESPACE b/NAMESPACE index 3b23c45..6ee6389 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ export(SSLRC_mobility_classification) export(TOXSWA_cwa) export(TSCF) export(chent_focus_sw) +export(drift_percentages_rautmann_formula) export(endpoint) export(geomean) export(max_twa) diff --git a/R/PEC_sw_drift.R b/R/PEC_sw_drift.R index 2dfd651..1d22e4e 100644 --- a/R/PEC_sw_drift.R +++ b/R/PEC_sw_drift.R @@ -4,15 +4,15 @@ #' concentration in surface water based on complete, instantaneous mixing #' with input via spray drift. #' +#' @inheritParams drift_percentages_rautmann_formula #' @param rate Application rate in units specified below -#' @param applications Number of applications for selection of drift percentile #' @param drift_percentages Percentage drift values for which to calculate PECsw. #' 'drift_data' and 'distances' if not NULL. #' @param drift_data Source of drift percentage data. If 'JKI', the [drift_data_JKI] #' included in the package is used. If 'RF', the Rautmann formula is used, if #' implemented for the crop type and number of applications -#' @param crop Crop name (use German names for JKI data), defaults to "Ackerbau" -#' @param distances The distances in m for which to get PEC values +#' @param crop_group_JKI When using the 'JKI' drift data, one of the German names +#' as used in [drift_parameters_focus]. #' @param water_depth Depth of the water body in cm #' @param rate_units Defaults to g/ha #' @param PEC_units Requested units for the calculated PEC. Only µg/L currently supported @@ -24,9 +24,13 @@ #' # Alternatively, we can use the formula for a single application to "Ackerbau" from the paper #' PEC_sw_drift(100, drift_data = "RF") #' -#' # This makes it possible to also use different substances +#' # This makes it possible to also use different distances #' PEC_sw_drift(100, distances = c(1, 3, 5, 6, 10, 20, 50, 100), drift_data = "RF") #' +#' # or consider aerial application +#' PEC_sw_drift(100, distances = c(1, 3, 5, 6, 10, 20, 50, 100), drift_data = "RF", +#' crop_group_focus = "aerial") +#' #' # Using custom drift percentages is also supported #' PEC_sw_drift(100, drift_percentages = c(2.77, 0.95, 0.57, 0.48, 0.29, 0.15, 0.06, 0.03)) PEC_sw_drift <- function(rate, @@ -34,7 +38,11 @@ PEC_sw_drift <- function(rate, water_depth = 30, drift_percentages = NULL, drift_data = c("JKI", "RF"), - crop = "Ackerbau", + crop_group_JKI = c("Ackerbau", + "Obstbau frueh", "Obstbau spaet", "Weinbau frueh", "Weinbau spaet", + "Hopfenbau", "Flaechenkulturen > 900 l/ha", "Gleisanlagen"), + crop_group_focus = c("arable", "hops", "vines, late", "vines, early", + "fruit, late", "fruit, early", "aerial"), distances = c(1, 5, 10, 20), rate_units = "g/ha", PEC_units = "\u00B5g/L") @@ -42,22 +50,16 @@ PEC_sw_drift <- function(rate, rate_units <- match.arg(rate_units) PEC_units <- match.arg(PEC_units) drift_data <- match.arg(drift_data) + crop_group_JKI <- match.arg(crop_group_JKI) + crop_group_focus <- match.arg(crop_group_focus) water_volume <- 100 * 100 * (water_depth/100) * 1000 # in L (for 1 ha) PEC_sw_overspray <- rate * 1e6 / water_volume # in µg/L dist_index <- as.character(distances) - RF <- list( - "1" = list("Ackerbau" = function(distance) 2.7705 * distance^-0.9787) # p. 134 - ) - if (drift_data == "RF") { - if (is.null(RF[[as.character(applications)]])) stop("Rautmann formula not included for ", applications, " applications") - if (is.null(RF[[as.character(applications)]][[crop]])) stop("Rautmann formula not included for this case") - } - if (is.null(drift_percentages)) { drift_percentages <- switch(drift_data, - JKI = pfm::drift_data_JKI[[applications]][dist_index, crop], - RF = RF[[applications]][[crop]](distances) + JKI = pfm::drift_data_JKI[[applications]][dist_index, crop_group_JKI], + RF = drift_percentages_rautmann_formula(distances, applications, crop_group_focus) ) names(drift_percentages) <- paste(dist_index, "m") } else { @@ -67,3 +69,37 @@ PEC_sw_drift <- function(rate, PEC_sw_drift <- PEC_sw_overspray * drift_percentages / 100 return(PEC_sw_drift) } + +#' Calculate the drift percentages according to the Rautmann formula +#' +#' @param distances The distances in m for which to get PEC values +#' @param applications Number of applications for selection of drift percentile +#' @param crop_group_focus One of the crop groups as used in [drift_parameters_focus] +#' @export +#' @examples +# # One application on field crops, for 1 m, 3 m and 5 m distance +#' drift_data_JKI[[1]][as.character(c(1, 3, 5)), "Ackerbau"] +#' drift_percentages_rautmann_formula(c(1, 3, 5)) +#' +#' # One application to early or late fruit crops +#' drift_data_JKI[[1]][as.character(c(3, 5, 20, 50)), "Obstbau frueh"] +#' drift_percentages_rautmann_formula(c(3, 5, 20, 50), crop_group = "fruit, early") +#' drift_data_JKI[[1]][as.character(c(3, 5, 20, 50)), "Obstbau spaet"] +#' drift_percentages_rautmann_formula(c(3, 5, 20, 50), crop_group = "fruit, late") +drift_percentages_rautmann_formula <- function(distances, applications = 1, + crop_group_focus = c("arable", "hops", "vines, late", "vines, early", "fruit, late", + "fruit, early", "aerial")) +{ + cg <- match.arg(crop_group_focus) + if (!applications %in% 1:8) stop("Only 1 to 8 applications are supported") + parms <- pfm::drift_parameters_focus[pfm::drift_parameters_focus$crop_group == cg & + pfm::drift_parameters_focus$n_apps == applications, c("A", "B", "C", "D", "hinge")] + + drift_percentages = with(as.list(parms), { + A <- ifelse(distances < hinge, A, C) + B <- ifelse(distances < hinge, B, D) + A * distances^B + } + ) + return(drift_percentages) +} diff --git a/R/drift_parameters_focus.R b/R/drift_parameters_focus.R index 6a456c6..c5e5661 100644 --- a/R/drift_parameters_focus.R +++ b/R/drift_parameters_focus.R @@ -4,6 +4,11 @@ #' using the R code given in the file `data_generation/drift_parameters_focus.R` #' installed with this package. The appendix itself is not included in the package, #' as its licence is not clear. +#' +#' For the hinge distance, `Inf` was substituted for the cases where no hinge +#' distance is given in the data, in this way parameters C and D are never +#' used for any distance if A and B are used for the case that the distance +#' is smaller than the hinge distance. #' #' @name drift_parameters_focus #' @docType data @@ -23,4 +28,5 @@ #' @keywords datasets #' @examples #' drift_parameters_focus +#' unique(drift_parameters_focus$crop_group) "drift_parameters_focus" diff --git a/_pkgdown.yml b/_pkgdown.yml index 3cf966f..4db64b0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -38,6 +38,7 @@ reference: - PEC_sw_drift - drift_data_JKI - drift_parameters_focus + - drift_percentages_rautmann_formula - PEC_sw_drainage_UK - PEC_sw_sed - PEC_sw_focus diff --git a/data/drift_parameters_focus.RData b/data/drift_parameters_focus.RData index bf46775..332b86c 100644 Binary files a/data/drift_parameters_focus.RData and b/data/drift_parameters_focus.RData differ diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 8f897da..2b05895 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.1 pkgdown: 2.0.7 pkgdown_sha: ~ articles: {} -last_built: 2024-01-31T16:36Z +last_built: 2024-02-01T09:39Z urls: reference: https://pkgdown.jrwb.de/pfm/reference article: https://pkgdown.jrwb.de/pfm/articles diff --git a/docs/reference/PEC_sw_drift.html b/docs/reference/PEC_sw_drift.html index d4cd191..8c5bc3a 100644 --- a/docs/reference/PEC_sw_drift.html +++ b/docs/reference/PEC_sw_drift.html @@ -60,7 +60,10 @@ with input via spray drift.

water_depth = 30, drift_percentages = NULL, drift_data = c("JKI", "RF"), - crop = "Ackerbau", + crop_group_JKI = c("Ackerbau", "Obstbau frueh", "Obstbau spaet", "Weinbau frueh", + "Weinbau spaet", "Hopfenbau", "Flaechenkulturen > 900 l/ha", "Gleisanlagen"), + crop_group_focus = c("arable", "hops", "vines, late", "vines, early", "fruit, late", + "fruit, early", "aerial"), distances = c(1, 5, 10, 20), rate_units = "g/ha", PEC_units = "µg/L" @@ -92,8 +95,13 @@ included in the package is used. If 'RF', the Rautmann formula is used, if implemented for the crop type and number of applications

-
crop
-

Crop name (use German names for JKI data), defaults to "Ackerbau"

+
crop_group_JKI
+

When using the 'JKI' drift data, one of the German names +as used in drift_parameters_focus.

+ + +
crop_group_focus
+

One of the crop groups as used in drift_parameters_focus

distances
@@ -127,14 +135,22 @@ implemented for the crop type and number of applications

# Alternatively, we can use the formula for a single application to "Ackerbau" from the paper PEC_sw_drift(100, drift_data = "RF") #> 1 m 5 m 10 m 20 m -#> 0.92350000 0.19114149 0.09699222 0.04921742 +#> 0.91976667 0.19064473 0.09680051 0.04915079 -# This makes it possible to also use different substances +# This makes it possible to also use different distances PEC_sw_drift(100, distances = c(1, 3, 5, 6, 10, 20, 50, 100), drift_data = "RF") #> 1 m 3 m 5 m 6 m 10 m 20 m 50 m -#> 0.92350000 0.31512171 0.19114149 0.15990435 0.09699222 0.04921742 0.02007497 +#> 0.91976667 0.31415827 0.19064473 0.15951494 0.09680051 0.04915079 0.02006434 +#> 100 m +#> 0.01018774 + +# or consider aerial application +PEC_sw_drift(100, distances = c(1, 3, 5, 6, 10, 20, 50, 100), drift_data = "RF", + crop_group_focus = "aerial") +#> 1 m 3 m 5 m 6 m 10 m 20 m 50 m +#> 16.8233333 11.0585820 9.0986174 8.4866460 6.9825178 4.7004640 1.8820816 #> 100 m -#> 0.01018678 +#> 0.9417586 # Using custom drift percentages is also supported PEC_sw_drift(100, drift_percentages = c(2.77, 0.95, 0.57, 0.48, 0.29, 0.15, 0.06, 0.03)) diff --git a/docs/reference/drift_parameters_focus.html b/docs/reference/drift_parameters_focus.html index 4c7539a..c3f6386 100644 --- a/docs/reference/drift_parameters_focus.html +++ b/docs/reference/drift_parameters_focus.html @@ -63,6 +63,13 @@ as its licence is not clear.

Format

A tibble::tibble.

+
+
+

Details

+

For the hinge distance, Inf was substituted for the cases where no hinge +distance is given in the data, in this way parameters C and D are never +used for any distance if A and B are used for the case that the distance +is smaller than the hinge distance.

References

@@ -84,17 +91,20 @@ Bundesanst. Land- Forstwirtsch. 383, 133-141

#> # A tibble: 49 × 8 #> crop_group n_apps percentile A B C D hinge #> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 arable 1 90 2.76 -0.978 NA NA NA -#> 2 arable 2 82 2.44 -1.01 NA NA NA -#> 3 arable 3 77 2.02 -0.996 NA NA NA -#> 4 arable 4 74 1.86 -0.986 NA NA NA -#> 5 arable 5 72 1.79 -0.994 NA NA NA -#> 6 arable 6 70 1.63 -0.986 NA NA NA -#> 7 arable 7 69 1.58 -0.981 NA NA NA -#> 8 arable 8 67 1.51 -0.983 NA NA NA +#> 1 arable 1 90 2.76 -0.978 NA NA Inf +#> 2 arable 2 82 2.44 -1.01 NA NA Inf +#> 3 arable 3 77 2.02 -0.996 NA NA Inf +#> 4 arable 4 74 1.86 -0.986 NA NA Inf +#> 5 arable 5 72 1.79 -0.994 NA NA Inf +#> 6 arable 6 70 1.63 -0.986 NA NA Inf +#> 7 arable 7 69 1.58 -0.981 NA NA Inf +#> 8 arable 8 67 1.51 -0.983 NA NA Inf #> 9 hops 1 90 58.2 -1.00 8655. -2.84 15.3 #> 10 hops 2 82 66.2 -1.20 5555. -2.82 15.3 #> # ℹ 39 more rows +unique(drift_parameters_focus$crop_group) +#> [1] "arable" "hops" "vines, late" "vines, early" "fruit, late" +#> [6] "fruit, early" "aerial"