From 36036b5901223591e7e21e8b73d8cd1fb034f4cb Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 16 May 2017 15:43:50 +0200 Subject: Finish the Step 1 calculator including tests Some cleaning up. PELMO facilities do not currently work at my end, as I have no working wine installation on this computer --- .Rbuildignore | 1 + ChangeLog | 18 ++ DESCRIPTION | 8 +- GNUmakefile | 8 +- NAMESPACE | 3 + R/FOCUS_GW_scenarios_2012.R | 2 +- R/FOCUS_Step_12_scenarios.R | 3 + R/PEC_sw_focus.R | 122 +++++++-- R/PELMO_runs.R | 13 +- _pkgdown.yml | 1 + docs/authors.html | 4 +- docs/index.html | 10 +- docs/pkgdown.css | 91 +++++-- docs/reference/FOCUS_GW_scenarios_2012.html | 14 +- docs/reference/FOCUS_PELMO_crop_sze_names.html | 14 +- docs/reference/FOCUS_PELMO_crops.html | 26 +- docs/reference/FOCUS_PELMO_location_codes.html | 8 +- docs/reference/FOCUS_Step_12_scenarios.html | 285 ++++++++++++++++++++++ docs/reference/GUS.html | 97 +++++--- docs/reference/PEC_soil.html | 133 ++++++---- docs/reference/PEC_sw_drainage_UK.html | 55 +++-- docs/reference/PEC_sw_drift.html | 67 +++-- docs/reference/PEC_sw_focus.html | 272 +++++++++++++++++++++ docs/reference/PEC_sw_sed.html | 63 +++-- docs/reference/PELMO_path.html | 29 ++- docs/reference/PELMO_runs.html | 143 +++++------ docs/reference/SFO_actual_twa.html | 23 +- docs/reference/SSLRC_mobility_classification.html | 19 +- docs/reference/TOXSWA_cwa.html | 44 ++-- docs/reference/chent_focus_sw.html | 142 +++++++++++ docs/reference/create_run_list.html | 31 ++- docs/reference/drift_data_JKI.html | 44 ++-- docs/reference/endpoint.html | 83 ++++--- docs/reference/evaluate_PELMO.html | 116 --------- docs/reference/focus_80th.html | 23 +- docs/reference/geomean.html | 23 +- docs/reference/get_flux.html | 18 +- docs/reference/get_interval.html | 22 +- docs/reference/index.html | 266 ++++++++++++-------- docs/reference/max_twa.html | 23 +- docs/reference/one_box-12.png | Bin 9901 -> 0 bytes docs/reference/one_box-6.png | Bin 5743 -> 0 bytes docs/reference/one_box.html | 53 ++-- docs/reference/pfm_degradation.html | 51 ++-- docs/reference/plot.TOXSWA_cwa.html | 57 +++-- docs/reference/plot.one_box.html | 63 +++-- docs/reference/read.TOXSWA_cwa.html | 71 ++++-- docs/reference/run_PELMO.html | 119 --------- docs/reference/sawtooth-8.png | Bin 13603 -> 0 bytes docs/reference/sawtooth.html | 39 +-- docs/reference/soil_scenario_data_EFSA_2015.html | 40 +-- docs/reference/sum_periods.html | 22 +- docs/reference/twa.html | 23 +- inst/extdata/FOCUS_Step_12_scenarios.txt | 48 ++++ man/FOCUS_GW_scenarios_2012.Rd | 2 +- man/FOCUS_Step_12_scenarios.Rd | 40 +++ man/PEC_sw_focus.Rd | 53 +++- man/PELMO_runs.Rd | 5 +- man/chent_focus_sw.Rd | 14 +- man/get_flux.Rd | 3 + man/get_interval.Rd | 5 + man/sum_periods.Rd | 5 + tests/testthat/test_PELMO.R | 7 +- tests/testthat/test_step_1.R | 97 ++++++-- 64 files changed, 2208 insertions(+), 976 deletions(-) create mode 100644 docs/reference/FOCUS_Step_12_scenarios.html create mode 100644 docs/reference/PEC_sw_focus.html create mode 100644 docs/reference/chent_focus_sw.html delete mode 100644 docs/reference/evaluate_PELMO.html delete mode 100644 docs/reference/one_box-12.png delete mode 100644 docs/reference/one_box-6.png delete mode 100644 docs/reference/run_PELMO.html delete mode 100644 docs/reference/sawtooth-8.png create mode 100755 inst/extdata/FOCUS_Step_12_scenarios.txt create mode 100644 man/FOCUS_Step_12_scenarios.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 005f437..01a3edc 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,5 +8,6 @@ ^build.log$ ^test.log$ ^inst/extdata/Tabelle\ der\ Abdrifteckwerte.xls$ +^inst/extdata/FOCUS_Step_12_scenarios.txt$ ^_pkgdown.yml$ ^docs$ diff --git a/ChangeLog b/ChangeLog index 227c446..b1eddf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +commit d042f8f06b313e8595087587455daac73d84f17b +Author: Johannes Ranke +Date: 2017-05-15 20:01:28 +0200 + + Start of an Steps 1/2 calculator in R + +commit b052bf8d1e090e07bf0853f0aa8b895db8f41a2a +Author: Johannes Ranke +Date: 2017-03-29 19:24:37 +0200 + + Make it possible to use expressions in axis labels + +commit d69fda8d8f854b735394ecdaec9d59fb18c42b00 +Author: Johannes Ranke +Date: 2017-03-28 10:09:45 +0200 + + Update Changelog + commit 90e5ff0a9fdadd65e179c04c7d43b4db6e301984 Author: Johannes Ranke Date: 2017-03-06 17:59:16 +0100 diff --git a/DESCRIPTION b/DESCRIPTION index e61f81a..8acf123 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,13 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling -Version: 0.4-2 -Date: 2017-01-30 +Version: 0.4-3 +Date: 2017-05-16 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) Description: Utilities for simple calculations of predicted environmental concentrations (PECs) and for dealing with data from some FOCUS pesticide - fate modelling software packages (currently only TOXSWA). + fate modelling software packages. Depends: R6, mkin @@ -25,4 +25,4 @@ License: GPL LazyLoad: yes LazyData: yes Encoding: UTF-8 -RoxygenNote: 5.0.1.9000 +RoxygenNote: 6.0.1 diff --git a/GNUmakefile b/GNUmakefile index 1a913ab..959c68f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -9,11 +9,13 @@ DATE := $(shell date +%Y-%m-%d) pkgfiles = DESCRIPTION \ .Rbuildignore \ - inst/testdata/* \ + data/* \ docs/* \ docs/reference/* \ - data/* \ - R/* + inst/testdata/* \ + R/* \ + tests/testthat.R \ + tests/testthat/* clean: @echo "Cleaning up..." diff --git a/NAMESPACE b/NAMESPACE index feb5ca7..7a5c668 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,12 +19,14 @@ export(GUS) export(PEC_soil) export(PEC_sw_drainage_UK) export(PEC_sw_drift) +export(PEC_sw_focus) export(PEC_sw_sed) export(PELMO_path) export(PELMO_runs) export(SFO_actual_twa) export(SSLRC_mobility_classification) export(TOXSWA_cwa) +export(chent_focus_sw) export(endpoint) export(evaluate_PELMO) export(focus_80th) @@ -56,3 +58,4 @@ importFrom(stats,start) importFrom(stats,time) importFrom(stats,ts) importFrom(utils,data) +importFrom(utils,read.table) diff --git a/R/FOCUS_GW_scenarios_2012.R b/R/FOCUS_GW_scenarios_2012.R index e26ea50..33c5293 100644 --- a/R/FOCUS_GW_scenarios_2012.R +++ b/R/FOCUS_GW_scenarios_2012.R @@ -1,4 +1,4 @@ -#' A very small subset of the FOCUS Groundwater scenario defitions +#' A very small subset of the FOCUS Groundwater scenario definitions #' #' Currently, only scenario names with acronyms and a small subset of the soil definitions are provided. The #' soil definitions are from page 46ff. from FOCUS (2012). diff --git a/R/FOCUS_Step_12_scenarios.R b/R/FOCUS_Step_12_scenarios.R index cb0654a..f28f03d 100644 --- a/R/FOCUS_Step_12_scenarios.R +++ b/R/FOCUS_Step_12_scenarios.R @@ -1,3 +1,6 @@ +# Register global variables +if(getRversion() >= '2.15.1') utils::globalVariables("FOCUS_Step_12_scenarios") + #' Step 1/2 scenario data as distributed with the FOCUS Step 1/2 calculator #' #' The data were extracted from the scenario.txt file using the R code shown below. diff --git a/R/PEC_sw_focus.R b/R/PEC_sw_focus.R index 5f3b3d2..21ed514 100644 --- a/R/PEC_sw_focus.R +++ b/R/PEC_sw_focus.R @@ -1,37 +1,75 @@ #' Calculate FOCUS Step 1 PEC surface water #' -#' This is an attempt to reimplement the FOCUS Step 1 and 2 calculator authored -#' by Michael Klein. The Step 1 and 2 scenario assumes an area ratio of 10:1 -#' between field and waterbody, and a water depth of 30 cm. -#' I did not (yet) implement the TWA formulas for times later than day 1, as I -#' did not understand them right away. -#' Also, Step 2 is not implemented (yet). +#' This is reimplementation of Step 1 of the FOCUS Step 1 and 2 calculator +#' version 3.2, authored by Michael Klein. Note that results for multiple +#' applications should be compared to the corresponding results for a +#' single application. At current, this is not done automatically in +#' this implementation. #' +#' @importFrom utils read.table +#' @references FOCUS (2014) Generic guidance for Surface Water Scenarios (version 1.4). +#' FOrum for the Co-ordination of pesticde fate models and their USe. +#' http://esdac.jrc.ec.europa.eu/public_path/projects_data/focus/sw/docs/Generic%20FOCUS_SWS_vc1.4.pdf +#' @references Website of the Steps 1 and 2 calculator at the Joint Research +#' Center of the European Union: +#' http://esdac.jrc.ec.europa.eu/projects/stepsonetwo +#' @note The formulas for input to the waterbody via runoff/drainage of the +#' parent and subsequent formation of the metabolite in water is not +#' documented in the model description coming with the calculator +#' @note Step 2 is not implemented #' @export #' @param parent A list containing substance specific parameters #' @param rate The application rate in g/ha. Overriden when #' applications are given explicitly #' @param n The number of applications #' @param i The application interval -#' @param applications A dataframe containing times and amounts of each application -#' @param step At the moment, only Step 1 is implemented +#' @param met A list containing metabolite specific parameters. If not NULL, +#' the PEC is calculated for this compound, not the parent. +#' @param f_drift The fraction of the application rate reaching the waterbody +#' via drift. If NA, this is derived from the scenario name and the number +#' of applications via the drift data defined by the +#' \code{\link{FOCUS_Step_12_scenarios}} +#' @param f_rd The fraction of the amount applied reaching the waterbody via +#' runoff/drainage. At Step 1, it is assumed to be 10%, be it the +#' parent or a metabolite +#' @param scenario The name of the scenario. Must be one of the scenario +#' names given in \code{\link{FOCUS_Step_12_scenarios}} #' @examples +#' # Parent only #' dummy_1 <- chent_focus_sw(cwsat = 6000, DT50_ws = 6, Koc = 344.8) #' PEC_sw_focus(dummy_1, 3000, f_drift = 0) +#' +#' # Metabolite +#' new_dummy <- chent_focus_sw(mw = 250, Koc = 100) +#' M1 <- chent_focus_sw(mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, max_ws = 0, max_soil = 0.5) +#' PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", met = M1) PEC_sw_focus <- function(parent, rate, n = 1, i = NA, - applications = data.frame(time = seq(0, 0 + n * i, length.out = n), - amount = rate), met = NULL, - step = 1, - f_drift = 0.02759, f_rd = 0.1) + f_drift = NA, f_rd = 0.1, + scenario = FOCUS_Step_12_scenarios$names) { + if (n > 1 & is.na(i)) stop("Please specify the interval i if n > 1") + + if (is.na(f_drift)) { + scenario = match.arg(scenario) + f_drift = FOCUS_Step_12_scenarios$drift[scenario, "1"] / 100 + # For Step 2 we would/will select the reduced percentiles for multiple apps: + # if (n <= 8) { + # f_drift = FOCUS_Step_12_scenarios$drift[scenario, as.character(n)] / 100 + # } else { + # f_drift = FOCUS_Step_12_scenarios$drift[scenario, ">8"] / 100 + # } + } + if (is.null(met)) { + cwsat = parent$cwsat mw_ratio = 1 max_soil = 1 max_ws = 1 Koc = parent$Koc DT50_ws = parent$DT50_ws } else { + cwsat = met$cwsat mw_ratio = met$mw / parent$mw max_soil = met$max_soil max_ws = met$max_ws @@ -41,17 +79,35 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA, # Rates for a single application eq_rate_drift_s = mw_ratio * max_ws * rate + # Parent only, or metabolite formed in soil: eq_rate_rd_s = mw_ratio * max_soil * rate + # Metabolite formed in water (this part is not documented in the Help files + # of the Steps 1/2 calculator): + if (!is.null(met)) { + eq_rate_rd_parent_s = mw_ratio * max_ws * rate + eq_rate_rd_s_tot = eq_rate_rd_s + eq_rate_rd_parent_s + } else { + eq_rate_rd_parent_s = NA + eq_rate_rd_s_tot = eq_rate_rd_s + } # Drift input input_drift_s = f_drift * eq_rate_drift_s / 10 # mg/m2 - input_drift = n * input_drift_s # Runoff/drainage input ratio_field_wb = 10 # 10 m2 of field for each m2 of the waterbody - input_rd_s = f_rd * eq_rate_rd_s * ratio_field_wb / 10 + input_rd_s = f_rd * eq_rate_rd_s_tot * ratio_field_wb / 10 input_rd = n * input_rd_s + # No accumulation between multiple applications if 3 * DT50 < i + if (n > 1 && (3 * DT50_ws < i)) { + input_drift = input_drift_s + input_rd = input_rd_s + } else { + input_drift = n * input_drift_s + input_rd = n * input_rd_s + } + # Fraction of compound entering the water phase via runoff/drainage depth_sw = 0.3 # m depth_sed = 0.05 # m @@ -85,25 +141,41 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA, PEC["1", "TWAECsw"] = (PEC_sw_0 + PEC["1", "PECsw"]) / 2 PEC["1", "TWAECsed"] = (PEC_sed_0 + PEC["1", "PECsed"]) / 2 - list(eq_rate_drift_s = eq_rate_drift_s, - eq_rate_rd_s = eq_rate_rd_s, - input_drift_s = input_drift_s, - input_rd_s = input_rd_s, - f_rd_sw = f_rd_sw, f_rd_sed = f_rd_sed, - PEC = PEC) + # Check if PEC_sw_max is above water solubility + PEC_sw_max = max(PEC[, "PECsw"]) + if (PEC_sw_max > 1000 * cwsat) { + warning("The maximum PEC surface water exceeds the water solubility") + } + + PEC_sed_max = max(PEC[, "PECsed"]) + + list(f_drift = f_drift, + eq_rate_drift_s = eq_rate_drift_s, + eq_rate_rd_s = eq_rate_rd_s, + eq_rate_rd_parent_s = eq_rate_rd_parent_s, + input_drift_s = input_drift_s, + input_rd_s = input_rd_s, + f_rd_sw = f_rd_sw, f_rd_sed = f_rd_sed, + PEC = PEC, + PEC_sw_max = PEC_sw_max, + PEC_sed_max = PEC_sed_max + ) } -#' Create an chemical compound object for FOCUS Step 1 and 2 calculations +#' Create a chemical compound object for FOCUS Step 1 calculations #' #' @export #' @param cwsat Water solubility in mg/L #' @param DT50_ws Half-life in water/sediment systems in days #' @param Koc Partition coefficient between organic carbon and water #' in L/kg. +#' @param mw Molar weight in g/mol +#' @param max_soil Maximum observed fraction (dimensionless) in soil +#' @param max_ws Maximum observed fraction (dimensionless) in water/sediment +#' systems #' @return A list with the substance specific properties -chent_focus_sw <- function(Koc, DT50_ws, cwsat = 1000) +chent_focus_sw <- function(Koc, DT50_ws = NA, cwsat = 1000, mw = NA, max_soil = 1, max_ws = 1) { - list(Koc = Koc, DT50_ws = DT50_ws, cwsat = cwsat) + list(Koc = Koc, DT50_ws = DT50_ws, cwsat = cwsat, + mw = mw, max_soil = max_soil, max_ws = max_ws) } - - diff --git a/R/PELMO_runs.R b/R/PELMO_runs.R index 0f134e0..b152b4d 100644 --- a/R/PELMO_runs.R +++ b/R/PELMO_runs.R @@ -3,7 +3,7 @@ #' Per default, the runs are not only set up but also executed with FOCUS #' PELMO, the results are processed and returned. Currently, only FOCUS PELMO #' as installed on Linux (or other Unix systems) -#' using the \code{\link{install_PELMO}} from the \code{PELMO.installeR} package +#' using the \code{install_PELMO} from the \code{PELMO.installeR} package #' maintained on github is supported. In such installations, FOCUS PELMO is #' installed into the package installation directory of \code{PELMO.installeR} #' and run using \code{wine}. @@ -33,6 +33,8 @@ #' PELMO test results \url{http://esdac.jrc.ec.europa.eu/public_path/projects_data/focus/gw/models/pelmo/test-results/test_results_FOCUS_PELMO_5_5_3.doc} #' @export #' @examples +#' # At the moment I can not run the examples, as my wine installation is not working +#' \dontrun{ #' # Reproduce the official test results for annual application of Pesticide D #' # to winter cereals at the day before emergence #' runs_1 <- list( @@ -54,6 +56,7 @@ #' PECgw_2 <- PELMO_runs(runs_2, psm_dir = system.file("testdata", package = "pfm"), #' cores = 3, overwrite = TRUE) #' print(PECgw_2) +#' } PELMO_runs <- function(runs, psm_dir = ".", version = "5.5.3", PELMO_base = "auto", execute = TRUE, cores = getOption("mc.cores", 2L), evaluate = TRUE, overwrite = FALSE) @@ -410,6 +413,9 @@ evaluate_PELMO <- function(runs, version = "5.5.3", PELMO_base = "auto") } #' Get the application interval in years from a psm file +#' +#' @param psm_file The path to the .psm file +#' @param location_code The location code get_interval <- function(psm_file, location_code) { # How many years do we calculate (26, 46 or 66)? psm <- readLines(psm_file, encoding = "latin1") @@ -433,6 +439,9 @@ get_interval <- function(psm_file, location_code) { } #' Sum up values according to FOCUS periods +#' +#' @param annual The annual flux as obtained by \code{get_flux} +#' @param interval The interval in years sum_periods <- function(annual, interval) { n_years <- switch(as.character(interval), "1" = 26, @@ -446,6 +455,8 @@ sum_periods <- function(annual, interval) { } #' Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file +#' +#' @param chem_file The full path to a CHEM*.PLM file get_flux <- function(chem_file) { chem <- readLines(chem_file) lowest_focus_comp_lines <- grep("^ . 21 ", chem, value = TRUE) diff --git a/_pkgdown.yml b/_pkgdown.yml index 829ba48..6c8f632 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -25,6 +25,7 @@ reference: - PEC_sw_drift - drift_data_JKI - PEC_sw_drainage_UK + - PEC_sw_focus - TOXSWA_cwa - read.TOXSWA_cwa - plot.TOXSWA_cwa diff --git a/docs/authors.html b/docs/authors.html index 0830cef..4bec4d8 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -25,12 +25,14 @@ - + + + diff --git a/docs/index.html b/docs/index.html index 0a45d75..7c7cca5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,7 +9,7 @@ - @@ -45,7 +45,7 @@
+pfm

The R package pfm provides some utilities for fate modelling, including dealing with FOCUS pesticide fate modelling tools, (currently only TOXSWA cwa and out files), made available under the GNU public license. This means:

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
@@ -61,19 +61,19 @@ You should have received a copy of the GNU General Public License along with
 this program. If not, see <http://www.gnu.org/licenses/>

- Installation

+Installation

You can install the package from github, e.g. using the devtools package. Using quick = TRUE skips docs, multiple-architecture builds, demos, and vignettes, to make installation as fast and painless as possible.

library(devtools)
 install_github("jranke/pfm", quick = TRUE)

- Use

+Use

Please refer to the reference.

- Examples

+Examples

One recent nice example of the usage of this package is the visualisation of a time weighted average for a sawtooth curve obtained from several overlays of mkinfit predictions as shown here.

Another, even more recent example shows how FOCUS PELMO can be run in parallel under Linux as shown here.

diff --git a/docs/pkgdown.css b/docs/pkgdown.css index fd7b0ba..9c437c7 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -36,11 +36,8 @@ img.icon { /* Section anchors ---------------------------------*/ -.hasAnchor { - margin-left: -30px; -} - a.anchor { + margin-left: -30px; display:inline-block; width: 30px; height: 30px; @@ -56,6 +53,13 @@ a.anchor { visibility: visible; } +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + /* Fixes for fixed navbar --------------------------*/ .contents h1, .contents h2, .contents h3, .contents h4 { @@ -63,6 +67,17 @@ a.anchor { margin-top: -60px; } +/* Static header placement on mobile devices */ +@media (max-width: 767px) { + .navbar-fixed-top { + position: absolute; + } + .navbar { + padding: 0; + } +} + + /* Sidebar --------------------------*/ #sidebar { @@ -81,33 +96,59 @@ a.anchor { margin-bottom: 0.5em; } -/* Syntax highlighting ---------------------------------------------------- */ +/* Reference index & topics ----------------------------------------------- */ -code { - background-color: #f7f7f7; - color: #333; -} -code a { - color: #375f84; +.ref-index th {font-weight: normal;} +.ref-index h2 {font-size: 20px;} + +.ref-index td {vertical-align: top;} +.ref-index .alias {width: 40%;} +.ref-index .title {width: 60%;} + +.ref-index .alias {width: 40%;} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; } -.warning { color: red; } -.message { font-weight: bolder; } -.error { color: red; font-weight: bolder; } +/* Syntax highlighting ---------------------------------------------------- */ -.fl,.number {color:rgb(21,20,181);} -.fu,.functioncall {color:#264D66 ;} -.ch,.st,.string {color:#375D81 ;} -.kw,.keyword {color:black;} -.argument {color:#264D66 ;} -.co,.comment {color: #777;} -.formalargs {color: #264D66;} -.eqformalargs {color:#264D66;} -.slot {font-style:italic;} -.symbol {color:black ;} -.prompt {color:black ;} +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} pre img { background-color: #fff; display: block; } + +code a, pre a { + color: #375f84; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + diff --git a/docs/reference/FOCUS_GW_scenarios_2012.html b/docs/reference/FOCUS_GW_scenarios_2012.html index fbc1649..97bdebf 100644 --- a/docs/reference/FOCUS_GW_scenarios_2012.html +++ b/docs/reference/FOCUS_GW_scenarios_2012.html @@ -6,7 +6,7 @@ -A very small subset of the FOCUS Groundwater scenario defitions — FOCUS_GW_scenarios_2012 • pfm +A very small subset of the FOCUS Groundwater scenario definitions — FOCUS_GW_scenarios_2012 • pfm @@ -25,12 +25,14 @@ - + + + @@ -66,7 +68,7 @@
@@ -74,7 +76,7 @@ soil definitions are from page 46ff. from FOCUS (2012).

-
FOCUS_GW_scenarios_2012
+
FOCUS_GW_scenarios_2012

Format

@@ -90,9 +92,9 @@ soil definitions are from page 46ff. from FOCUS (2012).

Examples

FOCUS_GW_scenarios_2012
#> $names #> Cha Ham Jok Kre Oke -#> "Châteaudun" "Hamburg" "Jokioinen" "Kremsmünster" "Okehampton" +#> "Châteaudun" "Hamburg" "Jokioinen" "Kremsmünster" "Okehampton" #> Pia Por Sev Thi -#> "Piacenza" "Porto" "Sevilla" "Thiva" +#> "Piacenza" "Porto" "Sevilla" "Thiva" #> #> $soils #> location horizon number pH_H2O perc_clay perc_oc rel_deg diff --git a/docs/reference/FOCUS_PELMO_crop_sze_names.html b/docs/reference/FOCUS_PELMO_crop_sze_names.html index 5777868..16c0dc6 100644 --- a/docs/reference/FOCUS_PELMO_crop_sze_names.html +++ b/docs/reference/FOCUS_PELMO_crop_sze_names.html @@ -25,12 +25,14 @@ - + + + @@ -76,7 +78,7 @@ in the file names are sometimes capitalized, sometimes not. The scenario files used for Beans (field) and Beans (vegetable) are the same.

-
FOCUS_PELMO_crop_sze_names
+
FOCUS_PELMO_crop_sze_names

Format

@@ -85,13 +87,13 @@ files used for Beans (field) and Beans (vegetable) are the same.

Examples

print(FOCUS_PELMO_crop_sze_names)
#> app gra pot sug win fbe vbe bus -#> "apples" "grass" "potato" "sbeets" "wcerea" "beans" "beans" "bushb" +#> "apples" "grass" "potato" "sbeets" "wcerea" "beans" "beans" "bushb" #> cab car cit cot lin mai soi woi -#> "cabbag" "carrot" "citrus" "cotton" "linse" "maize" "rapesu" "rapewi" +#> "cabbag" "carrot" "citrus" "cotton" "linse" "maize" "rapesu" "rapewi" #> oni ape soy spr str sun tob tom -#> "onions" "peas" "soyb" "scerea" "strawb" "sunflo" "tobacc" "tomato" +#> "onions" "peas" "soyb" "scerea" "strawb" "sunflo" "tobacc" "tomato" #> vin -#> "vines"
+#> "vines"
diff --git a/docs/reference/index.html b/docs/reference/index.html index 33713b6..a6ae657 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -25,12 +25,14 @@ - + + + @@ -66,113 +68,171 @@
-

General utility functions

-

Functions that are independent of specific fate modelling areas

- - -

Calculate the geometric mean

- - -

Create a time series of decline data

- - -

Plot time series of decline data

- - -

Create decline time series for multiple applications

- - -

Calculate a time weighted average concentration

- - -

The maximum time weighted average concentration for a moving window

- -

Predicted environmental concentrations in soil

-

+ - -

Calculate predicted environmental concentrations in soil

- - -

Properties of the predefined scenarios from the EFSA guidance from 2015

- -

Predicted environmental concentrations in groundwater

-

+ + + + - -

Set up runs for FOCUS PELMO

- -

Predicted environmental concentrations in surface water

-

- - -

Calculate predicted environmental concentrations in surface water due to drift

- - -

Deposition from spray drift expressed as percent of the applied dose as -

- - -

Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method

- - -

R6 class for holding TOXSWA cwa concentration data and associated statistics

- - -

Read TOXSWA surface water concentrations

- - -

Plot TOXSWA surface water concentrations

- -

Classifications and indicators

-

Evaluating environmental fate properties

- - -

Determine the SSLRC mobility classification for a chemical substance from its Koc

- - -

Groundwater ubiquity score based on Gustafson (1989)

- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

General utility functions

+

Functions that are independent of specific fate modelling areas

+
+

geomean

+

Calculate the geometric mean

+

one_box

+

Create a time series of decline data

+

plot

+

Plot time series of decline data

+

sawtooth

+

Create decline time series for multiple applications

+

twa

+

Calculate a time weighted average concentration

+

max_twa

+

The maximum time weighted average concentration for a moving window

+

Predicted environmental concentrations in soil

+

+
+

PEC_soil

+

Calculate predicted environmental concentrations in soil

+

soil_scenario_data_EFSA_2015

+

Properties of the predefined scenarios from the EFSA guidance from 2015

+

Predicted environmental concentrations in groundwater

+

+
+

PELMO_runs run_PELMO evaluate_PELMO

+

Set up runs for FOCUS PELMO

+

Predicted environmental concentrations in surface water

+

+
+

PEC_sw_drift

+

Calculate predicted environmental concentrations in surface water due to drift

+

drift_data_JKI

+

Deposition from spray drift expressed as percent of the applied dose as +published by the JKI

+

PEC_sw_drainage_UK

+

Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method

+

PEC_sw_focus

+

Calculate FOCUS Step 1 PEC surface water

+

TOXSWA_cwa

+

R6 class for holding TOXSWA cwa concentration data and associated statistics

+

read.TOXSWA_cwa

+

Read TOXSWA surface water concentrations

+

plot

+

Plot TOXSWA surface water concentrations

+

Classifications and indicators

+

Evaluating environmental fate properties

+
+

SSLRC_mobility_classification

+

Determine the SSLRC mobility classification for a chemical substance from its Koc

+

GUS print

+

Groundwater ubiquity score based on Gustafson (1989)

diff --git a/docs/reference/max_twa.html b/docs/reference/max_twa.html index f78da58..431bbd7 100644 --- a/docs/reference/max_twa.html +++ b/docs/reference/max_twa.html @@ -25,12 +25,14 @@ - + + + @@ -77,15 +79,20 @@ for finding the maximum. It is therefore recommended to check this using max_twa.

-
max_twa(x, window = 21)
+
max_twa(x, window = 21)

Arguments

-
-
x
-
An object of type one_box
-
window
-
The size of the moving window
-
+ + + + + + + + + + +
x

An object of type one_box

window

The size of the moving window

Details

diff --git a/docs/reference/one_box-12.png b/docs/reference/one_box-12.png deleted file mode 100644 index 31e2f4b..0000000 Binary files a/docs/reference/one_box-12.png and /dev/null differ diff --git a/docs/reference/one_box-6.png b/docs/reference/one_box-6.png deleted file mode 100644 index 10ebb35..0000000 Binary files a/docs/reference/one_box-6.png and /dev/null differ diff --git a/docs/reference/one_box.html b/docs/reference/one_box.html index 800ca66..931e722 100644 --- a/docs/reference/one_box.html +++ b/docs/reference/one_box.html @@ -25,12 +25,14 @@ - + + + @@ -73,7 +75,7 @@

Create a time series of decline data

-
one_box(x, ini, ..., t_end = 100, res = 0.01)
+    
one_box(x, ini, ..., t_end = 100, res = 0.01)
 
 # S3 method for numeric
 one_box(x, ini = 1, ..., t_end = 100, res = 0.01)
@@ -86,28 +88,41 @@
 one_box(x, ini = "model", ..., t_end = 100, res = 0.01)

Arguments

-
-
x
-
When numeric, this is the half-life to be used for an exponential + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

When numeric, this is the half-life to be used for an exponential decline. When a character string specifying a parent decline model is given e.g. FOMC, parms must contain the corresponding paramters. If x is an mkinfit object, the decline is calculated from this -object. -

ini
-
The initial amount. If x is an mkinfit object, and -ini is 'model', the fitted initial concentrations are used. Otherwise, ini +object.

ini

The initial amount. If x is an mkinfit object, and +ini is 'model', the fitted initial concentrations are used. Otherwise, ini must be numeric. If it has length one, it is used for the parent and initial values of metabolites are zero, otherwise, it must give values for -all observed variables. -

...
-
Further arguments passed to methods
-
t_end
-
End of the time series
-
res
-
Resolution of the time series
-
parms
-
A named numeric vector containing the model parameters
- +all observed variables.

...

Further arguments passed to methods

t_end

End of the time series

res

Resolution of the time series

parms

A named numeric vector containing the model parameters

Value

diff --git a/docs/reference/pfm_degradation.html b/docs/reference/pfm_degradation.html index d98778b..9198f6b 100644 --- a/docs/reference/pfm_degradation.html +++ b/docs/reference/pfm_degradation.html @@ -25,12 +25,14 @@ - + + + @@ -73,27 +75,40 @@

Calculate a time course of relative concentrations based on an mkinmod model

-
pfm_degradation(model = "SFO", DT50 = 1000, parms = c(k_parent_sink =
+    
pfm_degradation(model = "SFO", DT50 = 1000, parms = c(k_parent_sink =
   log(2)/DT50), years = 1, step_days = 1, times = seq(0, years * 365, by =
   step_days))

Arguments

-
-
model
-
The degradation model to be used. Either a parent only model like -'SFO' or 'FOMC', or an mkinmod object
-
DT50
-
The half-life. This is only used when simple exponential decline -is calculated (SFO model).
-
parms
-
The parameters used for the degradation model
-
years
-
For how many years should the degradation be predicted?
-
step_days
-
What step size in days should the output have?
-
times
-
The output times
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
model

The degradation model to be used. Either a parent only model like +'SFO' or 'FOMC', or an mkinmod object

DT50

The half-life. This is only used when simple exponential decline +is calculated (SFO model).

parms

The parameters used for the degradation model

years

For how many years should the degradation be predicted?

step_days

What step size in days should the output have?

times

The output times

Examples

diff --git a/docs/reference/plot.TOXSWA_cwa.html b/docs/reference/plot.TOXSWA_cwa.html index 7cbe238..5375673 100644 --- a/docs/reference/plot.TOXSWA_cwa.html +++ b/docs/reference/plot.TOXSWA_cwa.html @@ -25,12 +25,14 @@ - + + + @@ -74,30 +76,45 @@ segment of a TOXSWA surface water body.

-
# S3 method for TOXSWA_cwa
+    
# S3 method for TOXSWA_cwa
 plot(x, time_column = c("datetime", "t", "t_firstjan",
   "t_rel_to_max"), xlab = "default", ylab = "default", add = FALSE,
   total = FALSE, LC_TIME = "C", ...)

Arguments

-
-
x
-
The TOXSWA_cwa object to be plotted.
-
time_column
-
What should be used for the time axis. If "t_firstjan" is chosen, -the time is given in days relative to the first of January in the first year.
-
xlab, ylab
-
Labels for x and y axis.
-
add
-
Should we add to an existing plot?
-
total
-
Should the total concentration in water be plotted, including substance sorbed -to suspended matter?
-
LC_TIME
-
Specification of the locale used to format dates
-
...
-
Further arguments passed to plot if we are not adding to an existing plot
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

The TOXSWA_cwa object to be plotted.

time_column

What should be used for the time axis. If "t_firstjan" is chosen, +the time is given in days relative to the first of January in the first year.

xlab, ylab

Labels for x and y axis.

add

Should we add to an existing plot?

total

Should the total concentration in water be plotted, including substance sorbed +to suspended matter?

LC_TIME

Specification of the locale used to format dates

...

Further arguments passed to plot if we are not adding to an existing plot

Examples

diff --git a/docs/reference/plot.one_box.html b/docs/reference/plot.one_box.html index 4c3cb82..0a876e3 100644 --- a/docs/reference/plot.one_box.html +++ b/docs/reference/plot.one_box.html @@ -25,12 +25,14 @@ - + + + @@ -73,32 +75,49 @@

Plot time series of decline data

-
# S3 method for one_box
+    
# S3 method for one_box
 plot(x, xlim = range(time(x)), ylim = c(0, max(x)),
   xlab = "Time", ylab = "Residue", max_twa = NULL,
   max_twa_var = dimnames(x)[[2]][1], ...)

Arguments

-
-
x
-
The object of type one_box to be plotted
-
xlim
-
Limits for the x axis
-
ylim
-
Limits for the y axis
-
xlab
-
Label for the x axis
-
ylab
-
Label for the y axis
-
max_twa
-
If a numeric value is given, the maximum time weighted -average concentration(s) is/are shown in the graph.
-
max_twa_var
-
Variable for which the maximum time weighted average should -be shown if max_twa is not NULL.
-
...
-
Further arguments passed to methods
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

The object of type one_box to be plotted

xlim

Limits for the x axis

ylim

Limits for the y axis

xlab

Label for the x axis

ylab

Label for the y axis

max_twa

If a numeric value is given, the maximum time weighted +average concentration(s) is/are shown in the graph.

max_twa_var

Variable for which the maximum time weighted average should +be shown if max_twa is not NULL.

...

Further arguments passed to methods

See also

diff --git a/docs/reference/read.TOXSWA_cwa.html b/docs/reference/read.TOXSWA_cwa.html index 3afec9c..30e29cd 100644 --- a/docs/reference/read.TOXSWA_cwa.html +++ b/docs/reference/read.TOXSWA_cwa.html @@ -25,12 +25,14 @@ - + + + @@ -77,37 +79,54 @@ segment are imported. As TOXSWA 4 reports the values at the end of the hour of the hourly averages (ConLiqWatLay).

-
read.TOXSWA_cwa(filename, basedir = ".", zipfile = NULL, segment = "last",
+    
read.TOXSWA_cwa(filename, basedir = ".", zipfile = NULL, segment = "last",
   substance = "parent", total = FALSE, windows = NULL,
   thresholds = NULL)

Arguments

-
-
filename
-
The filename of the cwa file (TOXSWA 2.x.y or similar) or the -out file (FOCUS TOXSWA 4, i.e. TOXSWA 4.4.2 or similar).
-
basedir
-
The path to the directory where the cwa file resides.
-
zipfile
-
Optional path to a zip file containing the cwa file.
-
segment
-
The segment for which the data should be read. Either "last", or -the segment number.
-
substance
-
For TOXSWA 4 .out files, the default value "parent" leads + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
filename

The filename of the cwa file (TOXSWA 2.x.y or similar) or the +out file (FOCUS TOXSWA 4, i.e. TOXSWA 4.4.2 or similar).

basedir

The path to the directory where the cwa file resides.

zipfile

Optional path to a zip file containing the cwa file.

segment

The segment for which the data should be read. Either "last", or +the segment number.

substance

For TOXSWA 4 .out files, the default value "parent" leads to reading concentrations of the parent compound. Alternatively, the substance -of interested can be selected by its code name. -

total
-
Set this to TRUE in order to read total concentrations as well. This is +of interested can be selected by its code name.

total

Set this to TRUE in order to read total concentrations as well. This is only necessary for .out files as generated by TOXSWA 4.4.2 or similar, not for .cwa -files. For .cwa files, the total concentration is always read as well. -

windows
-
Numeric vector of width of moving windows in days, for calculating -maximum time weighted average concentrations and areas under the curve.
-
thresholds
-
Numeric vector of threshold concentrations in µg/L for -generating event statistics.
- +files. For .cwa files, the total concentration is always read as well.

windows

Numeric vector of width of moving windows in days, for calculating +maximum time weighted average concentrations and areas under the curve.

thresholds

Numeric vector of threshold concentrations in µg/L for +generating event statistics.

Value

diff --git a/docs/reference/run_PELMO.html b/docs/reference/run_PELMO.html deleted file mode 100644 index 067d3c1..0000000 --- a/docs/reference/run_PELMO.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - -Run PELMO — run_PELMO • pfm - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - - -

Run PELMO

- - -
run_PELMO(runs, version = "5.5.3", PELMO_base = "auto",
-  cores = getOption("mc.cores", 2L))
- -

Arguments

-
-
runs
-
A list of lists. Each inner lists has an element named 'psm' -that holds the psm string, and elements named using three letter crop acronyms, -as used in FOCUS_PELMO_crops, -that hold character vectors of three letter scenario acronyms -as used in FOCUS_GW_scenarios_2012.
-
version
-
The FOCUS PELMO version
-
PELMO_base
-
Where the FOCUS PELMO installation is located
-
cores
-
The number of cores to execute PELMO runs in parallel
-
- - -
- -
- -
- - -
-

Site built with pkgdown.

-
- -
-
- - - diff --git a/docs/reference/sawtooth-8.png b/docs/reference/sawtooth-8.png deleted file mode 100644 index 161ecb4..0000000 Binary files a/docs/reference/sawtooth-8.png and /dev/null differ diff --git a/docs/reference/sawtooth.html b/docs/reference/sawtooth.html index be43745..0d5c9a9 100644 --- a/docs/reference/sawtooth.html +++ b/docs/reference/sawtooth.html @@ -25,12 +25,14 @@ - + + + @@ -75,22 +77,31 @@ application pattern specified in applications is repeated ni.

-
sawtooth(x, n = 1, i = 365, applications = data.frame(time = seq(0, 0 + n
+    
sawtooth(x, n = 1, i = 365, applications = data.frame(time = seq(0, 0 + n
   * i, length.out = n), amount = 1))

Arguments

-
-
x
-
A one_box object
-
n
-
The number of applications. If applications is specified, n is ignored
-
i
-
The interval between applications. If applications is specified, i -is ignored
-
applications
-
A data frame holding the application times in the first column and -the corresponding amounts applied in the second column.
-
+ + + + + + + + + + + + + + + + + + +
x

A one_box object

n

The number of applications. If applications is specified, n is ignored

i

The interval between applications. If applications is specified, i +is ignored

applications

A data frame holding the application times in the first column and +the corresponding amounts applied in the second column.

Examples

diff --git a/docs/reference/soil_scenario_data_EFSA_2015.html b/docs/reference/soil_scenario_data_EFSA_2015.html index f842d08..39841ed 100644 --- a/docs/reference/soil_scenario_data_EFSA_2015.html +++ b/docs/reference/soil_scenario_data_EFSA_2015.html @@ -25,12 +25,14 @@ - + + + @@ -92,24 +94,24 @@ doi:10.2903/j.efsa.2015.4093

Examples

-
## Not run: ------------------------------------ -# # This is the code that was used to define the data -# soil_scenario_data_EFSA_2015 <- data.frame( -# Zone = rep(c("North", "Central", "South"), 2), -# Country = c("Estonia", "Germany", "France", "Denmark", "Czech Republik", "Spain"), -# T_arit = c(4.7, 8.0, 11.0, 8.2, 9.1, 12.8), -# T_arr = c(7.0, 10.1, 12.3, 9.8, 11.2, 14.7), -# Texture = c("Coarse", "Coarse", "Medium fine", "Medium", "Medium", "Medium"), -# f_om = c(0.118, 0.086, 0.048, 0.023, 0.018, 0.011), -# theta_fc = c(0.244, 0.244, 0.385, 0.347, 0.347, 0.347), -# rho = c(0.95, 1.05, 1.22, 1.39, 1.43, 1.51), -# f_sce = c(3, 2, 2, 2, 1.5, 1.5), -# f_mod = c(2, 2, 2, 4, 4, 4), -# stringsAsFactors = FALSE, -# row.names = c("CTN", "CTC", "CTS", "CLN", "CLC", "CLS") -# ) -# save(soil_scenario_data_EFSA_2015, file = '../data/soil_scenario_data_EFSA_2015.RData') -## --------------------------------------------- +
not_run({ + # This is the code that was used to define the data + soil_scenario_data_EFSA_2015 <- data.frame( + Zone = rep(c("North", "Central", "South"), 2), + Country = c("Estonia", "Germany", "France", "Denmark", "Czech Republik", "Spain"), + T_arit = c(4.7, 8.0, 11.0, 8.2, 9.1, 12.8), + T_arr = c(7.0, 10.1, 12.3, 9.8, 11.2, 14.7), + Texture = c("Coarse", "Coarse", "Medium fine", "Medium", "Medium", "Medium"), + f_om = c(0.118, 0.086, 0.048, 0.023, 0.018, 0.011), + theta_fc = c(0.244, 0.244, 0.385, 0.347, 0.347, 0.347), + rho = c(0.95, 1.05, 1.22, 1.39, 1.43, 1.51), + f_sce = c(3, 2, 2, 2, 1.5, 1.5), + f_mod = c(2, 2, 2, 4, 4, 4), + stringsAsFactors = FALSE, + row.names = c("CTN", "CTC", "CTS", "CLN", "CLC", "CLS") + ) + save(soil_scenario_data_EFSA_2015, file = '../data/soil_scenario_data_EFSA_2015.RData') +}) # And this is the resulting dataframe soil_scenario_data_EFSA_2015
#> Zone Country T_arit T_arr Texture f_om theta_fc rho f_sce diff --git a/docs/reference/sum_periods.html b/docs/reference/sum_periods.html index 66466ac..147a698 100644 --- a/docs/reference/sum_periods.html +++ b/docs/reference/sum_periods.html @@ -25,12 +25,14 @@ - + + + @@ -73,13 +75,27 @@

Sum up values according to FOCUS periods

-
sum_periods(annual, interval)
- +
sum_periods(annual, interval)
+ +

Arguments

+ + + + + + + + + + +
annual

The annual flux as obtained by get_flux

interval

The interval in years

+
diff --git a/docs/reference/twa.html b/docs/reference/twa.html index 414b372..32fa459 100644 --- a/docs/reference/twa.html +++ b/docs/reference/twa.html @@ -25,12 +25,14 @@ - + + + @@ -75,18 +77,23 @@ the earliest possible time for the maximum in the time series returned is after one window has passed.

-
twa(x, window = 21)
+    
twa(x, window = 21)
 
 # S3 method for one_box
 twa(x, window = 21)

Arguments

-
-
x
-
An object of type one_box
-
window
-
The size of the moving window
-
+ + + + + + + + + + +
x

An object of type one_box

window

The size of the moving window

See also

diff --git a/inst/extdata/FOCUS_Step_12_scenarios.txt b/inst/extdata/FOCUS_Step_12_scenarios.txt new file mode 100755 index 0000000..a022166 --- /dev/null +++ b/inst/extdata/FOCUS_Step_12_scenarios.txt @@ -0,0 +1,48 @@ +Ver 02 FOCUS step 1 & 2 scenario data file +water depth (cm): 30 +sediment depth(cm): 5 +effective sediment depth (cm): 1 +sediment oc (%): 5 +sediment bulk density (kg/L): 0.8 +ratio of field to water body: 10 +Spray drift Number of crops: 29 Number of variations: 9 Number of Interception classes: 4 +Crop Distance crop-water 1 2 3 4 5 6 7 8 >8 no interception minimal crop cover average crop cover full canopy +cereals, spring 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0 0.2 0.7 +cereals, winter 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0 0.2 0.7 +citrus 3 15.725 12.129 11.011 10.124 9.743 9.204 9.102 8.656 8.656 0 0.8 0.8 0.8 +cotton 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.3 0.6 0.75 +field beans 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.4 0.7 +grass / alfalfa 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.4 0.6 0.75 +hops 3 19.326 17.723 15.928 15.378 15.114 14.902 14.628 13.52 13.52 0 0.2 0.5 0.7 +legumes 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.5 0.7 +maize 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.5 0.75 +oil seed rape, spring 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.4 0.7 0.75 +oil seed rape, winter 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.4 0.7 0.75 +olives 3 15.725 12.129 11.011 10.124 9.743 9.204 9.102 8.656 8.656 0 0.7 0.7 0.7 +pome / stone fruit, early applns 3 29.197 25.531 23.96 23.603 23.116 22.76 22.69 22.241 22.241 0 0.2 0.4 0.65 +pome / stone fruit, late applns 3 15.725 12.129 11.011 10.124 9.743 9.204 9.102 8.656 8.656 0 0.2 0.4 0.65 +potatoes 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.15 0.5 0.7 +soybeans 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.2 0.5 0.75 +sugar beets 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.2 0.7 0.75 +sunflowers 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.2 0.5 0.75 +tobacco 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.2 0.7 0.75 +vegetables, bulb 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.1 0.25 0.4 +vegetables, fruiting 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.5 0.7 +vegetables, leafy 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.4 0.7 +vegetables, root 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.25 0.5 0.7 +vines, early applns 3 2.699 2.496 2.546 2.499 2.398 2.336 2.283 2.265 2.265 0 0.4 0.5 0.6 +vines, late applns 3 8.028 7.119 6.898 6.631 6.636 6.431 6.227 6.173 6.173 0 0.4 0.5 0.6 +appln, aerial 3 33.2 33.2 33.2 33.2 33.2 33.2 33.2 33.2 33.2 0 0.2 0.5 0.7 +appln, hand (crop < 50 cm) 1 2.759 2.438 2.024 1.862 1.794 1.631 1.578 1.512 1.512 0 0.2 0.5 0.7 +appln, hand (crop > 50 cm) 3 8.028 7.119 6.898 6.631 6.636 6.431 6.227 6.173 6.173 0 0.2 0.5 0.7 +no drift (incorp or seed trtmt) 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +Runoff/Drainage Numbers for step 1 1 Numbers for step 2 7 +Step 1 10 +North Europe, Oct. - Feb. 5 +North Europe, Mar. - May 2 +North Europe, June - Sep. 2 +South Europe, Oct. - Feb. 4 +South Europe, Mar. - May 4 +South Europe, June - Sep. 3 +No Runoff/Drainage 0 +Equilibrium Factor 1.5 diff --git a/man/FOCUS_GW_scenarios_2012.Rd b/man/FOCUS_GW_scenarios_2012.Rd index a19bbe5..4529816 100644 --- a/man/FOCUS_GW_scenarios_2012.Rd +++ b/man/FOCUS_GW_scenarios_2012.Rd @@ -3,7 +3,7 @@ \docType{data} \name{FOCUS_GW_scenarios_2012} \alias{FOCUS_GW_scenarios_2012} -\title{A very small subset of the FOCUS Groundwater scenario defitions} +\title{A very small subset of the FOCUS Groundwater scenario definitions} \format{An object of class \code{list} of length 2.} \usage{ FOCUS_GW_scenarios_2012 diff --git a/man/FOCUS_Step_12_scenarios.Rd b/man/FOCUS_Step_12_scenarios.Rd new file mode 100644 index 0000000..f58dea7 --- /dev/null +++ b/man/FOCUS_Step_12_scenarios.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/FOCUS_Step_12_scenarios.R +\docType{data} +\name{FOCUS_Step_12_scenarios} +\alias{FOCUS_Step_12_scenarios} +\title{Step 1/2 scenario data as distributed with the FOCUS Step 1/2 calculator} +\format{A list containing the scenario names in a character vector called 'names', + the drift percentiles in a matrix called 'drift', interception percentages in + a matrix called 'interception' and the runoff/drainage percentages for Step 2 + calculations in a matrix called 'rd'.} +\description{ +The data were extracted from the scenario.txt file using the R code shown below. +The text file is not included in the package as its licence is not clear. +} +\examples{ + +\dontrun{ + # This is the code that was used to extract the data + scenario_path <- "inst/extdata/FOCUS_Step_12_scenarios.txt" + scenarios <- readLines(scenario_path)[9:38] + FOCUS_Step_12_scenarios <- list() + sce <- read.table(text = scenarios, sep = "\\t", header = TRUE, check.names = FALSE, + stringsAsFactors = FALSE) + FOCUS_Step_12_scenarios$names = sce$Crop + rownames(sce) <- sce$Crop + FOCUS_Step_12_scenarios$drift = sce[, 3:11] + FOCUS_Step_12_scenarios$interception = sce[, 12:15] + sce_2 <- readLines(scenario_path)[41:46] + rd <- read.table(text = sce_2, sep = "\\t")[1:2] + rd_mat <- matrix(rd$V2, nrow = 3, byrow = FALSE) + dimnames(rd_mat) = list(Time = c("Oct-Feb", "Mar-May", "Jun-Sep"), + Region = c("North", "South")) + FOCUS_Step_12_scenarios$rd = rd_mat + save(FOCUS_Step_12_scenarios, file = "data/FOCUS_Step_12_scenarios.RData") +} + +# And this is the resulting data +FOCUS_Step_12_scenarios +} +\keyword{datasets} diff --git a/man/PEC_sw_focus.Rd b/man/PEC_sw_focus.Rd index 0f444ca..22c20c5 100644 --- a/man/PEC_sw_focus.Rd +++ b/man/PEC_sw_focus.Rd @@ -4,9 +4,8 @@ \alias{PEC_sw_focus} \title{Calculate FOCUS Step 1 PEC surface water} \usage{ -PEC_sw_focus(parent, rate, n = 1, i = NA, applications = data.frame(time = - seq(0, 0 + n * i, length.out = n), amount = rate), met = NULL, step = 1, - f_drift = 0.02759, f_rd = 0.1) +PEC_sw_focus(parent, rate, n = 1, i = NA, met = NULL, f_drift = NA, + f_rd = 0.1, scenario = FOCUS_Step_12_scenarios$names) } \arguments{ \item{parent}{A list containing substance specific parameters} @@ -18,19 +17,51 @@ applications are given explicitly} \item{i}{The application interval} -\item{applications}{A dataframe containing times and amounts of each application} +\item{met}{A list containing metabolite specific parameters. If not NULL, +the PEC is calculated for this compound, not the parent.} -\item{step}{At the moment, only Step 1 is implemented} +\item{f_drift}{The fraction of the application rate reaching the waterbody +via drift. If NA, this is derived from the scenario name and the number +of applications via the drift data defined by the +\code{\link{FOCUS_Step_12_scenarios}}} + +\item{f_rd}{The fraction of the amount applied reaching the waterbody via +runoff/drainage. At Step 1, it is assumed to be 10%, be it the +parent or a metabolite} + +\item{scenario}{The name of the scenario. Must be one of the scenario +names given in \code{\link{FOCUS_Step_12_scenarios}}} } \description{ -This is an attempt to reimplement the FOCUS Step 1 and 2 calculator authored -by Michael Klein. The Step 1 and 2 scenario assumes an area ratio of 10:1 -between field and waterbody, and a water depth of 30 cm. -I did not (yet) implement the TWA formulas for times later than day 1, as I -did not understand them right away. -Also, Step 2 is not implemented (yet). +This is reimplementation of Step 1 of the FOCUS Step 1 and 2 calculator +version 3.2, authored by Michael Klein. Note that results for multiple +applications should be compared to the corresponding results for a +single application. At current, this is not done automatically in +this implementation. +} +\note{ +The formulas for input to the waterbody via runoff/drainage of the + parent and subsequent formation of the metabolite in water is not + documented in the model description coming with the calculator + +Step 2 is not implemented } \examples{ +# Parent only dummy_1 <- chent_focus_sw(cwsat = 6000, DT50_ws = 6, Koc = 344.8) PEC_sw_focus(dummy_1, 3000, f_drift = 0) + +# Metabolite +new_dummy <- chent_focus_sw(mw = 250, Koc = 100) +M1 <- chent_focus_sw(mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, max_ws = 0, max_soil = 0.5) +PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", met = M1) +} +\references{ +FOCUS (2014) Generic guidance for Surface Water Scenarios (version 1.4). + FOrum for the Co-ordination of pesticde fate models and their USe. + http://esdac.jrc.ec.europa.eu/public_path/projects_data/focus/sw/docs/Generic%20FOCUS_SWS_vc1.4.pdf + +Website of the Steps 1 and 2 calculator at the Joint Research + Center of the European Union: + http://esdac.jrc.ec.europa.eu/projects/stepsonetwo } diff --git a/man/PELMO_runs.Rd b/man/PELMO_runs.Rd index aa02a89..a0d0df8 100644 --- a/man/PELMO_runs.Rd +++ b/man/PELMO_runs.Rd @@ -44,7 +44,7 @@ If evaluate is TRUE, a list of lists of matrices holding the Per default, the runs are not only set up but also executed with FOCUS PELMO, the results are processed and returned. Currently, only FOCUS PELMO as installed on Linux (or other Unix systems) -using the \code{\link{install_PELMO}} from the \code{PELMO.installeR} package +using the \code{install_PELMO} from the \code{PELMO.installeR} package maintained on github is supported. In such installations, FOCUS PELMO is installed into the package installation directory of \code{PELMO.installeR} and run using \code{wine}. @@ -55,6 +55,8 @@ run directory, holding the results for all FOCUS periods, equivalent to the period.plm file generated by the FOCUS PELMO GUI. } \examples{ +# At the moment I can not run the examples, as my wine installation is not working +\dontrun{ # Reproduce the official test results for annual application of Pesticide D # to winter cereals at the day before emergence runs_1 <- list( @@ -77,6 +79,7 @@ PECgw_2 <- PELMO_runs(runs_2, psm_dir = system.file("testdata", package = "pfm") cores = 3, overwrite = TRUE) print(PECgw_2) } +} \references{ PELMO.installeR \url{https://jranke.github.io/PELMO.installeR} diff --git a/man/chent_focus_sw.Rd b/man/chent_focus_sw.Rd index 26742d0..945c343 100644 --- a/man/chent_focus_sw.Rd +++ b/man/chent_focus_sw.Rd @@ -2,9 +2,10 @@ % Please edit documentation in R/PEC_sw_focus.R \name{chent_focus_sw} \alias{chent_focus_sw} -\title{Create an chemical compound object for FOCUS Step 1 and 2 calculations} +\title{Create a chemical compound object for FOCUS Step 1 calculations} \usage{ -chent_focus_sw(Koc, DT50_ws, cwsat = 1000) +chent_focus_sw(Koc, DT50_ws = NA, cwsat = 1000, mw = NA, max_soil = 1, + max_ws = 1) } \arguments{ \item{Koc}{Partition coefficient between organic carbon and water @@ -13,10 +14,17 @@ in L/kg.} \item{DT50_ws}{Half-life in water/sediment systems in days} \item{cwsat}{Water solubility in mg/L} + +\item{mw}{Molar weight in g/mol} + +\item{max_soil}{Maximum observed fraction (dimensionless) in soil} + +\item{max_ws}{Maximum observed fraction (dimensionless) in water/sediment +systems} } \value{ A list with the substance specific properties } \description{ -Create an chemical compound object for FOCUS Step 1 and 2 calculations +Create a chemical compound object for FOCUS Step 1 calculations } diff --git a/man/get_flux.Rd b/man/get_flux.Rd index 93778cb..c56b891 100644 --- a/man/get_flux.Rd +++ b/man/get_flux.Rd @@ -6,6 +6,9 @@ \usage{ get_flux(chem_file) } +\arguments{ +\item{chem_file}{The full path to a CHEM*.PLM file} +} \description{ Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file } diff --git a/man/get_interval.Rd b/man/get_interval.Rd index a751996..519cf36 100644 --- a/man/get_interval.Rd +++ b/man/get_interval.Rd @@ -6,6 +6,11 @@ \usage{ get_interval(psm_file, location_code) } +\arguments{ +\item{psm_file}{The path to the .psm file} + +\item{location_code}{The location code} +} \description{ Get the application interval in years from a psm file } diff --git a/man/sum_periods.Rd b/man/sum_periods.Rd index 5051af4..21bd2c9 100644 --- a/man/sum_periods.Rd +++ b/man/sum_periods.Rd @@ -6,6 +6,11 @@ \usage{ sum_periods(annual, interval) } +\arguments{ +\item{annual}{The annual flux as obtained by \code{get_flux}} + +\item{interval}{The interval in years} +} \description{ Sum up values according to FOCUS periods } diff --git a/tests/testthat/test_PELMO.R b/tests/testthat/test_PELMO.R index 9bebc95..e6d3a0f 100644 --- a/tests/testthat/test_PELMO.R +++ b/tests/testthat/test_PELMO.R @@ -20,6 +20,7 @@ runs <- list( win = names(FOCUS_GW_scenarios_2012$names))) test_that("PELMO paths are correctly created", { + skip("A wine installation is needed for this test") psm_paths = c( PELMO_path(runs[[1]]$psm, "fbe", "Por"), PELMO_path(runs[[2]]$psm, "pot", "Ham"), @@ -34,6 +35,7 @@ test_that("PELMO paths are correctly created", { }) test_that("PELMO runs are correctly set up", { + skip("A wine installation is needed for this test") # Prepare runs in analogy to the test archive PELMO_runs(runs, psm_dir = PELMO_base, execute = FALSE, evaluate = FALSE, overwrite = TRUE) @@ -57,6 +59,7 @@ test_that("PELMO runs are correctly set up", { }) test_that("PELMO runs can be run and give the expected result files", { + skip("A wine installation is needed for this test") run_PELMO(runs, cores = 7) plm_files <- c("CHEM.PLM", "ECHO.PLM", @@ -85,9 +88,10 @@ test_that("PELMO runs can be run and give the expected result files", { } }) -pfm_PECgw <- evaluate_PELMO(runs) +# pfm_PECgw <- evaluate_PELMO(runs) test_that("PELMO runs are correctly evaluated", { + skip("A wine installation is needed for this test") # Check that if output is the same as in the test archive for (run in runs) { @@ -145,6 +149,7 @@ test_that("PELMO runs are correctly evaluated", { }) test_that("PECgw from FOCUS summary files can be reproduced", { + skip("A wine installation is needed for this test") focus_summary <- list() for (run in runs) { diff --git a/tests/testthat/test_step_1.R b/tests/testthat/test_step_1.R index abef72c..b067e8f 100644 --- a/tests/testthat/test_step_1.R +++ b/tests/testthat/test_step_1.R @@ -1,11 +1,12 @@ context("FOCUS Step 1 calculations") +t_out <- c(0, 1, 2, 4) # Checking the first four days should be sufficient for Step 1 + test_that("Results of Steps 1/2 calculator for Dummy 1 are reproduced", { dummy_1 <- chent_focus_sw(cwsat = 6000, DT50_ws = 6, Koc = 344.8) res_dummy_1 <- PEC_sw_focus(dummy_1, 3000, f_drift = 0) - t_out <- c(0, 1, 2, 4) # Checking the first four days should be sufficient for Step 1 - PEC_orig = matrix(NA, nrow = length(t_out), ncol = 4, + PEC_orig_1 = matrix(NA, nrow = length(t_out), ncol = 4, dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) PEC_orig_1[, "PECsw"] = c(685.06, 610.32, 543.73, 431.56) @@ -21,7 +22,6 @@ test_that("Results of Steps 1/2 calculator for Dummy 2 are reproduced", { dummy_2 <- chent_focus_sw(cwsat = 30, DT50_ws = 26, Koc = 110) res_dummy_2 <- PEC_sw_focus(dummy_2, 1000) - t_out <- c(0, 1, 2, 4) # Checking the first four days should be sufficient for Step 1 PEC_orig_2 = matrix(NA, nrow = length(t_out), ncol = 4, dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) @@ -31,22 +31,89 @@ test_that("Results of Steps 1/2 calculator for Dummy 2 are reproduced", { PEC_orig_2["1", "TWAECsed"] = 319.86 # Later TWAEC not implemented expect_equal(res_dummy_2$PEC[1:4, c(1, 2)], PEC_orig_2[, c(1, 2)], tolerance = 0.01, scale = 1) - expect_equal(res_dummy_2$PEC[1:4, c(3, 4)], PEC_orig_2[, c(3, 4)], tolerance = 10, scale = 1) + expect_equal(res_dummy_2$PEC[1:4, c(3, 4)], PEC_orig_2[, c(3, 4)], tolerance = 0.01, scale = 1) }) -test_that("Results of Steps 1/2 calculator for Dummy 2 are reproduced", { - dummy_2 <- chent_focus_sw(cwsat = 30, DT50_ws = 26, Koc = 110) - res_dummy_2 <- PEC_sw_focus(dummy_2, 1000) +test_that("Results of Steps 1/2 calculator for Dummy 4 are reproduced", { + dummy_4 <- chent_focus_sw(cwsat = 2e-3, DT50_ws = 4, Koc = 970) + res_dummy_4 <- PEC_sw_focus(dummy_4, 7.5, n = 3, i = 14, + scenario = "pome / stone fruit, early") - t_out <- c(0, 1, 2, 4) # Checking the first four days should be sufficient for Step 1 - PEC_orig_2 = matrix(NA, nrow = length(t_out), ncol = 4, + PEC_orig_4 = matrix(NA, nrow = length(t_out), ncol = 4, dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) - PEC_orig_2[, "PECsw"] = c(299.89, 290.86, 283.21, 268.50) - PEC_orig_2["1", "TWAECsw"] = 295.38 # Later TWAEC not implemented - PEC_orig_2[, "PECsed"] = c(319.77, 319.95, 311.53, 295.35) - PEC_orig_2["1", "TWAECsed"] = 319.86 # Later TWAEC not implemented + PEC_orig_4[, "PECsw"] = c(1.82, 1.18, 1.00, 0.70) + PEC_orig_4["1", "TWAECsw"] = 1.50 # Later TWAEC not implemented + PEC_orig_4[, "PECsed"] = c(10.57, 11.49, 9.66, 6.83) + PEC_orig_4["1", "TWAECsed"] = 11.03 # Later TWAEC not implemented - expect_equal(res_dummy_2$PEC[1:4, c(1, 2)], PEC_orig_2[, c(1, 2)], tolerance = 0.01, scale = 1) - expect_equal(res_dummy_2$PEC[1:4, c(3, 4)], PEC_orig_2[, c(3, 4)], tolerance = 10, scale = 1) + expect_equal(res_dummy_4$PEC[1:4, c(1, 2)], PEC_orig_4[, c(1, 2)], tolerance = 0.01, scale = 1) + expect_equal(res_dummy_4$PEC[1:4, c(3, 4)], PEC_orig_4[, c(3, 4)], tolerance = 0.01, scale = 1) +}) + +test_that("Results of Steps 1/2 calculator for Dummy 5 are reproduced", { + dummy_5 <- chent_focus_sw(cwsat = 1.15, DT50_ws = 118, Koc = 860) + res_dummy_5 <- PEC_sw_focus(dummy_5, 75, n = 5, i = 14, + scenario = "vines, early") + + PEC_orig_5 = matrix(NA, nrow = length(t_out), ncol = 4, + dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) + + PEC_orig_5[, "PECsw"] = c(61.60, 59.45, 59.10, 58.41) + PEC_orig_5["1", "TWAECsw"] = 60.53 # Later TWAEC not implemented + PEC_orig_5[, "PECsed"] = c(500.78, 511.28, 508.29, 502.35) + PEC_orig_5["1", "TWAECsed"] = 506.03 # Later TWAEC not implemented + + expect_equal(res_dummy_5$PEC[1:4, c(1, 2)], PEC_orig_5[, c(1, 2)], tolerance = 0.01, scale = 1) + expect_equal(res_dummy_5$PEC[1:4, c(3, 4)], PEC_orig_5[, c(3, 4)], tolerance = 0.01, scale = 1) +}) + +test_that("Results of Steps 1/2 calculator for Dummy 7 are reproduced", { + dummy_7 <- chent_focus_sw(cwsat = 2.60, DT50_ws = 28, Koc = 500) + res_dummy_7 <- PEC_sw_focus(dummy_7, 750, n = 4, i = 14, + scenario = "vines, early") + + PEC_orig_7 = matrix(NA, nrow = length(t_out), ncol = 4, + dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) + + PEC_orig_7[, "PECsw"] = c(626.99, 601.13, 586.43, 558.10) + PEC_orig_7["1", "TWAECsw"] = 614.06 # Later TWAEC not implemented + PEC_orig_7[, "PECsed"] = c(3.0, 3.01, 2.93, 2.79) * 1e3 + PEC_orig_7["1", "TWAECsed"] = 3.01e3 # Later TWAEC not implemented + + expect_equal(res_dummy_7$PEC[1:4, c(1, 2)], PEC_orig_7[, c(1, 2)], tolerance = 0.01, scale = 1) + expect_equal(res_dummy_7$PEC[1:4, c(3, 4)], PEC_orig_7[, c(3, 4)], tolerance = 10, scale = 1) +}) + +test_that("Results of Steps 1/2 calculator for New Dummy (M1-M3) are reproduced", { + new_dummy <- chent_focus_sw(mw = 250, Koc = 100) + M1 <- chent_focus_sw(mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, max_ws = 0, max_soil = 0.5) + res_M1 <- PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", + met = M1) + + PEC_orig_M1 = matrix(NA, nrow = length(t_out), ncol = 4, + dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) + + PEC_orig_M1[, "PECsw"] = c(62.5, 62.07, 61.64, 60.79) + PEC_orig_M1["1", "TWAECsw"] = 62.28 # Later TWAEC not implemented + PEC_orig_M1[, "PECsed"] = c(31.25, 31.03, 30.82, 30.40) + PEC_orig_M1["1", "TWAECsed"] = 31.14 # Later TWAEC not implemented + + expect_equal(res_M1$PEC[1:4, c(1, 2)], PEC_orig_M1[, c(1, 2)], tolerance = 0.01, scale = 1) + expect_equal(res_M1$PEC[1:4, c(3, 4)], PEC_orig_M1[, c(3, 4)], tolerance = 0.01, scale = 1) + + M2 <- chent_focus_sw(mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, max_ws = 0.5, max_soil = 0) + res_M2 <- PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", + met = M2) + + PEC_orig_M2 = matrix(NA, nrow = length(t_out), ncol = 4, + dimnames = list(Time = t_out, type = c("PECsw", "TWAECsw", "PECsed", "TWAECsed"))) + + PEC_orig_M2[, "PECsw"] = c(64.34, 63.78, 63.34, 62.47) + PEC_orig_M2["1", "TWAECsw"] = 64.06 # Later TWAEC not implemented + PEC_orig_M2[, "PECsed"] = c(31.25, 31.89, 31.67, 31.23) + PEC_orig_M2["1", "TWAECsed"] = 31.57 # Later TWAEC not implemented + + expect_equal(res_M2$PEC[1:4, c(1, 2)], PEC_orig_M2[, c(1, 2)], tolerance = 0.01, scale = 1) + expect_equal(res_M2$PEC[1:4, c(3, 4)], PEC_orig_M2[, c(3, 4)], tolerance = 0.01, scale = 1) }) -- cgit v1.2.1