jranke / pfm
Showing 1 of 14 files from the diff.

@@ -8,7 +8,9 @@
Loading
8 8
#' @param applications Number of applications for selection of drift percentile
9 9
#' @param drift_percentages Percentage drift values for which to calculate PECsw.
10 10
#'   'drift_data' and 'distances' if not NULL.
11 -
#' @param drift_data Source of drift percentage data
11 +
#' @param drift_data Source of drift percentage data. If 'JKI', the [drift_data_JKI]
12 +
#'   included in the package is used. If 'RF', the Rautmann formula is used, if
13 +
#'   implemented for the crop type and number of applications
12 14
#' @param crop Crop name (use German names for JKI data), defaults to "Ackerbau"
13 15
#' @param distances The distances in m for which to get PEC values
14 16
#' @param water_depth Depth of the water body in cm
@@ -19,15 +21,23 @@
Loading
19 21
#' @author Johannes Ranke
20 22
#' @examples
21 23
#' PEC_sw_drift(100)
22 -
PEC_sw_drift <- function(rate, 
23 -
                         applications = 1,
24 -
                         water_depth = 30, 
25 -
                         drift_percentages = NULL,
26 -
                         drift_data = "JKI",
27 -
                         crop = "Ackerbau",
28 -
                         distances = c(1, 5, 10, 20),
29 -
                         rate_units = "g/ha",
30 -
                         PEC_units = "\u00B5g/L")
24 +
#' # Alternatively, we can use the formula for a single application to "Ackerbau" from the paper
25 +
#' PEC_sw_drift(100, drift_data = "RF")
26 +
#'
27 +
#' # This makes it possible to also use different substances
28 +
#' PEC_sw_drift(100, distances = c(1, 3, 5, 6, 10, 20, 50, 100), drift_data = "RF")
29 +
#'
30 +
#' # Using custom drift percentages is also supported
31 +
#' PEC_sw_drift(100, drift_percentages = c(2.77, 0.95, 0.57, 0.48, 0.29, 0.15, 0.06, 0.03))
32 +
PEC_sw_drift <- function(rate,
33 +
  applications = 1,
34 +
  water_depth = 30,
35 +
  drift_percentages = NULL,
36 +
  drift_data = c("JKI", "RF"),
37 +
  crop = "Ackerbau",
38 +
  distances = c(1, 5, 10, 20),
39 +
  rate_units = "g/ha",
40 +
  PEC_units = "\u00B5g/L")
31 41
{
32 42
  rate_units <- match.arg(rate_units)
33 43
  PEC_units <- match.arg(PEC_units)
@@ -36,8 +46,19 @@
Loading
36 46
  PEC_sw_overspray <- rate * 1e6 / water_volume          # in µg/L
37 47
  dist_index <- as.character(distances)
38 48
49 +
  RF <- list(
50 +
    "1" = list("Ackerbau" = function(distance) 2.7705 * distance^-0.9787) # p. 134
51 +
  )
52 +
  if (drift_data == "RF") {
53 +
    if (is.null(RF[[as.character(applications)]])) stop("Rautmann formula not included for ", applications, " applications")
54 +
    if (is.null(RF[[as.character(applications)]][[crop]])) stop("Rautmann formula not included for this case")
55 +
  }
56 +
39 57
  if (is.null(drift_percentages)) {
40 -
    drift_percentages <- pfm::drift_data_JKI[[applications]][dist_index, crop]
58 +
    drift_percentages <- switch(drift_data,
59 +
      JKI = pfm::drift_data_JKI[[applications]][dist_index, crop],
60 +
      RF =  RF[[applications]][[crop]](distances)
61 +
    )
41 62
    names(drift_percentages) <- paste(dist_index, "m")
42 63
  } else {
43 64
    names(drift_percentages) <- paste(drift_percentages, "%")
Files Coverage
R 69.05%
Project Totals (17 files) 69.05%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading