aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/DESCRIPTION8
-rw-r--r--pkg/NAMESPACE1
-rw-r--r--pkg/R/TOXSWA_cwa.R2
-rw-r--r--pkg/tests/testthat/H_sw_D4_pond.rdsbin244540 -> 0 bytes
-rw-r--r--pkg/tests/testthat/H_sw_D4_pond_printed.txt10
-rw-r--r--pkg/tests/testthat/H_sw_R1_stream_events.rdsbin332 -> 334 bytes
-rw-r--r--pkg/tests/testthat/H_sw_R1_stream_printed.txt10
-rw-r--r--pkg/tests/testthat/H_sw_R1_stream_windows.rdsbin234 -> 235 bytes
-rw-r--r--pkg/tests/testthat/test_TOXSWA_cwa.R39
9 files changed, 56 insertions, 14 deletions
diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION
index 5c3050c..f24b6bf 100644
--- a/pkg/DESCRIPTION
+++ b/pkg/DESCRIPTION
@@ -2,12 +2,14 @@ Package: pfm
Type: Package
Title: Utilities for Pesticide Fate Modelling
Version: 0.2-3
-Date: 2015-07-02
+Date: 2015-08-21
Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de",
role = c("aut", "cre", "cph"))
-Description: Utilities for simple PEC calculations and for dealing with data
- from some FOCUS pesticide fate modelling software.
+Description: 'pfm' contains utilities for simple calculations of predicted
+ environmental concentrations (PECs) and for dealing with data from some FOCUS
+ pesticide fate modelling software packages.
Depends: R6, mkin
+Imports: graphics
Suggests: testthat
License: GPL
LazyLoad: yes
diff --git a/pkg/NAMESPACE b/pkg/NAMESPACE
index 0613a5c..cd2f08b 100644
--- a/pkg/NAMESPACE
+++ b/pkg/NAMESPACE
@@ -13,5 +13,6 @@ export(TOXSWA_cwa)
export(geomean)
export(pfm_degradation)
export(read.TOXSWA_cwa)
+import(graphics)
import(mkin)
importFrom(R6,R6Class)
diff --git a/pkg/R/TOXSWA_cwa.R b/pkg/R/TOXSWA_cwa.R
index 7fd8ec1..9f729e5 100644
--- a/pkg/R/TOXSWA_cwa.R
+++ b/pkg/R/TOXSWA_cwa.R
@@ -58,6 +58,7 @@ read.TOXSWA_cwa <- function(filename, basedir = ".", zipfile = NULL,
#' Plot TOXSWA hourly concentrations of a chemical substance in a specific
#' segment of a segment of a TOXSWA surface water body.
#'
+#' @import graphics
#' @param x The TOXSWA_cwa object to be plotted.
#' @param xlab,ylab Labels for x and y axis.
#' @param time_column What should be used for the time axis. If "t_firstjan" is chosen,
@@ -171,6 +172,7 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa",
}
cwa_all_segments <- try(read.table(file_connection,
sep = "", skip = 40,
+ encoding = "UTF-8",
colClasses = c("character", "numeric",
"integer", rep("numeric", 5)),
col.names = c("datetime", "t", "segment",
diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds
deleted file mode 100644
index 62c54bc..0000000
--- a/pkg/tests/testthat/H_sw_D4_pond.rds
+++ /dev/null
Binary files differ
diff --git a/pkg/tests/testthat/H_sw_D4_pond_printed.txt b/pkg/tests/testthat/H_sw_D4_pond_printed.txt
new file mode 100644
index 0000000..5730be6
--- /dev/null
+++ b/pkg/tests/testthat/H_sw_D4_pond_printed.txt
@@ -0,0 +1,10 @@
+<TOXSWA_cwa> data from file 00001p_pa.cwa segment 1
+ datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L
+1 1985-01-01 00:00:00 0.000 0.00000000 -396.167 0.00000000 0.00000000
+2 1985-01-01 01:00:00 0.042 0.04166667 -396.125 0.08323064 0.08323716
+3 1985-01-01 02:00:00 0.083 0.08333333 -396.084 0.16626900 0.16628210
+4 1985-01-01 03:00:00 0.125 0.12500000 -396.042 0.24911240 0.24913190
+5 1985-01-01 04:00:00 0.167 0.16666667 -396.000 0.33172050 0.33174650
+6 1985-01-01 05:00:00 0.208 0.20833333 -395.959 0.41401430 0.41404670
+Moving window analysis
+NULL
diff --git a/pkg/tests/testthat/H_sw_R1_stream_events.rds b/pkg/tests/testthat/H_sw_R1_stream_events.rds
index 842c5de..ba6557b 100644
--- a/pkg/tests/testthat/H_sw_R1_stream_events.rds
+++ b/pkg/tests/testthat/H_sw_R1_stream_events.rds
Binary files differ
diff --git a/pkg/tests/testthat/H_sw_R1_stream_printed.txt b/pkg/tests/testthat/H_sw_R1_stream_printed.txt
new file mode 100644
index 0000000..572ad6d
--- /dev/null
+++ b/pkg/tests/testthat/H_sw_R1_stream_printed.txt
@@ -0,0 +1,10 @@
+<TOXSWA_cwa> data from file 00003s_pa.cwa segment 20
+ datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L
+20 1978-10-01 00:00:00 0.000 273.0000 -55.333 0 0
+40 1978-10-01 01:00:00 0.042 273.0417 -55.291 0 0
+60 1978-10-01 02:00:00 0.083 273.0833 -55.250 0 0
+80 1978-10-01 03:00:00 0.125 273.1250 -55.208 0 0
+100 1978-10-01 04:00:00 0.167 273.1667 -55.166 0 0
+120 1978-10-01 05:00:00 0.208 273.2083 -55.125 0 0
+Moving window analysis
+NULL
diff --git a/pkg/tests/testthat/H_sw_R1_stream_windows.rds b/pkg/tests/testthat/H_sw_R1_stream_windows.rds
index 29e13f2..2531189 100644
--- a/pkg/tests/testthat/H_sw_R1_stream_windows.rds
+++ b/pkg/tests/testthat/H_sw_R1_stream_windows.rds
Binary files differ
diff --git a/pkg/tests/testthat/test_TOXSWA_cwa.R b/pkg/tests/testthat/test_TOXSWA_cwa.R
index 582c51e..407a7a1 100644
--- a/pkg/tests/testthat/test_TOXSWA_cwa.R
+++ b/pkg/tests/testthat/test_TOXSWA_cwa.R
@@ -1,20 +1,37 @@
library(pfm)
context("Read and analyse TOXSWA cwa files")
-test_that("TOXSWA cwa file is correctly read", {
- H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa",
- basedir = "SwashProjects/project_H_sw/TOXSWA",
- zipfile = system.file("testdata/SwashProjects.zip",
- package = "pfm"))
- H_sw_D4_pond$zipfile <- NULL # do not test the path
- expect_equal_to_reference(H_sw_D4_pond, file = "H_sw_D4_pond.rds")
+zipfile_test = system.file("testdata/SwashProjects.zip", package = "pfm")
+basedir_test = "SwashProjects/project_H_sw/TOXSWA"
+
+H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa",
+ basedir = basedir_test,
+ zipfile = zipfile_test)
+
+H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa",
+ basedir = basedir_test,
+ zipfile = zipfile_test)
+
+
+test_that("TOXSWA cwa file is correctly read and printed", {
+
+ # This was the setting when printing the output into text files
+ options(width = 100)
+
+ # Most content of the R6 object is at least partially printed
+
+ H_sw_D4_pond_printed <- capture.output(print(H_sw_D4_pond))
+
+ expect_equal(H_sw_D4_pond_printed, readLines("H_sw_D4_pond_printed.txt"))
+
+ H_sw_R1_stream_printed <- capture.output(print(H_sw_R1_stream))
+ expect_equal(H_sw_R1_stream_printed, readLines("H_sw_R1_stream_printed.txt"))
+
+ # The basedir is not printed, therefore tested separately
+ expect_equal(H_sw_D4_pond$basedir, basedir_test)
})
test_that("Getting events and moving window analysis works", {
- H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa",
- basedir = "SwashProjects/project_H_sw/TOXSWA",
- zipfile = system.file("testdata/SwashProjects.zip",
- package = "pfm"))
# Event analysis with two different thresholds
H_sw_R1_stream$get_events(c(2, 10))

Contact - Imprint