From 512cd50874b060d50a14d28df88018ac144cf6d3 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 7 Jul 2020 12:36:56 +0200 Subject: Remove copyright headers, update TOXSWA_cwa test - The window column of the windows component of a TOXSWA_cwa object is not a factor any more, but a character vector. - testthat::expect_equal_to_reference is replaced by testthat::expect_known_output, so we can have git diff show what has changed --- ChangeLog | 32 ++++++++++++++++++++++++++++++ DESCRIPTION | 2 +- R/FOMC_actual_twa.R | 17 ---------------- R/GUS.R | 17 ---------------- R/PEC_soil.R | 17 ---------------- R/PEC_sw_drainage_UK.R | 17 ---------------- R/PEC_sw_drift.R | 17 ---------------- R/PEC_sw_sed.R | 17 ---------------- R/SFO_actual_twa.R | 17 ---------------- R/SSLRC_mobility_classification.R | 17 ---------------- R/TOXSWA_cwa.R | 16 --------------- R/geomean.R | 17 ---------------- R/twa.R | 28 +++++--------------------- build.log | 5 ++--- man/pfm_degradation.Rd | 2 +- man/sawtooth.Rd | 2 +- test.log | 17 +++++----------- tests/testthat/H_sw_R1_stream_events.rds | Bin 334 -> 0 bytes tests/testthat/H_sw_R1_stream_events.txt | 0 tests/testthat/H_sw_R1_stream_windows.rds | Bin 235 -> 0 bytes tests/testthat/H_sw_R1_stream_windows.txt | 0 tests/testthat/test_TOXSWA.R | 6 +++--- 22 files changed, 50 insertions(+), 213 deletions(-) delete mode 100644 tests/testthat/H_sw_R1_stream_events.rds create mode 100644 tests/testthat/H_sw_R1_stream_events.txt delete mode 100644 tests/testthat/H_sw_R1_stream_windows.rds create mode 100644 tests/testthat/H_sw_R1_stream_windows.txt diff --git a/ChangeLog b/ChangeLog index c6701ea..874b9af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +commit 58c6214f459b28b899794f32a60836aef97ac01b +Author: Johannes Ranke +Date: 2020-07-07 11:27:44 +0200 + + Adapt pfm_degradation to current mkin + + use_of_ff = "max" is now the default + +commit e3bc264df69f892e9ad990be22d3ec1b22041daa +Author: Johannes Ranke +Date: 2020-06-17 13:37:59 +0200 + + TSCF estimation equations, update docs + + Briggs et al. (1982) and Dettenmaier et al. (2009) + +commit e505ecc4aba0f6719fd772faa2655dd824a6930d +Author: Johannes Ranke +Date: 2020-04-17 09:51:33 +0200 + + Skip testing on R-devel + + it currently fails with + + ✖ | 6 1 | Read and analyse TOXSWA cwa files [6.4 s] + ──────────────────────────────────────────────────────────────────────────────────────────────────── + test_TOXSWA.R:68: failure: Getting events and moving window analysis works + H_sw_R1_stream$windows has changed from known value recorded in 'H_sw_R1_stream_windows.rds'. + Component "window": Modes: character, numeric + Component "window": Attributes: < target is NULL, current is list > + Component "window": target is character, current is factor + commit d81550d0cccae824cc748de48e7fd50ea8d8033a Author: Johannes Ranke Date: 2020-04-16 18:02:18 +0200 diff --git a/DESCRIPTION b/DESCRIPTION index 8d0ebeb..e877629 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling Version: 0.5.7 -Date: 2020-06-17 +Date: 2020-07-07 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/R/FOMC_actual_twa.R b/R/FOMC_actual_twa.R index dc869b5..0ccf315 100644 --- a/R/FOMC_actual_twa.R +++ b/R/FOMC_actual_twa.R @@ -1,20 +1,3 @@ -# Copyright (C) 2018 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 - #' Actual and maximum moving window time average concentrations for FOMC kinetics #' #' @param alpha Parameter of the FOMC model diff --git a/R/GUS.R b/R/GUS.R index 4a6532d..040857a 100644 --- a/R/GUS.R +++ b/R/GUS.R @@ -1,20 +1,3 @@ -# 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 - #' Groundwater ubiquity score based on Gustafson (1989) #' #' The groundwater ubiquity score GUS is calculated according to diff --git a/R/PEC_soil.R b/R/PEC_soil.R index 541184f..b29ff13 100644 --- a/R/PEC_soil.R +++ b/R/PEC_soil.R @@ -1,20 +1,3 @@ -# Copyright (C) 2015,2016,2018,2019 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 - # Register global variables if(getRversion() >= '2.15.1') utils::globalVariables(c("destination", "study_type", "TP_identifier", "soil_scenario_data_EFSA_2015", diff --git a/R/PEC_sw_drainage_UK.R b/R/PEC_sw_drainage_UK.R index 3be4c97..d773f40 100644 --- a/R/PEC_sw_drainage_UK.R +++ b/R/PEC_sw_drainage_UK.R @@ -1,20 +1,3 @@ -# 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 initial predicted environmental concentrations in surface water due to drainage using the UK method #' #' This implements the method specified in the UK data requirements handbook and was checked against the spreadsheet diff --git a/R/PEC_sw_drift.R b/R/PEC_sw_drift.R index 261706c..6fcaecf 100644 --- a/R/PEC_sw_drift.R +++ b/R/PEC_sw_drift.R @@ -1,20 +1,3 @@ -# 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 diff --git a/R/PEC_sw_sed.R b/R/PEC_sw_sed.R index a4a3d6a..2865ab7 100644 --- a/R/PEC_sw_sed.R +++ b/R/PEC_sw_sed.R @@ -1,20 +1,3 @@ -# 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 sediment from surface #' water concentrations #' diff --git a/R/SFO_actual_twa.R b/R/SFO_actual_twa.R index 0d2015b..63a53f3 100644 --- a/R/SFO_actual_twa.R +++ b/R/SFO_actual_twa.R @@ -1,20 +1,3 @@ -# Copyright (C) 2015,2018 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 - #' Actual and maximum moving window time average concentrations for SFO kinetics #' #' @param DT50 The half-life. diff --git a/R/SSLRC_mobility_classification.R b/R/SSLRC_mobility_classification.R index 602f166..b78de98 100644 --- a/R/SSLRC_mobility_classification.R +++ b/R/SSLRC_mobility_classification.R @@ -1,20 +1,3 @@ -# Copyright (C) 2015,2018,2019 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 - #' Determine the SSLRC mobility classification for a chemical substance from its Koc #' #' This implements the method specified in the UK data requirements handbook and was diff --git a/R/TOXSWA_cwa.R b/R/TOXSWA_cwa.R index 5b1e8f2..42cdd35 100644 --- a/R/TOXSWA_cwa.R +++ b/R/TOXSWA_cwa.R @@ -1,19 +1,3 @@ -# Copyright (C) 2014,2015,2016,2017,2018 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 if(getRversion() >= '2.15.1') utils::globalVariables(c("cwa")) #' Read TOXSWA surface water concentrations diff --git a/R/geomean.R b/R/geomean.R index 04328c8..34c5caf 100644 --- a/R/geomean.R +++ b/R/geomean.R @@ -1,20 +1,3 @@ -# Copyright (C) 2015,2020 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 the geometric mean #' #' Based on some posts in a thread on Stackoverflow diff --git a/R/twa.R b/R/twa.R index 59fc73a..886351d 100644 --- a/R/twa.R +++ b/R/twa.R @@ -1,28 +1,10 @@ -# Copyright (C) 2016,2017 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 - #' Create a time series of decline data #' #' @param 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. \code{FOMC}, \code{parms} must contain the corresponding parameters. #' If x is an \code{\link{mkinfit}} object, the decline is calculated from this -#' object. +#' object. #' @param ini The initial amount. If x is an \code{\link{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 @@ -93,7 +75,7 @@ one_box.character <- function(x, ini = 1, parms, ..., t_out <- seq(0, t_end, by = res) pred <- mkinpredict(m, odeparms = parms, odeini = c(parent = ini), - outtimes = t_out, solution_type = "analytical")[-1] + outtimes = t_out, solution_type = "analytical")[, -1, drop = FALSE] result <- ts(pred, 0, t_end, frequency = 1/res) class(result) <- c("one_box", "ts") return(result) @@ -118,7 +100,7 @@ one_box.mkinfit <- function(x, ini = "model", ..., t_end = 100, res = 0.01) { else solution_type = "deSolve" tmp <- mkinpredict(fit$mkinmod, odeparms = fit$bparms.ode, odeini = odeini, - outtimes = t_out, solution_type = solution_type)[-1] + outtimes = t_out, solution_type = solution_type)[, -1, drop = FALSE] result <- ts(tmp, 0, t_end, frequency = 1/res) class(result) <- c("one_box", "ts") return(result) @@ -172,7 +154,7 @@ plot.one_box <- function(x, #' Create decline time series for multiple applications #' -#' If the application pattern is specified in \code{applications}, +#' If the application pattern is specified in \code{applications}, #' \code{n} and \code{i} are disregarded. #' @param x A \code{\link{one_box}} object #' @param n The number of applications. If \code{applications} is specified, \code{n} is ignored @@ -260,7 +242,7 @@ twa.one_box <- function(x, window = 21) #' for finding the maximum. It is therefore recommended to check this using #' \code{\link{plot.one_box}} using the window size for the argument #' \code{max_twa}. -#' +#' #' The method working directly on fitted \code{\link{mkinfit}} objects uses the #' equations given in the PEC soil section of the FOCUS guidance and is restricted #' SFO, FOMC and DFOP models and to the parent compound diff --git a/build.log b/build.log index e001d03..08c031a 100644 --- a/build.log +++ b/build.log @@ -6,8 +6,7 @@ Removed empty directory ‘pfm/inst/testdata/SwashProjects/Project_1/MACRO’ Removed empty directory ‘pfm/inst/testdata/SwashProjects/Project_1’ Removed empty directory ‘pfm/inst/testdata/SwashProjects’ -* looking to see if a ‘data/datalist’ file should be added NB: this package now depends on R (>= 3.5.0) - WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: 'pfm/data/EFSA_GW_interception_2014.RData' WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: 'pfm/data/EFSA_washoff_2017.RData' -* building 'pfm_0.5.7.tar.gz' + WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: ‘pfm/data/EFSA_GW_interception_2014.RData’ WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: ‘pfm/data/EFSA_washoff_2017.RData’ +* building ‘pfm_0.5.7.tar.gz’ diff --git a/man/pfm_degradation.Rd b/man/pfm_degradation.Rd index 6684fa4..81f2e81 100644 --- a/man/pfm_degradation.Rd +++ b/man/pfm_degradation.Rd @@ -7,7 +7,7 @@ pfm_degradation( model = "SFO", DT50 = 1000, - parms = c(k_parent_sink = log(2)/DT50), + parms = c(k_parent = log(2)/DT50), years = 1, step_days = 1, times = seq(0, years * 365, by = step_days) diff --git a/man/sawtooth.Rd b/man/sawtooth.Rd index 44ab2be..0850ded 100644 --- a/man/sawtooth.Rd +++ b/man/sawtooth.Rd @@ -23,7 +23,7 @@ is ignored} the corresponding amounts applied in the second column.} } \description{ -If the application pattern is specified in \code{applications}, +If the application pattern is specified in \code{applications}, \code{n} and \code{i} are disregarded. } \examples{ diff --git a/test.log b/test.log index 4744951..b8dbd2f 100644 --- a/test.log +++ b/test.log @@ -7,26 +7,19 @@ Testing pfm ⠏ | 0 | Simple PEC soil calculations ⠙ | 2 | Simple PEC soil calculations ✔ | 17 | Simple PEC soil calculations [0.3 s] ⠏ | 0 | Simple PEC surface water calculations with drift entry ✔ | 2 | Simple PEC surface water calculations with drift entry ⠏ | 0 | Actual and time weighted average concentrations for SFO kinetics ✔ | 1 | Actual and time weighted average concentrations for SFO kinetics - ⠏ | 0 | Read and analyse TOXSWA cwa files ⠋ | 1 | 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 ✖ | 6 1 | Read and analyse TOXSWA cwa files [6.4 s] -──────────────────────────────────────────────────────────────────────────────────────────────────── -test_TOXSWA.R:68: failure: Getting events and moving window analysis works -H_sw_R1_stream$windows has changed from known value recorded in 'H_sw_R1_stream_windows.rds'. -Component "window": Modes: character, numeric -Component "window": Attributes: < target is NULL, current is list > -Component "window": target is character, current is factor -──────────────────────────────────────────────────────────────────────────────────────────────────── + ⠏ | 0 | Read and analyse TOXSWA cwa files ⠋ | 1 | 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 [5.8 s] ⠏ | 0 | UK drainage PEC calculations ✔ | 12 | UK drainage PEC calculations ⠏ | 0 | Exposit calculations ✔ | 7 | Exposit calculations ⠏ | 0 | 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 [2.1 s] + ⠏ | 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 [0.9 s] ⠏ | 0 | Processing of residue series ✔ | 11 | Processing of residue series ⠏ | 0 | FOCUS Step 1 calculations ⠹ | 3 | FOCUS Step 1 calculations ✔ | 9 | FOCUS Step 1 calculations [0.1 s] ⠏ | 0 | FOCUS Steps 12 input files ✔ | 8 | FOCUS Steps 12 input files ══ Results ═════════════════════════════════════════════════════════════════════════════════════════ -Duration: 9.3 s +Duration: 7.4 s -OK: 81 -Failed: 1 +OK: 82 +Failed: 0 Warnings: 0 Skipped: 0 diff --git a/tests/testthat/H_sw_R1_stream_events.rds b/tests/testthat/H_sw_R1_stream_events.rds deleted file mode 100644 index ba6557b..0000000 Binary files a/tests/testthat/H_sw_R1_stream_events.rds and /dev/null differ diff --git a/tests/testthat/H_sw_R1_stream_events.txt b/tests/testthat/H_sw_R1_stream_events.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/testthat/H_sw_R1_stream_windows.rds b/tests/testthat/H_sw_R1_stream_windows.rds deleted file mode 100644 index 2531189..0000000 Binary files a/tests/testthat/H_sw_R1_stream_windows.rds and /dev/null differ diff --git a/tests/testthat/H_sw_R1_stream_windows.txt b/tests/testthat/H_sw_R1_stream_windows.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/testthat/test_TOXSWA.R b/tests/testthat/test_TOXSWA.R index de60d48..b011288 100644 --- a/tests/testthat/test_TOXSWA.R +++ b/tests/testthat/test_TOXSWA.R @@ -1,4 +1,3 @@ -library(pfm) context("Read and analyse TOXSWA cwa files") # zipfile_test = tempfile() @@ -61,9 +60,10 @@ test_that("A TOXSWA 5.5.3 out file is correctly read and printed", { 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") + expect_known_output(H_sw_R1_stream$events, file = "H_sw_R1_stream_events.txt") # Moving window analysis H_sw_R1_stream$moving_windows(c(7, 21)) - expect_equal_to_reference(H_sw_R1_stream$windows, file = "H_sw_R1_stream_windows.rds") + H_sw_R1_stream$windows + expect_known_output(H_sw_R1_stream$windows, file = "H_sw_R1_stream_windows.txt") }) -- cgit v1.2.1