From ea9b75183bcf41fcdd6f61ec6060e94c4bc321a2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 11 Jun 2015 12:13:47 +0200 Subject: Add simple drift PEC ini calculations These are tested for field crops with the CRD spreadsheet --- README.md | 43 +++++++++++++++++++------- README.rmd | 7 +++++ pkg/NAMESPACE | 1 + pkg/R/PEC_sw_drift.R | 55 ++++++++++++++++++++++++++++++++++ pkg/man/PEC_sw_drift.Rd | 42 ++++++++++++++++++++++++++ pkg/tests/testthat/test_PEC_sw_drift.R | 14 +++++++++ 6 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 pkg/R/PEC_sw_drift.R create mode 100644 pkg/man/PEC_sw_drift.Rd create mode 100644 pkg/tests/testthat/test_PEC_sw_drift.R diff --git a/README.md b/README.md index 1f70a86..1e9c805 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,13 @@ Read in and analyse a cwa file: ```r library(pfm) +``` + +``` +## Loading required package: R6 +``` + +```r example_cwa <- read.TOXSWA_cwa("00003s_pa.cwa") plot(example_cwa) ``` @@ -105,16 +112,30 @@ drift_data_JKI[1] ``` ## [[1]] -## crop -## distance Ackerbau Obstbau früh Obstbau spät -## 1.000000 2.77 NA NA -## 3.000000 NA 29.20 15.73 -## 5.000000 0.57 19.89 8.41 -## 10.000000 0.29 11.81 3.60 -## 15.000000 0.20 5.55 1.81 -## 20.000000 0.15 2.77 1.09 -## 30.000000 0.10 1.04 0.54 -## 40.000000 0.07 0.52 0.32 -## 50.000000 0.06 0.30 0.22 +## crop +## distance Ackerbau Obstbau früh Obstbau spät +## 1 2.77 NA NA +## 3 NA 29.20 15.73 +## 5 0.57 19.89 8.41 +## 10 0.29 11.81 3.60 +## 15 0.20 5.55 1.81 +## 20 0.15 2.77 1.09 +## 30 0.10 1.04 0.54 +## 40 0.07 0.52 0.32 +## 50 0.06 0.30 0.22 +``` + +### PEC surface water due to drift + +Initial PEC values for an application of 100 g/ha in the vicinity of a 30 cm +deep water body are obtained using + + +```r +PEC_sw_drift(100, applications = 1) ``` +``` +## 1 m 5 m 10 m 20 m +## 0.92333333 0.19000000 0.09666667 0.05000000 +``` diff --git a/README.rmd b/README.rmd index c4c514e..ade1445 100644 --- a/README.rmd +++ b/README.rmd @@ -67,4 +67,11 @@ see the data for one application: drift_data_JKI[1] ``` +### PEC surface water due to drift +Initial PEC values for an application of 100 g/ha in the vicinity of a 30 cm +deep water body are obtained using + +```{r} +PEC_sw_drift(100, applications = 1) +``` diff --git a/pkg/NAMESPACE b/pkg/NAMESPACE index 86b85da..00b0022 100644 --- a/pkg/NAMESPACE +++ b/pkg/NAMESPACE @@ -2,6 +2,7 @@ S3method(plot,TOXSWA_cwa) export(PEC_soil) +export(PEC_sw_drift) export(TOXSWA_cwa) export(geomean) export(read.TOXSWA_cwa) diff --git a/pkg/R/PEC_sw_drift.R b/pkg/R/PEC_sw_drift.R new file mode 100644 index 0000000..ce57f79 --- /dev/null +++ b/pkg/R/PEC_sw_drift.R @@ -0,0 +1,55 @@ +# Copyright (C) 2015 Johannes Ranke +# Contact: jranke@uni-bremen.de +# This file is part of the R package pfm + +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see + +#' Calculate predicted environmental concentrations in surface water due to drift +#' +#' This is a basic, vectorised form of a simple calculation of a contaminant +#' concentration in surface water based on complete, instantaneous mixing +#' with input via spray drift. +#' +#' @param rate Application rate in units specified below +#' @param applications Number of applications for selection of drift percentile +#' @param drift_data Source of drift percentage data +#' @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 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 +#' @return The predicted concentration in surface water +#' @export +#' @author Johannes Ranke +#' @examples +#' PEC_sw_drift(100) +PEC_sw_drift <- function(rate, + applications = 1, + water_depth = 30, + drift_data = "JKI", + crop = "Ackerbau", + distances = c(1, 5, 10, 20), + rate_units = "g/ha", + PEC_units = "\u00B5g/L") +{ + rate_units <- match.arg(rate_units) + PEC_units <- match.arg(PEC_units) + drift_data <- match.arg(drift_data) + 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) + PEC_sw_drift <- PEC_sw_overspray * pfm::drift_data_JKI[[applications]][dist_index, crop] / 100 + names(PEC_sw_drift) <- paste(dist_index, "m") + return(PEC_sw_drift) +} diff --git a/pkg/man/PEC_sw_drift.Rd b/pkg/man/PEC_sw_drift.Rd new file mode 100644 index 0000000..20299a5 --- /dev/null +++ b/pkg/man/PEC_sw_drift.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Please edit documentation in R/PEC_sw_drift.R +\name{PEC_sw_drift} +\alias{PEC_sw_drift} +\title{Calculate predicted environmental concentrations in surface water due to drift} +\usage{ +PEC_sw_drift(rate, applications = 1, water_depth = 30, drift_data = "JKI", + crop = "Ackerbau", distances = c(1, 5, 10, 20), rate_units = "g/ha", + PEC_units = "µg/L") +} +\arguments{ +\item{rate}{Application rate in units specified below} + +\item{applications}{Number of applications for selection of drift percentile} + +\item{water_depth}{Depth of the water body in cm} + +\item{drift_data}{Source of drift percentage data} + +\item{crop}{Crop name (use German names for JKI data), defaults to "Ackerbau"} + +\item{distances}{The distances in m for which to get PEC values} + +\item{rate_units}{Defaults to g/ha} + +\item{PEC_units}{Requested units for the calculated PEC. Only µg/L currently supported} +} +\value{ +The predicted concentration in surface water +} +\description{ +This is a basic, vectorised form of a simple calculation of a contaminant +concentration in surface water based on complete, instantaneous mixing +with input via spray drift. +} +\examples{ +PEC_sw_drift(100) +} +\author{ +Johannes Ranke +} + diff --git a/pkg/tests/testthat/test_PEC_sw_drift.R b/pkg/tests/testthat/test_PEC_sw_drift.R new file mode 100644 index 0000000..390df34 --- /dev/null +++ b/pkg/tests/testthat/test_PEC_sw_drift.R @@ -0,0 +1,14 @@ +library(pfm) +context("Simple PEC surface water calculations with drift entry") + +test_that("PEC_sw_drift gives the same results as the CRD PEC calculator", { + # One application of 30 g/ha to field crops calculated with UK PEC calculator published by CRD + expect_equal(round(PEC_sw_drift(30), 3), c('1 m' = 0.277, '5 m' = 0.057, '10 m' = 0.029, '20 m' = 0.015)) + + # 7 applications of 30 g/ha to field crops calculated with UK PEC calculator, initial PEC + expect_equal(round(PEC_sw_drift(30, 7), 3), c('1 m' = 0.161, '5 m' = 0.033, '10 m' = 0.017, '20 m' = 0.008)) + + # 4 applications of 30 g/ha to late fruit crops calculated with UK PEC calculator published by CRD (uses different drift values from SANCO aquatic guidance) + #expect_equal(round(PEC_sw_drift(30, 4, crop = "Obstbau spät", distances = c(3, 20, 50)), 3), c('3 m' = 1.101, '20 m' = 0.080, '50 m' = 0.013)) +}) + -- cgit v1.2.1