aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-07-10 17:57:33 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2018-07-10 17:59:19 +0200
commitcb3695dd434b3a3273217fb22c5ffb86065ae96d (patch)
treec37fbe68273e25d2741c0845665458357ac05450
parentc4c3ca282c6aadca82e392692ae4100fec1dd834 (diff)
EFSA PEC soil guidance from 2017
- Implement the new guidance as well as possible - Maintenance work addressing CRAN checks
-rw-r--r--.Rbuildignore1
-rw-r--r--ChangeLog14
-rw-r--r--DESCRIPTION4
-rw-r--r--GNUmakefile2
-rw-r--r--R/PEC_soil.R213
-rw-r--r--R/PEC_sw_exposit_runoff.R1
-rw-r--r--R/soil_scenario_data_EFSA_2015.R8
-rw-r--r--R/soil_scenario_data_EFSA_2017.R20
-rw-r--r--README.html2
-rw-r--r--README.md2
-rw-r--r--build.log3
-rw-r--r--data/soil_scenario_data_EFSA_2017.RDatabin0 -> 582 bytes
-rw-r--r--man/PEC_soil.Rd59
-rw-r--r--man/perc_runoff_exposit.Rd1
-rw-r--r--man/soil_scenario_data_EFSA_2015.Rd8
-rw-r--r--man/soil_scenario_data_EFSA_2017.Rd25
-rw-r--r--test.log38
-rw-r--r--tests/testthat/test_PEC_soil.R68
-rw-r--r--tests/testthat/test_PELMO.R10
-rw-r--r--tests/testthat/test_TOXSWA.R49
20 files changed, 407 insertions, 121 deletions
diff --git a/.Rbuildignore b/.Rbuildignore
index cbcae93..b6fc8e9 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -4,6 +4,7 @@
^README.html$
^build.log$
^test.log$
+^test.R$
^inst/extdata/Tabelle\ der\ Abdrifteckwerte.xls$
^inst/extdata/FOCUS_Step_12_scenarios.txt$
^_pkgdown.yml$
diff --git a/ChangeLog b/ChangeLog
index 2960fbe..e9c2e8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+commit c4c3ca282c6aadca82e392692ae4100fec1dd834
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2018-07-10 16:46:47 +0200
+
+ .out file from TOXSWA 5.5.3 for testing
+
+commit 8989a484b9b2d23463c95e0a3927e307ec0a5e64
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2018-07-04 10:59:47 +0200
+
+ Some documentation updates
+
+ Document that TOXSWA 5.5.3 is supported in the help files
+
commit 6ca8bdb8636141fac592688a6794ae092f0bc85a
Author: Johannes Ranke <jranke@uni-bremen.de>
Date: 2018-06-20 14:58:44 +0200
diff --git a/DESCRIPTION b/DESCRIPTION
index c1d967f..c7ea8a9 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Package: pfm
Type: Package
Title: Utilities for Pesticide Fate Modelling
-Version: 0.4-6
-Date: 2018-07-04
+Version: 0.5.1
+Date: 2018-07-10
Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de",
role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0003-4371-6538"))
diff --git a/GNUmakefile b/GNUmakefile
index a6b575c..c10c13a 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -57,7 +57,7 @@ winbin: $(WINBIN)
test: build
@echo "Running testthat tests..."
- "$(R_HOME)/bin/Rscript" -e 'devtools::test()' 2>&1 | tee test.log
+ NOT_CRAN=true "$(R_HOME)/bin/Rscript" -e 'devtools::test()' 2>&1 | tee test.log
@echo "DONE."
quickcheck: build
diff --git a/R/PEC_soil.R b/R/PEC_soil.R
index 15ccc90..1227f6a 100644
--- a/R/PEC_soil.R
+++ b/R/PEC_soil.R
@@ -17,23 +17,34 @@
# Register global variables
if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_type", "TP_identifier",
- "soil_scenario_data_EFSA_2015"))
+ "soil_scenario_data_EFSA_2015",
+ "soil_scenario_data_EFSA_2017", "bottom"))
#' Calculate predicted environmental concentrations in soil
#'
#' This is a basic calculation of a contaminant concentration in bulk soil
-#' based on complete, instantaneous mixing. If an interval is given, an
+#' based on complete, instantaneous mixing. If an interval is given, an
#' attempt is made at calculating a long term maximum concentration using
-#' the concepts layed out for example in the PPR panel opinion (EFSA 2012).
-#'
+#' the concepts layed out in the PPR panel opinion (EFSA PPR panel 2012
+#' and in the EFSA guidance on PEC soil calculations (EFSA, 2015, 2017).
+#'
#' This assumes that the complete load to soil during the time specified by
#' 'interval' (typically 365 days) is dosed at once. As in the PPR panel
-#' opinion cited below (PPR panel 2012), only temperature correction using the
-#' Arrhenius equation is performed.
-#'
+#' opinion cited below (EFSA PPR panel 2012), only temperature correction using the
+#' Arrhenius equation is performed.
+#'
#' Total soil and porewater PEC values for the scenarios as defined in the EFSA
-#' guidance (2015, p. 13) can easily be calculated.
-#'
+#' guidance (2017, p. 14/15) can easily be calculated.
+#' @note While time weighted average (TWA) concentrations given in the examples
+#' from the EFSA guidance from 2015 (p. 80) are be reproduced, this is not
+#' true for the TWA concentrations given for the same example in the EFSA guidance
+#' from 2017 (p. 92).
+#' @note According to the EFSA guidance (EFSA, 2017, p. 43), leaching should be
+#' taken into account for the EFSA 2017 scenarios, using the evaluation depth
+#' (here mixing depth) as the depth of the layer from which leaching takes
+#' place. However, as the amount leaching below the evaluation depth
+#' (often 5 cm) will partly be mixed back during tillage, the default in this function
+#' is to use the tillage depth for the calculation of the leaching rate.
#' @note If temperature information is available in the selected scenarios, as
#' e.g. in the EFSA scenarios, the DT50 for groundwater modelling
#' (destination 'PECgw') is taken from the chent object, otherwise the DT50
@@ -49,7 +60,17 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_typ
#' @param PEC_units Requested units for the calculated PEC. Only mg/kg currently supported
#' @param PEC_pw_units Only mg/L currently supported
#' @param tillage_depth Periodic (see interval) deeper mixing in cm
-#' @param chent An optional chent object holding substance specific information. Can
+#' @param leaching_depth EFSA (2017) uses the mixing depth (ecotoxicological
+#' evaluation depth) to calculate leaching for annual crops where tillage
+#' takes place. By default, losses from the layer down to the tillage
+#' depth are taken into account in this implementation.
+#' @param cultivation Does mechanical cultivation in the sense of EFSA (2017)
+#' take place, i.e. twice a year to a depth of 5 cm? Ignored for scenarios
+#' other than EFSA_2017
+#' @param crop Ignored for scenarios other than EFSA_2017. Only annual crops
+#' are supported when these scenarios are used. Only crops with a single cropping
+#' cycle per year are currently supported.
+#' @param chent An optional chent object holding substance specific information. Can
#' also be a name for the substance as a character string
#' @param DT50 If specified, overrides soil DT50 endpoints from a chent object
#' If DT50 is not specified here and not available from the chent object, zero
@@ -65,6 +86,8 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_typ
#' 'chents' is specified, the DegT50 with destination 'PECgw' will be used),
#' and corrected using an Arrhenius activation energy of 65.4 kJ/mol. Also
#' model and scenario adjustment factors from the EFSA guidance are used.
+#' @param leaching Should leaching be taken into account? The default is FALSE,
+#' except when the EFSA_2017 scenarios are used.
#' @param porewater Should equilibrium porewater concentrations be estimated
#' based on Kom and the organic carbon fraction of the soil instead of total
#' soil concentrations? Based on equation (7) given in the PPR panel opinion
@@ -76,23 +99,38 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_typ
#' selection and scenario parameterisation for predicting environmental
#' concentrations of plant protection products in soil. \emph{EFSA Journal}
#' \bold{10}(2) 2562, doi:10.2903/j.efsa.2012.2562
-#'
+#'
+#' EFSA (European Food Safety Authority) 2017) EFSA guidance document for
+#' predicting environmental concentrations of active substances of plant
+#' protection products and transformation products of these active substances
+#' in soil. \emph{EFSA Journal} \bold{15}(10) 4982
+#' doi:10.2903/j.efsa.2017.4982
+#'
#' EFSA (European Food Safety Authority) (2015) EFSA guidance document for
#' predicting environmental concentrations of active substances of plant
#' protection products and transformation products of these active substances
#' in soil. \emph{EFSA Journal} \bold{13}(4) 4093
#' doi:10.2903/j.efsa.2015.4093
+#'
#' @author Johannes Ranke
#' @export
#' @examples
#' PEC_soil(100, interception = 0.25)
#'
+#' # This is example 1 starting at p. 92 of the EFSA guidance (2017)
+#' # Note that TWA concentrations differ from the ones given in the guidance
+#' # for an unknown reason (the values from EFSA (2015) can be reproduced).
+#' PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+#' Kom = 1000, scenarios = "EFSA_2017")
+#' PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+#' Kom = 1000, scenarios = "EFSA_2017", porewater = TRUE)
+#'
#' # This is example 1 starting at p. 79 of the EFSA guidance (2015)
#' PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
#' scenarios = "EFSA_2015")
#' PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
#' Kom = 1000, scenarios = "EFSA_2015", porewater = TRUE)
-#'
+#'
#' # The following is from example 4 starting at p. 85 of the EFSA guidance (2015)
#' # Metabolite M2
#' # Calculate total and porewater soil concentrations for tier 1 scenarios
@@ -103,34 +141,97 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_typ
#' Kom = 100, scenarios = "EFSA_2015", porewater = TRUE)
PEC_soil <- function(rate, rate_units = "g/ha", interception = 0,
- mixing_depth = 5,
+ mixing_depth = 5,
PEC_units = "mg/kg", PEC_pw_units = "mg/L",
interval = NA, n_periods = Inf,
- tillage_depth = 20,
- chent = NA,
- DT50 = NA,
+ tillage_depth = 20,
+ leaching_depth = tillage_depth,
+ crop = "annual",
+ cultivation = FALSE,
+ chent = NA,
+ DT50 = NA,
Koc = NA, Kom = Koc / 1.724,
t_avg = 0,
- scenarios = c("default", "EFSA_2015"),
+ scenarios = c("default", "EFSA_2017", "EFSA_2015"),
+ leaching = scenarios == "EFSA_2017",
porewater = FALSE)
{
+ # Comments with equation numbers in parentheses refer to
+ # the numbering in the EFSA guidance from 2017, appendix A
rate_to_soil = (1 - interception) * rate
rate_units = match.arg(rate_units)
PEC_units = match.arg(PEC_units)
scenarios = match.arg(scenarios)
- sce <- switch(scenarios,
+ if (scenarios == "EFSA_2017") {
+ if (crop != "annual") stop("Only annual crops are currently supported")
+ if (cultivation) stop("Permanent crops with mechanical cultivation are currently not supported")
+ }
+ sce <- switch(scenarios,
default = data.frame(rho = 1.5, T_arr = NA, theta_fc = 0.2, f_om = 1.724 * 0.02,
f_sce = 1, f_mod = 1, row.names = "default"),
- EFSA_2015 = if (porewater) soil_scenario_data_EFSA_2015[4:6, ]
- else soil_scenario_data_EFSA_2015[1:3, ]
+ EFSA_2015 = if (porewater) soil_scenario_data_EFSA_2015[4:6, ]
+ else soil_scenario_data_EFSA_2015[1:3, ],
+ EFSA_2017 = if (porewater) soil_scenario_data_EFSA_2017[4:6, ]
+ else soil_scenario_data_EFSA_2017[1:3, ]
)
n_sce = nrow(sce)
soil_volume = 100 * 100 * (mixing_depth/100) # in m3
soil_mass = soil_volume * sce$rho * 1000 # in kg
+ # In EFSA (2017), f_om is depth dependent for permanent crops
+ # For annual crops, the correction factor is 1 (uniform f_om is
+ # assumed)
+ mixing_depth_string <- paste(mixing_depth, "cm")
+ tillage_depth_string <- paste(tillage_depth, "cm")
+ if (scenarios == "EFSA_2017" & crop != "annual") {
+ # Correction factors f_f_om with depth according to EFSA 2017, p. 15
+ f_f_om_depth = data.frame(
+ depth = c("0-5", "5-10", "10-20", "20-30"),
+ bottom = c(5, 10, 20, 30),
+ thickness = c(5, 5, 10, 10),
+ f_f_om_no_cultivation = c(1.95, 1.30, 0.76, 0.62),
+ f_f_om_cultivation = c(1.50, 1.20, 0.90, 0.75))
+ # Averages for the 0-5 cm and 0-20 cm layers
+ f_f_om_layer = data.frame(
+ layer = c("0-5", "0-20"),
+ f_f_om_no_cultivation = c(1.95, (5 * 1.95 + 5 * 1.3 + 10 * 0.76)/20),
+ f_f_om_cultivation = c(1.50, (5 * 1.5 + 5 * 1.2 + 10 * 0.9)/20))
+ # The resulting mean value for 0-20 cm and no cultivation of 1.1925 is
+ # consistent with the value of 1.19 given in Table B.4 on p. 54 of the
+ # 2017 EFSA guidance
+
+ f_f_om_average <- function(depth, cultivation) {
+ rownames(f_f_om_layer) = paste(f_f_om_layer$layer, "cm")
+ if (depth %in% c(5, 20)) {
+ if (cultivation) {
+ return(f_f_om_layer[paste0("0-", depth, " cm"), "f_f_om_cultivation"])
+ } else {
+ return(f_f_om_layer[paste0("0-", depth, " cm"), "f_f_om_no_cultivation"])
+ }
+ } else {
+ stop("Depths other than 5 and 20 cm are not supported when using EFSA 2017 scenarios for permanent crops")
+ }
+ }
+
+ # For the loss via leaching, the equilibrium and therefore the f_om at the
+ # bottom of the layer is probably most relevant. Unfortunately this is not
+ # clarified in the guidance.
+ f_f_om_bottom <- function(depth, cultivation) {
+ bottom_depth <- depth # rename to avoid confusion when subsetting
+ if (cultivation) {
+ f_f_om <- subset(f_f_om_depth, bottom == bottom_depth)$f_f_om_cultivation
+ } else {
+ f_f_om <- subset(f_f_om_depth, bottom == bottom_depth)$f_f_om_no_cultivation
+ }
+ return(f_f_om)
+ }
+ } else {
+ f_f_om_average <- f_f_om_bottom <- function(depth, cultivation) 1
+ }
+
# The following is C_T,ini from EFSA 2012, p. 22, but potentially with interception > 0
- PEC_soil_ini = rate_to_soil * 1000 / soil_mass # in mg/kg
+ PEC_soil_ini = rate_to_soil * 1000 / soil_mass # in mg/kg (A1)
# Decide which DT50 to take, or set degradation to zero if no DT50 available
if (is.na(DT50) & is(chent, "chent")) {
@@ -142,26 +243,56 @@ PEC_soil <- function(rate, rate_units = "g/ha", interception = 0,
if (length(DT50) > 1) stop("More than one PECsoil DT50 in chent object")
if (length(DT50) == 0) DT50 <- Inf
}
- k = log(2)/DT50
+ k_ref = log(2)/DT50 # (A5)
# Temperature correction of degradation (accumulation)
if (all(is.na(sce$T_arr))) { # No temperature correction
f_T = 1
} else {
# Temperature correction as in EFSA 2012 p. 23
- f_T = ifelse(sce$T_arr == 0,
- 0,
- exp(- (65.4 / 0.008314) * (1/(sce$T_arr + 273.15) - 1/293.15)))
+ f_T = ifelse(sce$T_arr == 0,
+ 0, # (A4b)
+ exp(- (65.4 / 0.008314) * (1/(sce$T_arr + 273.15) - 1/293.15))) # (A4a)
}
- # X is the fraction left after one period (EFSA guidance p. 23)
- X = exp(- k * f_T * interval)
-
+ # Define Kom if needed
+ if (leaching | porewater) {
+ # If Kom is not specified, try to get K(f)oc
+ if (is.na(Kom)) {
+ # If Koc not specified, try to get K(f)oc from chent
+ if (is.na(Koc) & is(chent, "chent")) {
+ Koc <- soil_Kfoc(chent)
+ } else {
+ stop("No Kom information specified")
+ }
+ Kom <- Koc / 1.724
+ }
+ }
+
+ if (leaching) {
+ leaching_depth_string <- paste(leaching_depth, "cm")
+ f_q <- c("1 cm" = 0.8, "2.5 cm" = 0.75, "5 cm" = 0.7, "20 cm" = 0.5) # EFSA 2017 p. 54
+ if (leaching_depth_string %in% names(f_q)) {
+ q_mm_year = f_q[leaching_depth_string] * sce$prec # Irrigation at tier 1? I have not found values for Tier 1
+ q_dm_day = q_mm_year / (100 * 365)
+ leaching_depth_dm <- leaching_depth / 10
+
+ k_leach = q_dm_day/(leaching_depth_dm * (sce$theta_fc + sce$rho * f_f_om_average(leaching_depth, cultivation) * sce$f_om * Kom))
+ } else {
+ stop("Leaching can not be calculated, because f_q for this leaching depth is undefined")
+ }
+ } else {
+ k_leach = 0
+ }
+
+ # X is the fraction left after one period (EFSA 2017 guidance p. 23)
+ X = exp(- (k_ref * f_T + k_leach) * interval) # (A3)
+
# f_accu is the fraction left after n periods (X + X^2 + ...)
- f_accu = 0
+ f_accu = 0
if (!is.na(interval)) {
if (n_periods == Inf) {
- f_accu = X/(1 - X)
+ f_accu = X/(1 - X) # part of (A2)
} else {
for (i in 1:n_periods) {
f_accu = f_accu + X^i
@@ -171,25 +302,14 @@ PEC_soil <- function(rate, rate_units = "g/ha", interception = 0,
f_tillage = mixing_depth / tillage_depth
- PEC_background = f_accu * f_tillage * PEC_soil_ini
+ PEC_background = f_accu * f_tillage * PEC_soil_ini # (A2)
- PEC_soil = (1 + f_accu * f_tillage) * PEC_soil_ini
+ PEC_soil = PEC_soil_ini + PEC_background # (A6)
# Get porewater PEC if requested
if (porewater) {
- # If Kom is not specified, try to get K(f)oc
- if (is.na(Kom)) {
- # If Koc not specified, try to get K(f)oc from chent
- if (is.na(Koc) & is(chent, "chent")) {
- Koc <- soil_Kfoc(chent)
- }
- Kom <- Koc / 1.724
- }
-
- if (is.na(Kom)) stop("No Kom information specified")
-
- PEC_soil = PEC_soil/((sce$theta_fc/sce$rho) + sce$f_om * Kom)
+ PEC_soil = PEC_soil/((sce$theta_fc/sce$rho) + f_f_om_average(mixing_depth, cultivation) * sce$f_om * Kom) # (A7)
}
# Scenario adjustment factors
@@ -200,14 +320,15 @@ PEC_soil <- function(rate, rate_units = "g/ha", interception = 0,
result <- matrix(NA, ncol = n_sce, nrow = length(t_avg),
dimnames = list(t_avg = t_avg, scenario = rownames(sce)))
-
+
result[1, ] <- PEC_soil_sce_mod
for (i in seq_along(t_avg)) {
t_av_i <- t_avg[i]
+ k_avg <- f_T * k_ref # Leaching not taken into account, EFSA 2017 p. 43
if (t_av_i > 0) {
# Equation 10 from p. 24 (EFSA 2015)
- result[i, ] <- PEC_soil_sce_mod/(t_av_i * f_T * k) * (1 - exp(- f_T * k * t_av_i))
+ result[i, ] <- PEC_soil_sce_mod/(t_av_i * k_avg) * (1 - exp(- k_avg * t_av_i)) # (A8)
}
}
diff --git a/R/PEC_sw_exposit_runoff.R b/R/PEC_sw_exposit_runoff.R
index f56b8f8..733f621 100644
--- a/R/PEC_sw_exposit_runoff.R
+++ b/R/PEC_sw_exposit_runoff.R
@@ -6,6 +6,7 @@
#' @format A data frame with percentage values for the dissolved fraction and the fraction
#' bound to eroding particles, with Koc classes used as row names
#' \describe{
+#' \item{Koc_lower_bound}{The lower bound of the Koc class}
#' \item{dissolved}{The percentage of the applied substance transferred to an
#' adjacent water body in the dissolved phase}
#' \item{bound}{The percentage of the applied substance transferred to an
diff --git a/R/soil_scenario_data_EFSA_2015.R b/R/soil_scenario_data_EFSA_2015.R
index fb096bc..660cafe 100644
--- a/R/soil_scenario_data_EFSA_2015.R
+++ b/R/soil_scenario_data_EFSA_2015.R
@@ -10,10 +10,10 @@
#' e.g. CTN for the Northern scenario for the total concentration in soil. Columns are
#' mostly self-explanatory. \code{rho} is the dry bulk density of the top soil.
#' @source EFSA (European Food Safety Authority) (2015)
-#' EFSA guidance document for predicting environmental concentrations
-#' of active substances of plant protection products and transformation products of these
-#' active substances in soil. \emph{EFSA Journal} \bold{13}(4) 4093
-#' doi:10.2903/j.efsa.2015.4093
+#' EFSA guidance document for predicting environmental concentrations
+#' of active substances of plant protection products and transformation products of these
+#' active substances in soil. \emph{EFSA Journal} \bold{13}(4) 4093
+#' doi:10.2903/j.efsa.2015.4093
#' @keywords datasets
#' @examples
#' \dontrun{
diff --git a/R/soil_scenario_data_EFSA_2017.R b/R/soil_scenario_data_EFSA_2017.R
new file mode 100644
index 0000000..79ee15f
--- /dev/null
+++ b/R/soil_scenario_data_EFSA_2017.R
@@ -0,0 +1,20 @@
+#' Properties of the predefined scenarios from the EFSA guidance from 2017
+#'
+#' Properties of the predefined scenarios used at Tier 1, Tier 2A and Tier 3A for the
+#' concentration in soil as given in the EFSA guidance (2017, p. 14/15). Also, the
+#' scenario and model adjustment factors from p. 16 and p. 18 are included.
+#'
+#' @name soil_scenario_data_EFSA_2017
+#' @docType data
+#' @format A data frame with one row for each scenario. Row names are the scenario codes,
+#' e.g. CTN for the Northern scenario for the total concentration in soil. Columns are
+#' mostly self-explanatory. \code{rho} is the dry bulk density of the top soil.
+#' @source EFSA (European Food Safety Authority) (2017)
+#' EFSA guidance document for predicting environmental concentrations
+#' of active substances of plant protection products and transformation products of these
+#' active substances in soil. \emph{EFSA Journal} \bold{15}(10) 4982
+#' doi:10.2903/j.efsa.2017.4982
+#' @keywords datasets
+#' @examples
+#' soil_scenario_data_EFSA_2017
+NULL
diff --git a/README.html b/README.html
index ef6dfca..77a9d18 100644
--- a/README.html
+++ b/README.html
@@ -138,7 +138,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see &lt;http://www.gnu.org/licenses/&gt;</code></pre>
<div id="installation" class="section level2">
<h2>Installation</h2>
-<p>The easiest way to install the package is probably to use <a href="http://cran.r-project.org/package=drat">drat</a>:</p>
+<p>The easiest way to install the package is probably to use <a href="https://cran.r-project.org/package=drat">drat</a>:</p>
<pre class="r"><code>install.packages(&quot;drat&quot;)
drat::addRepo(&quot;jranke&quot;)
install.packages(&quot;pfm&quot;)</code></pre>
diff --git a/README.md b/README.md
index 68874f2..ab34018 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ This means:
## Installation
The easiest way to install the package is probably to use
-[drat](http://cran.r-project.org/package=drat):
+[drat](https://cran.r-project.org/package=drat):
```r
install.packages("drat")
diff --git a/build.log b/build.log
index ea12067..e77bb21 100644
--- a/build.log
+++ b/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/inst/testdata/SwashProjects/Project_1/MACRO’
* looking to see if a ‘data/datalist’ file should be added
-* building ‘pfm_0.4-6.tar.gz’
+* building ‘pfm_0.5.1.tar.gz’
diff --git a/data/soil_scenario_data_EFSA_2017.RData b/data/soil_scenario_data_EFSA_2017.RData
new file mode 100644
index 0000000..ff8f045
--- /dev/null
+++ b/data/soil_scenario_data_EFSA_2017.RData
Binary files differ
diff --git a/man/PEC_soil.Rd b/man/PEC_soil.Rd
index 1491790..f9e82e8 100644
--- a/man/PEC_soil.Rd
+++ b/man/PEC_soil.Rd
@@ -6,9 +6,11 @@
\usage{
PEC_soil(rate, rate_units = "g/ha", interception = 0, mixing_depth = 5,
PEC_units = "mg/kg", PEC_pw_units = "mg/L", interval = NA,
- n_periods = Inf, tillage_depth = 20, chent = NA, DT50 = NA,
+ n_periods = Inf, tillage_depth = 20, leaching_depth = tillage_depth,
+ crop = "annual", cultivation = FALSE, chent = NA, DT50 = NA,
Koc = NA, Kom = Koc/1.724, t_avg = 0, scenarios = c("default",
- "EFSA_2015"), porewater = FALSE)
+ "EFSA_2017", "EFSA_2015"), leaching = scenarios == "EFSA_2017",
+ porewater = FALSE)
}
\arguments{
\item{rate}{Application rate in units specified below}
@@ -30,7 +32,20 @@ degradation rate units are in days}
\item{tillage_depth}{Periodic (see interval) deeper mixing in cm}
-\item{chent}{An optional chent object holding substance specific information. Can
+\item{leaching_depth}{EFSA (2017) uses the mixing depth (ecotoxicological
+evaluation depth) to calculate leaching for annual crops where tillage
+takes place. By default, losses from the layer down to the tillage
+depth are taken into account in this implementation.}
+
+\item{crop}{Ignored for scenarios other than EFSA_2017. Only annual crops
+are supported when these scenarios are used. Only crops with a single cropping
+cycle per year are currently supported.}
+
+\item{cultivation}{Does mechanical cultivation in the sense of EFSA (2017)
+take place, i.e. twice a year to a depth of 5 cm? Ignored for scenarios
+other than EFSA_2017}
+
+\item{chent}{An optional chent object holding substance specific information. Can
also be a name for the substance as a character string}
\item{DT50}{If specified, overrides soil DT50 endpoints from a chent object
@@ -52,6 +67,9 @@ the DT50 is taken to be a modelling half-life at 20°C and pF2 (for when
and corrected using an Arrhenius activation energy of 65.4 kJ/mol. Also
model and scenario adjustment factors from the EFSA guidance are used.}
+\item{leaching}{Should leaching be taken into account? The default is FALSE,
+except when the EFSA_2017 scenarios are used.}
+
\item{porewater}{Should equilibrium porewater concentrations be estimated
based on Kom and the organic carbon fraction of the soil instead of total
soil concentrations? Based on equation (7) given in the PPR panel opinion
@@ -63,20 +81,33 @@ The predicted concentration in soil
}
\description{
This is a basic calculation of a contaminant concentration in bulk soil
-based on complete, instantaneous mixing. If an interval is given, an
+based on complete, instantaneous mixing. If an interval is given, an
attempt is made at calculating a long term maximum concentration using
-the concepts layed out for example in the PPR panel opinion (EFSA 2012).
+the concepts layed out in the PPR panel opinion (EFSA PPR panel 2012
+and in the EFSA guidance on PEC soil calculations (EFSA, 2015, 2017).
}
\details{
This assumes that the complete load to soil during the time specified by
'interval' (typically 365 days) is dosed at once. As in the PPR panel
-opinion cited below (PPR panel 2012), only temperature correction using the
+opinion cited below (EFSA PPR panel 2012), only temperature correction using the
Arrhenius equation is performed.
Total soil and porewater PEC values for the scenarios as defined in the EFSA
-guidance (2015, p. 13) can easily be calculated.
+guidance (2017, p. 14/15) can easily be calculated.
}
\note{
+While time weighted average (TWA) concentrations given in the examples
+from the EFSA guidance from 2015 (p. 80) are be reproduced, this is not
+true for the TWA concentrations given for the same example in the EFSA guidance
+from 2017 (p. 92).
+
+According to the EFSA guidance (EFSA, 2017, p. 43), leaching should be
+ taken into account for the EFSA 2017 scenarios, using the evaluation depth
+ (here mixing depth) as the depth of the layer from which leaching takes
+ place. However, as the amount leaching below the evaluation depth
+ (often 5 cm) will partly be mixed back during tillage, the default in this function
+ is to use the tillage depth for the calculation of the leaching rate.
+
If temperature information is available in the selected scenarios, as
e.g. in the EFSA scenarios, the DT50 for groundwater modelling
(destination 'PECgw') is taken from the chent object, otherwise the DT50
@@ -85,6 +116,14 @@ If temperature information is available in the selected scenarios, as
\examples{
PEC_soil(100, interception = 0.25)
+# This is example 1 starting at p. 92 of the EFSA guidance (2017)
+# Note that TWA concentrations differ from the ones given in the guidance
+# for an unknown reason (the values from EFSA (2015) can be reproduced).
+PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2017")
+PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2017", porewater = TRUE)
+
# This is example 1 starting at p. 79 of the EFSA guidance (2015)
PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
scenarios = "EFSA_2015")
@@ -107,6 +146,12 @@ EFSA Panel on Plant Protection Products and their Residues (2012)
concentrations of plant protection products in soil. \emph{EFSA Journal}
\bold{10}(2) 2562, doi:10.2903/j.efsa.2012.2562
+ EFSA (European Food Safety Authority) 2017) EFSA guidance document for
+ predicting environmental concentrations of active substances of plant
+ protection products and transformation products of these active substances
+ in soil. \emph{EFSA Journal} \bold{15}(10) 4982
+ doi:10.2903/j.efsa.2017.4982
+
EFSA (European Food Safety Authority) (2015) EFSA guidance document for
predicting environmental concentrations of active substances of plant
protection products and transformation products of these active substances
diff --git a/man/perc_runoff_exposit.Rd b/man/perc_runoff_exposit.Rd
index 4f460e4..bdc36e8 100644
--- a/man/perc_runoff_exposit.Rd
+++ b/man/perc_runoff_exposit.Rd
@@ -6,6 +6,7 @@
\format{A data frame with percentage values for the dissolved fraction and the fraction
bound to eroding particles, with Koc classes used as row names
\describe{
+ \item{Koc_lower_bound}{The lower bound of the Koc class}
\item{dissolved}{The percentage of the applied substance transferred to an
adjacent water body in the dissolved phase}
\item{bound}{The percentage of the applied substance transferred to an
diff --git a/man/soil_scenario_data_EFSA_2015.Rd b/man/soil_scenario_data_EFSA_2015.Rd
index 02c16dc..64c00a8 100644
--- a/man/soil_scenario_data_EFSA_2015.Rd
+++ b/man/soil_scenario_data_EFSA_2015.Rd
@@ -9,10 +9,10 @@
mostly self-explanatory. \code{rho} is the dry bulk density of the top soil.}
\source{
EFSA (European Food Safety Authority) (2015)
-EFSA guidance document for predicting environmental concentrations
-of active substances of plant protection products and transformation products of these
-active substances in soil. \emph{EFSA Journal} \bold{13}(4) 4093
-doi:10.2903/j.efsa.2015.4093
+ EFSA guidance document for predicting environmental concentrations
+ of active substances of plant protection products and transformation products of these
+ active substances in soil. \emph{EFSA Journal} \bold{13}(4) 4093
+ doi:10.2903/j.efsa.2015.4093
}
\description{
Properties of the predefined scenarios used at Tier 1, Tier 2A and Tier 3A for the
diff --git a/man/soil_scenario_data_EFSA_2017.Rd b/man/soil_scenario_data_EFSA_2017.Rd
new file mode 100644
index 0000000..aeaacac
--- /dev/null
+++ b/man/soil_scenario_data_EFSA_2017.Rd
@@ -0,0 +1,25 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/soil_scenario_data_EFSA_2017.R
+\docType{data}
+\name{soil_scenario_data_EFSA_2017}
+\alias{soil_scenario_data_EFSA_2017}
+\title{Properties of the predefined scenarios from the EFSA guidance from 2017}
+\format{A data frame with one row for each scenario. Row names are the scenario codes,
+ e.g. CTN for the Northern scenario for the total concentration in soil. Columns are
+ mostly self-explanatory. \code{rho} is the dry bulk density of the top soil.}
+\source{
+EFSA (European Food Safety Authority) (2017)
+ EFSA guidance document for predicting environmental concentrations
+ of active substances of plant protection products and transformation products of these
+ active substances in soil. \emph{EFSA Journal} \bold{15}(10) 4982
+ doi:10.2903/j.efsa.2017.4982
+}
+\description{
+Properties of the predefined scenarios used at Tier 1, Tier 2A and Tier 3A for the
+concentration in soil as given in the EFSA guidance (2017, p. 14/15). Also, the
+scenario and model adjustment factors from p. 16 and p. 18 are included.
+}
+\examples{
+soil_scenario_data_EFSA_2017
+}
+\keyword{datasets}
diff --git a/test.log b/test.log
index 2692d54..f16336b 100644
--- a/test.log
+++ b/test.log
@@ -2,23 +2,25 @@ Loading pfm
Loading required package: testthat
Loading required package: R6
Loading required package: mkin
-Loading required package: minpack.lm
-Loading required package: rootSolve
-Loading required package: inline
-Loading required package: methods
-Loading required package: parallel
Testing pfm
-Exposit runoff calculations: ...
-Geometric mean calculation: ......
-Check max_twa for parent mkinfit models against analytical solutions: .
-Simple PEC sediment calculations: .
-Simple PEC soil calculations: ...........
-Simple PEC surface water calculations with drift entry: ..
-Create PELMO runs from psm files and execute them: ...........................................................................................................................................................................................................................
-Actual and time weighted average concentrations for SFO kinetics: .
-FOCUS Step 1 calculations: .........
-FOCUS Steps 12 input files: ........
-Read and analyse TOXSWA cwa files: .......
-UK drainage PEC calculations: ............
+✔ | OK F W S | Context
+ ⠏ | 0 | Exposit runoff calculations ⠋ | 1 | Exposit runoff calculations ⠙ | 2 | Exposit runoff calculations ⠹ | 3 | Exposit runoff calculations ✔ | 3 | Exposit runoff calculations
+ ⠏ | 0 | Geometric mean calculation ⠋ | 1 | Geometric mean calculation ⠙ | 2 | Geometric mean calculation ⠹ | 3 | Geometric mean calculation ⠸ | 4 | Geometric mean calculation ⠼ | 5 | Geometric mean calculation ⠴ | 6 | Geometric mean calculation ✔ | 6 | Geometric mean calculation
+ ⠏ | 0 | Check max_twa for parent mkinfit models against analytical solutions ⠋ | 1 | Check max_twa for parent mkinfit models against analytical solutions ✔ | 1 | Check max_twa for parent mkinfit models against analytical solutions [1.0 s]
+ ⠏ | 0 | Simple PEC sediment calculations ⠋ | 1 | Simple PEC sediment calculations ✔ | 1 | Simple PEC sediment calculations
+ ⠏ | 0 | Simple PEC soil calculations ⠋ | 1 | Simple PEC soil calculations ⠙ | 2 | Simple PEC soil calculations ⠹ | 3 | Simple PEC soil calculations ⠸ | 4 | Simple PEC soil calculations ⠼ | 5 | Simple PEC soil calculations ⠴ | 6 | Simple PEC soil calculations ⠦ | 7 | Simple PEC soil calculations ⠧ | 8 | Simple PEC soil calculations ⠇ | 9 | Simple PEC soil calculations ⠏ | 10 | Simple PEC soil calculations ⠋ | 11 | Simple PEC soil calculations ⠙ | 12 | Simple PEC soil calculations ⠹ | 13 | Simple PEC soil calculations ✔ | 13 | Simple PEC soil calculations
+ ⠏ | 0 | Simple PEC surface water calculations with drift entry ⠋ | 1 | Simple PEC surface water calculations with drift entry ⠙ | 2 | Simple PEC surface water calculations with drift entry ✔ | 2 | Simple PEC surface water calculations with drift entry
+ ⠏ | 0 | Create PELMO runs from psm files and execute them ⠋ | 1 | Create PELMO runs from psm files and execute them ⠙ | 2 | Create PELMO runs from psm files and execute them ⠹ | 3 | Create PELMO runs from psm files and execute them ⠸ | 4 | Create PELMO runs from psm files and execute them ⠼ | 5 | Create PELMO runs from psm files and execute them ⠴ | 6 | Create PELMO runs from psm files and execute them ⠦ | 7 | Create PELMO runs from psm files and execute them ⠧ | 8 | Create PELMO runs from psm files and execute them ⠇ | 9 | Create PELMO runs from psm files and execute them ⠏ | 10 | Create PELMO runs from psm files and execute them ⠋ | 11 | Create PELMO runs from psm files and execute them ⠙ | 12 | Create PELMO runs from psm files and execute them ⠹ | 13 | Create PELMO runs from psm files and execute them ⠸ | 14 | Create PELMO runs from psm files and execute them ⠼ | 15 | Create PELMO runs from psm files and execute them ⠴ | 16 | Create PELMO runs from psm files and execute them ⠦ | 17 | Create PELMO runs from psm files and execute them ⠧ | 18 | Create PELMO runs from psm files and execute them ⠇ | 19 | Create PELMO runs from psm files and execute them ⠏ | 20 | Create PELMO runs from psm files and execute them ⠋ | 21 | Create PELMO runs from psm files and execute them ⠙ | 22 | Create PELMO runs from psm files and execute them ⠹ | 23 | Create PELMO runs from psm files and execute them ⠸ | 24 | Create PELMO runs from psm files and execute them ⠼ | 25 | Create PELMO runs from psm files and execute them ⠴ | 26 | Create PELMO runs from psm files and execute them ⠦ | 27 | Create PELMO runs from psm files and execute them ⠧ | 28 | Create PELMO runs from psm files and execute them ⠇ | 29 | Create PELMO runs from psm files and execute them ⠏ | 30 | Create PELMO runs from psm files and execute them ⠋ | 31 | Create PELMO runs from psm files and execute them ⠙ | 32 | Create PELMO runs from psm files and execute them ⠹ | 33 | Create PELMO runs from psm files and execute them ⠸ | 34 | Create PELMO runs from psm files and execute them ⠼ | 35 | Create PELMO runs from psm files and execute them ⠴ | 36 | Create PELMO runs from psm files and execute them ⠦ | 37 | Create PELMO runs from psm files and execute them ⠧ | 38 | Create PELMO runs from psm files and execute them ⠇ | 39 | Create PELMO runs from psm files and execute them ⠏ | 40 | Create PELMO runs from psm files and execute them ⠋ | 41 | Create PELMO runs from psm files and execute them ⠙ | 42 | Create PELMO runs from psm files and execute them ⠹ | 43 | Create PELMO runs from psm files and execute them ⠸ | 44 | Create PELMO runs from psm files and execute them ⠼ | 45 | Create PELMO runs from psm files and execute them ⠴ | 46 | Create PELMO runs from psm files and execute them ⠦ | 47 | Create PELMO runs from psm files and execute them ⠧ | 48 | Create PELMO runs from psm files and execute them ⠇ | 49 | Create PELMO runs from psm files and execute them ⠏ | 50 | Create PELMO runs from psm files and execute them ⠋ | 51 | Create PELMO runs from psm files and execute them ⠙ | 52 | Create PELMO runs from psm files and execute them ⠹ | 53 | Create PELMO runs from psm files and execute them ⠸ | 54 | Create PELMO runs from psm files and execute them ⠼ | 55 | Create PELMO runs from psm files and execute them ⠴ | 56 | Create PELMO runs from psm files and execute them ⠦ | 57 | Create PELMO runs from psm files and execute them ⠧ | 58 | Create PELMO runs from psm files and execute them ⠇ | 59 | Create PELMO runs from psm files and execute them ⠏ | 60 | Create PELMO runs from psm files and execute them ⠋ | 61 | Create PELMO runs from psm files and execute them ⠙ | 62 | Create PELMO runs from psm files and execute them ⠹ | 63 | Create PELMO runs from psm files and execute them ⠸ | 64 | Create PELMO runs from psm files and execute them ⠼ | 65 | Create PELMO runs from psm files and execute them ⠴ | 66 | Create PELMO runs from psm files and execute them ⠦ | 67 | Create PELMO runs from psm files and execute them ⠧ | 68 | Create PELMO runs from psm files and execute them ⠇ | 69 | Create PELMO runs from psm files and execute them ⠏ | 70 | Create PELMO runs from psm files and execute them ⠋ | 71 | Create PELMO runs from psm files and execute them ⠙ | 72 | Create PELMO runs from psm files and execute them ⠹ | 73 | Create PELMO runs from psm files and execute them ⠸ | 74 | Create PELMO runs from psm files and execute them ⠼ | 75 | Create PELMO runs from psm files and execute them ⠴ | 76 | Create PELMO runs from psm files and execute them ⠦ | 77 | Create PELMO runs from psm files and execute them ⠧ | 78 | Create PELMO runs from psm files and execute them ⠇ | 79 | Create PELMO runs from psm files and execute them ⠏ | 80 | Create PELMO runs from psm files and execute them ⠋ | 81 | Create PELMO runs from psm files and execute them ⠙ | 82 | Create PELMO runs from psm files and execute them ⠹ | 83 | Create PELMO runs from psm files and execute them ⠸ | 84 | Create PELMO runs from psm files and execute them ⠼ | 85 | Create PELMO runs from psm files and execute them ⠴ | 86 | Create PELMO runs from psm files and execute them ⠦ | 87 | Create PELMO runs from psm files and execute them ⠧ | 88 | Create PELMO runs from psm files and execute them ⠇ | 89 | Create PELMO runs from psm files and execute them ⠏ | 90 | Create PELMO runs from psm files and execute them ⠋ | 91 | Create PELMO runs from psm files and execute them ⠙ | 92 | Create PELMO runs from psm files and execute them ⠹ | 93 | Create PELMO runs from psm files and execute them ⠸ | 94 | Create PELMO runs from psm files and execute them ⠼ | 95 | Create PELMO runs from psm files and execute them ⠴ | 96 | Create PELMO runs from psm files and execute them ⠦ | 97 | Create PELMO runs from psm files and execute them ⠧ | 98 | Create PELMO runs from psm files and execute them ⠇ | 99 | Create PELMO runs from psm files and execute them ⠏ | 100 | Create PELMO runs from psm files and execute them ⠋ | 101 | Create PELMO runs from psm files and execute them ⠙ | 102 | Create PELMO runs from psm files and execute them ⠹ | 103 | Create PELMO runs from psm files and execute them ⠸ | 104 | Create PELMO runs from psm files and execute them ⠼ | 105 | Create PELMO runs from psm files and execute them ⠴ | 106 | Create PELMO runs from psm files and execute them ⠦ | 107 | Create PELMO runs from psm files and execute them ⠧ | 108 | Create PELMO runs from psm files and execute them ⠇ | 109 | Create PELMO runs from psm files and execute them ⠏ | 110 | Create PELMO runs from psm files and execute them ⠋ | 111 | Create PELMO runs from psm files and execute them ⠙ | 112 | Create PELMO runs from psm files and execute them ⠹ | 113 | Create PELMO runs from psm files and execute them ⠸ | 114 | Create PELMO runs from psm files and execute them ⠼ | 115 | Create PELMO runs from psm files and execute them ⠴ | 116 | Create PELMO runs from psm files and execute them ⠦ | 117 | Create PELMO runs from psm files and execute them ⠧ | 118 | Create PELMO runs from psm files and execute them ⠇ | 119 | Create PELMO runs from psm files and execute them ⠏ | 120 | Create PELMO runs from psm files and execute them ⠋ | 121 | Create PELMO runs from psm files and execute them ⠙ | 122 | Create PELMO runs from psm files and execute them ⠹ | 123 | Create PELMO runs from psm files and execute them ⠸ | 124 | Create PELMO runs from psm files and execute them ⠼ | 125 | Create PELMO runs from psm files and execute them ⠴ | 126 | Create PELMO runs from psm files and execute them ⠦ | 127 | Create PELMO runs from psm files and execute them ⠧ | 128 | Create PELMO runs from psm files and execute them ⠇ | 129 | Create PELMO runs from psm files and execute them ⠏ | 130 | Create PELMO runs from psm files and execute them ⠋ | 131 | Create PELMO runs from psm files and execute them ⠙ | 132 | Create PELMO runs from psm files and execute them ⠹ | 133 | Create PELMO runs from psm files and execute them ⠸ | 134 | Create PELMO runs from psm files and execute them ⠼ | 135 | Create PELMO runs from psm files and execute them ⠴ | 136 | Create PELMO runs from psm files and execute them ⠦ | 137 | Create PELMO runs from psm files and execute them ⠧ | 138 | Create PELMO runs from psm files and execute them ⠇ | 139 | Create PELMO runs from psm files and execute them ⠏ | 140 | Create PELMO runs from psm files and execute them ⠋ | 141 | Create PELMO runs from psm files and execute them ⠙ | 142 | Create PELMO runs from psm files and execute them ⠹ | 143 | Create PELMO runs from psm files and execute them ⠸ | 144 | Create PELMO runs from psm files and execute them ⠼ | 145 | Create PELMO runs from psm files and execute them ⠴ | 146 | Create PELMO runs from psm files and execute them ⠦ | 147 | Create PELMO runs from psm files and execute them ⠧ | 148 | Create PELMO runs from psm files and execute them ⠇ | 149 | Create PELMO runs from psm files and execute them ⠏ | 150 | Create PELMO runs from psm files and execute them ⠋ | 151 | Create PELMO runs from psm files and execute them ⠙ | 152 | Create PELMO runs from psm files and execute them ⠹ | 153 | Create PELMO runs from psm files and execute them ⠸ | 154 | Create PELMO runs from psm files and execute them ⠼ | 155 | Create PELMO runs from psm files and execute them ⠴ | 156 | Create PELMO runs from psm files and execute them ⠦ | 157 | Create PELMO runs from psm files and execute them ⠧ | 158 | Create PELMO runs from psm files and execute them ⠇ | 159 | Create PELMO runs from psm files and execute them ⠏ | 160 | Create PELMO runs from psm files and execute them ⠋ | 161 | Create PELMO runs from psm files and execute them ⠙ | 162 | Create PELMO runs from psm files and execute them ⠹ | 163 | Create PELMO runs from psm files and execute them ⠸ | 164 | Create PELMO runs from psm files and execute them ⠼ | 165 | Create PELMO runs from psm files and execute them ⠴ | 166 | Create PELMO runs from psm files and execute them ⠦ | 167 | Create PELMO runs from psm files and execute them ⠧ | 168 | Create PELMO runs from psm files and execute them ⠇ | 169 | Create PELMO runs from psm files and execute them ⠏ | 170 | Create PELMO runs from psm files and execute them ⠋ | 171 | Create PELMO runs from psm files and execute them ⠙ | 172 | Create PELMO runs from psm files and execute them ⠹ | 173 | Create PELMO runs from psm files and execute them ⠸ | 174 | Create PELMO runs from psm files and execute them ⠼ | 175 | Create PELMO runs from psm files and execute them ⠴ | 176 | Create PELMO runs from psm files and execute them ⠦ | 177 | Create PELMO runs from psm files and execute them ⠧ | 178 | Create PELMO runs from psm files and execute them ⠇ | 179 | Create PELMO runs from psm files and execute them ⠏ | 180 | Create PELMO runs from psm files and execute them ⠋ | 181 | Create PELMO runs from psm files and execute them ⠙ | 182 | Create PELMO runs from psm files and execute them ⠹ | 183 | Create PELMO runs from psm files and execute them ⠸ | 184 | Create PELMO runs from psm files and execute them ⠼ | 185 | Create PELMO runs from psm files and execute them ⠴ | 186 | Create PELMO runs from psm files and execute them ⠦ | 187 | Create PELMO runs from psm files and execute them ⠧ | 188 | Create PELMO runs from psm files and execute them ⠇ | 189 | Create PELMO runs from psm files and execute them ⠏ | 190 | Create PELMO runs from psm files and execute them ⠋ | 191 | Create PELMO runs from psm files and execute them ⠙ | 192 | Create PELMO runs from psm files and execute them ⠹ | 193 | Create PELMO runs from psm files and execute them ⠸ | 194 | Create PELMO runs from psm files and execute them ⠼ | 195 | Create PELMO runs from psm files and execute them ⠴ | 196 | Create PELMO runs from psm files and execute them ⠦ | 197 | Create PELMO runs from psm files and execute them ⠧ | 198 | Create PELMO runs from psm files and execute them ⠇ | 199 | Create PELMO runs from psm files and execute them ⠏ | 200 | Create PELMO runs from psm files and execute them ⠋ | 201 | Create PELMO runs from psm files and execute them ⠙ | 202 | Create PELMO runs from psm files and execute them ⠹ | 203 | Create PELMO runs from psm files and execute them ⠸ | 204 | Create PELMO runs from psm files and execute them ⠼ | 205 | Create PELMO runs from psm files and execute them ⠴ | 206 | Create PELMO runs from psm files and execute them ⠦ | 207 | Create PELMO runs from psm files and execute them ⠧ | 208 | Create PELMO runs from psm files and execute them ⠇ | 209 | Create PELMO runs from psm files and execute them ⠏ | 210 | Create PELMO runs from psm files and execute them ⠋ | 211 | Create PELMO runs from psm files and execute them ⠙ | 212 | Create PELMO runs from psm files and execute them ⠹ | 213 | Create PELMO runs from psm files and execute them ⠸ | 214 | Create PELMO runs from psm files and execute them ⠼ | 215 | Create PELMO runs from psm files and execute them ⠴ | 216 | Create PELMO runs from psm files and execute them ⠦ | 217 | Create PELMO runs from psm files and execute them ⠧ | 218 | Create PELMO runs from psm files and execute them ⠇ | 219 | Create PELMO runs from psm files and execute them ✔ | 219 | Create PELMO runs from psm files and execute them [73.9 s]
+ ⠏ | 0 | Actual and time weighted average concentrations for SFO kinetics ⠋ | 1 | Actual and time weighted average concentrations for SFO kinetics ✔ | 1 | Actual and time weighted average concentrations for SFO kinetics
+ ⠏ | 0 | FOCUS Step 1 calculations ⠋ | 1 | FOCUS Step 1 calculations ⠙ | 2 | FOCUS Step 1 calculations ⠹ | 3 | FOCUS Step 1 calculations ⠸ | 4 | FOCUS Step 1 calculations ⠼ | 5 | FOCUS Step 1 calculations ⠴ | 6 | FOCUS Step 1 calculations ⠦ | 7 | FOCUS Step 1 calculations ⠧ | 8 | FOCUS Step 1 calculations ⠇ | 9 | FOCUS Step 1 calculations ✔ | 9 | FOCUS Step 1 calculations [0.1 s]
+ ⠏ | 0 | FOCUS Steps 12 input files ⠋ | 1 | FOCUS Steps 12 input files ⠙ | 2 | FOCUS Steps 12 input files ⠹ | 3 | FOCUS Steps 12 input files ⠸ | 4 | FOCUS Steps 12 input files ⠼ | 5 | FOCUS Steps 12 input files ⠴ | 6 | FOCUS Steps 12 input files ⠦ | 7 | FOCUS Steps 12 input files ⠧ | 8 | FOCUS Steps 12 input files ✔ | 8 | FOCUS Steps 12 input files
+ ⠏ | 0 | Read and analyse TOXSWA cwa files ⠋ | 1 | Read and analyse TOXSWA cwa files ⠙ | 2 | Read and analyse TOXSWA cwa files ⠹ | 3 | Read and analyse TOXSWA cwa files ⠸ | 4 | Read and analyse TOXSWA cwa files ⠼ | 5 | Read and analyse TOXSWA cwa files ⠴ | 6 | Read and analyse TOXSWA cwa files ⠦ | 7 | Read and analyse TOXSWA cwa files ✔ | 7 | Read and analyse TOXSWA cwa files [3.6 s]
+ ⠏ | 0 | UK drainage PEC calculations ⠋ | 1 | UK drainage PEC calculations ⠙ | 2 | UK drainage PEC calculations ⠹ | 3 | UK drainage PEC calculations ⠸ | 4 | UK drainage PEC calculations ⠼ | 5 | UK drainage PEC calculations ⠴ | 6 | UK drainage PEC calculations ⠦ | 7 | UK drainage PEC calculations ⠧ | 8 | UK drainage PEC calculations ⠇ | 9 | UK drainage PEC calculations ⠏ | 10 | UK drainage PEC calculations ⠋ | 11 | UK drainage PEC calculations ⠙ | 12 | UK drainage PEC calculations ✔ | 12 | UK drainage PEC calculations
-DONE ===============================================================================================
+══ Results ═════════════════════════════════════════════════════════════════════════════════════════
+Duration: 78.9 s
+
+OK: 282
+Failed: 0
+Warnings: 0
+Skipped: 0
diff --git a/tests/testthat/test_PEC_soil.R b/tests/testthat/test_PEC_soil.R
index 0661a52..34b4749 100644
--- a/tests/testthat/test_PEC_soil.R
+++ b/tests/testthat/test_PEC_soil.R
@@ -1,4 +1,5 @@
library(pfm)
+library(testthat)
context("Simple PEC soil calculations")
test_that("PEC_soil calculates correctly", {
@@ -6,40 +7,73 @@ test_that("PEC_soil calculates correctly", {
expect_equal(as.numeric(PEC_soil(100)), 0.1 * 4/3)
# or 0.1 mg/kg assuming 25% interception
- expect_equal(as.numeric(PEC_soil(100, interception = 0.25)), 0.1)
+ expect_equal(as.numeric(PEC_soil(100, interception = 0.25)), 0.1)
# Mixing depth of 1 cm gives five-fold PEC
expect_equal(as.numeric(PEC_soil(100, interception = 0.25, mixing_depth = 1)), 0.5)
})
-test_that("Tier 1 PEC soil example for Pesticide A in EFSA guidance can be reproduced", {
+test_that("Tier 1 PEC soil example for Pesticide A in EFSA guidance from 2017 can be reproduced", {
# Calculate total soil concentrations for tier 1 scenarios
- results_pfm <- PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
- scenarios = "EFSA_2015")
+ # Leaching is calculated from the 5 cm layer to be able to reproduce the
+ # results from the guidance
+ results_pfm_2017 <- PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+ scenarios = "EFSA_2017", Kom = 1000,
+ leaching_depth = 5)
+
+ # From Table G.2, p. 92
+ results_guidance_2017 <- matrix(c(18.6, 13.0, 9.9, 18.2, 12.7, 9.6),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance_2017) <- list(t_avg = c(0, 21),
+ scenario = c("CTN", "CTC", "CTS"))
+
+
+ expect_equal(round(results_pfm_2017, 1)[1, ], results_guidance_2017[1, ])
+ # I do not get the same TWA concentrations as in the 2017 guidance on p. 92
+
+ # Calculate porewater soil concentrations for tier 1 scenarios
+ results_pfm_pw_2017 <- PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2017", porewater = TRUE,
+ leaching_depth = 5)
# From Table I.5, p. 80
- results_guidance <- matrix(c(22.0, 11.5, 9.1, 21.8, 11.4, 9.0),
- ncol = 3, byrow = TRUE)
- dimnames(results_guidance) <- list(t_avg = c(0, 21),
- scenario = c("CTN", "CTC", "CTS"))
+ results_guidance_pw_2017 <- matrix(c(0.48, 0.60, 0.91, 0.47, 0.58, 0.86),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance_pw_2017) <- list(t_avg = c(0, 21),
+ scenario = c("CLN", "CLC", "CLS"))
+ expect_equal(round(results_pfm_pw_2017, 2)[1, ], results_guidance_pw_2017[1, ])
+ # Here I also do not get the same TWA concentrations as in the guidance p. 92
+})
+
+test_that("Tier 1 PEC soil example for Pesticide A in EFSA guidance from 2015 can be reproduced", {
+ # Calculate total soil concentrations for tier 1 scenarios
+ results_pfm_2015 <- PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+ scenarios = "EFSA_2015")
+
+ # From Table I.5, p. 80
+ results_guidance_2015 <- matrix(c(22.0, 11.5, 9.1, 21.8, 11.4, 9.0),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance_2015) <- list(t_avg = c(0, 21),
+ scenario = c("CTN", "CTC", "CTS"))
- expect_equal(round(results_pfm, 1), results_guidance)
+
+ expect_equal(round(results_pfm_2015, 1), results_guidance_2015)
# Calculate porewater soil concentrations for tier 1 scenarios
- results_pfm_pw <- PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
- Kom = 1000, scenarios = "EFSA_2015", porewater = TRUE)
+ results_pfm_pw_2015 <- PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2015", porewater = TRUE)
# From Table I.5, p. 80
- results_guidance_pw <- matrix(c(0.76, 0.67, 0.91, 0.75, 0.66, 0.90),
- ncol = 3, byrow = TRUE)
- dimnames(results_guidance_pw) <- list(t_avg = c(0, 21),
- scenario = c("CLN", "CLC", "CLS"))
+ results_guidance_pw_2015 <- matrix(c(0.76, 0.67, 0.91, 0.75, 0.66, 0.90),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance_pw_2015) <- list(t_avg = c(0, 21),
+ scenario = c("CLN", "CLC", "CLS"))
- expect_equal(round(results_pfm_pw, 2), results_guidance_pw)
+ expect_equal(round(results_pfm_pw_2015, 2), results_guidance_pw_2015)
})
-test_that("Tier 1 PEC soil example for Pesticide F in EFSA guidance can be reproduced", {
+test_that("Tier 1 PEC soil example for Pesticide F in EFSA guidance from 2015 can be reproduced", {
# Parent F
# Calculate total and porewater soil concentrations for tier 1 scenarios
results_pfm <- PEC_soil(1000, interval = 365, DT50 = 25, t_avg = c(0, 21),
diff --git a/tests/testthat/test_PELMO.R b/tests/testthat/test_PELMO.R
index be0b410..49c03d3 100644
--- a/tests/testthat/test_PELMO.R
+++ b/tests/testthat/test_PELMO.R
@@ -45,6 +45,7 @@ test_that("PELMO runs are correctly set up", {
}
# Prepare runs in analogy to the test archive
+ skip_on_cran()
PELMO_runs(runs, psm_dir = PELMO_base, execute = FALSE, evaluate = FALSE, overwrite = TRUE)
# Check that input files are correctly generated in the right location
@@ -70,6 +71,7 @@ test_that("PELMO runs can be run and give the expected result files", {
skip("A wine installation is needed for this test")
}
+ skip_on_cran()
run_PELMO(runs, cores = 7)
plm_files <- c("CHEM.PLM", "ECHO.PLM",
@@ -89,8 +91,12 @@ test_that("PELMO runs can be run and give the expected result files", {
new <- readLines(file.path(PELMO_base, "FOCUS", pp, plm))
test <- readLines(file.path(test_dir, pp, plm))
+ # Don't check for differences in the PESTICIDE BALANCE ERROR
+ pest_balance_error <- suppressWarnings(grep("PESTICIDE BALANCE ERROR", new))
+ # Suppress warnings about invalid strings in this locale caused by the files
+
# Check if the ouput files are correctly reproduced
- expect_identical(new, test)
+ expect_identical(new[!pest_balance_error], test[!pest_balance_error])
}
}
}
@@ -105,6 +111,7 @@ test_that("PELMO runs are correctly evaluated", {
skip("A wine installation is needed for this test")
}
+ skip_on_cran()
# Check that if output is the same as in the test archive
for (run in runs) {
psm <- run$psm
@@ -164,6 +171,7 @@ test_that("PECgw from FOCUS summary files can be reproduced", {
if (!wine_installed) {
skip("A wine installation is needed for this test")
}
+ skip_on_cran()
focus_summary <- list()
for (run in runs) {
diff --git a/tests/testthat/test_TOXSWA.R b/tests/testthat/test_TOXSWA.R
index 7c9a73c..de60d48 100644
--- a/tests/testthat/test_TOXSWA.R
+++ b/tests/testthat/test_TOXSWA.R
@@ -1,26 +1,23 @@
library(pfm)
context("Read and analyse TOXSWA cwa files")
-zipfile_test = system.file("testdata/SwashProjects.zip", package = "pfm")
-basedir_test = "SwashProjects/project_H_sw/TOXSWA"
-
-H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa",
- basedir = basedir_test,
- zipfile = zipfile_test)
-
-H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa",
- basedir = basedir_test,
- zipfile = zipfile_test)
+# zipfile_test = tempfile()
+# download.file("https://cgit.jrwb.de/pfm/plain/inst/testdata/SwashProjects.zip", zipfile_test)
+zipfile_test <- system.file("testdata/SwashProjects.zip", package = "pfm")
+basedir_test = "SwashProjects/project_H_sw/TOXSWA" # cwa files from TOXSWA 3.x
+# .out file produced with TOXSWA 4.4.2
basedir_test_2 = "SwashProjects/Project_1/TOXSWA"
-EXSW2_R1_stream <- read.TOXSWA_cwa("3.out",
- basedir = basedir_test_2,
- zipfile = zipfile_test)
-
+H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa",
+ basedir = basedir_test,
+ zipfile = zipfile_test)
+H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa",
+ basedir = basedir_test,
+ zipfile = zipfile_test)
-test_that("TOXSWA cwa file is correctly read and printed", {
+test_that("Old TOXSWA cwa and out files are correctly read and printed", {
# This was the setting when printing the output into text files
options(width = 100)
@@ -37,15 +34,31 @@ test_that("TOXSWA cwa file is correctly read and printed", {
# The basedir is not printed, therefore tested separately
expect_equal(H_sw_D4_pond$basedir, basedir_test)
+
+ EXSW2_R1_stream <- read.TOXSWA_cwa("3.out",
+ basedir = basedir_test_2,
+ zipfile = zipfile_test)
EXSW2_R1_stream_printed <- capture.output(print(EXSW2_R1_stream))
expect_equal(EXSW2_R1_stream_printed, readLines("EXSW2_R1_stream_printed.txt"))
+})
- # The basedir is not printed, therefore tested separately
- expect_equal(H_sw_D4_pond$basedir, basedir_test)
+test_that("A TOXSWA 5.5.3 out file is correctly read and printed", {
+ # zipfile_test_3 = tempfile()
+ # download.file("https://cgit.jrwb.de/pfm/plain/inst/testdata/SwashProjects_TOXSWA_553.zip",
+ # zipfile_test_3)
+ zipfile_test_3 <- system.file("testdata/SwashProjects_TOXSWA_553.zip", package = "pfm")
+ basedir_test_3 = "SwashProjects/Project_1/TOXSWA"
+
+ EXSW2_R1_stream_TOXSWA_553 <- read.TOXSWA_cwa("3.out",
+ basedir = basedir_test_3,
+ zipfile = zipfile_test_3)
+ EXSW2_R1_stream_printed_TOXSWA_553 <- capture.output(print(EXSW2_R1_stream_TOXSWA_553))
+
+ # We actually get the same results, at least judged by the printed object
+ expect_equal(EXSW2_R1_stream_printed_TOXSWA_553, readLines("EXSW2_R1_stream_printed.txt"))
})
test_that("Getting events and moving window analysis works", {
-
# Event analysis with two different thresholds
H_sw_R1_stream$get_events(c(2, 10))
expect_equal_to_reference(H_sw_R1_stream$events, file = "H_sw_R1_stream_events.rds")

Contact - Imprint