From cac29c8c1cc0f6004ef0cd63229cfb993a24496c Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 11 Jun 2018 16:27:22 +0200 Subject: Adapt to TOXSWA 5.5.3 --- ChangeLog | 9 +++++++++ DESCRIPTION | 4 ++-- R/TOXSWA_cwa.R | 18 +++++++++++++----- build.log | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ea31a7..926bcd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +commit bd15236d5dedb4067bd29e58e655c5352aca1db4 +Author: Johannes Ranke +Date: 2018-06-08 16:20:40 +0200 + + Enable PEC porewater for the default scenario + + The default scenario uses soil parameters from the REACH guidance R.16, + Table R.16-9. + commit ec2052d68950745380c2724757b3ba8b116605fc Author: Johannes Ranke Date: 2018-06-08 14:54:40 +0200 diff --git a/DESCRIPTION b/DESCRIPTION index 96aea24..0851224 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling -Version: 0.4-5 -Date: 2018-06-08 +Version: 0.4-6 +Date: 2018-06-11 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/TOXSWA_cwa.R b/R/TOXSWA_cwa.R index 4caafb6..576c7d3 100644 --- a/R/TOXSWA_cwa.R +++ b/R/TOXSWA_cwa.R @@ -259,17 +259,25 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", stop("Could not read ", filename) } } else { - # out file from FOCUS TOXSWA 4 (TOXSWA 4.4.2 or similar) + # out file from FOCUS TOXSWA 4 or higher outfile <- try(readLines(file_connection)) + focus_toxswa_version <- gsub(".*: ", "", outfile[4]) + + if (substr(focus_toxswa_version, 1, 1) == "3") { + cwastring = "ConLiqWatLayCur" + } else { + cwastring = "ConLiqWatLay" + } + close(file_connection) # only needed for files if (inherits(outfile, "try-error")) { stop("Could not read ", filename) } else { # Get the substance name(s) - sub_lines <- grep(".*0.000.*ConLiqWatLayCur_", outfile[1:50], value = TRUE) - substances <- gsub(".*ConLiqWatLayCur_(.*?) +[0-9].*", "\\1", sub_lines) + sub_lines <- grep(paste0(".*0.000.*", cwastring, "_"), outfile[1:50], value = TRUE) + substances <- gsub(paste0(".*", cwastring, "_(.*?) +[0-9].*"), "\\1", sub_lines) if (!substance %in% c("parent", substances)) { stop("No data for substance ", substance, " present in the .out file.") } @@ -277,9 +285,9 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", # Generate field name for the concentrations at end of hour for the # substance of interest if (substance == "parent") { - cwa_string = paste0("ConLiqWatLayCur_", substances[1]) + cwa_string = paste0(cwastring, "_", substances[1]) } else { - cwa_string = paste0("ConLiqWatLayCur_", substance) + cwa_string = paste0(cwastring, "_", substance) } cwa_lines <- grep(cwa_string, outfile, value = TRUE) diff --git a/build.log b/build.log index 95a265b..ea12067 100644 --- a/build.log +++ b/build.log @@ -4,5 +4,5 @@ * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories * looking to see if a ‘data/datalist’ file should be added -* building ‘pfm_0.4-5.tar.gz’ +* building ‘pfm_0.4-6.tar.gz’ -- cgit v1.2.1