diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2018-06-11 16:27:22 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2018-06-11 16:27:22 +0200 |
commit | cac29c8c1cc0f6004ef0cd63229cfb993a24496c (patch) | |
tree | cb24081e119a15162425872b2a9f32a31720d303 /R | |
parent | bd15236d5dedb4067bd29e58e655c5352aca1db4 (diff) |
Adapt to TOXSWA 5.5.3
Diffstat (limited to 'R')
-rw-r--r-- | R/TOXSWA_cwa.R | 18 |
1 files changed, 13 insertions, 5 deletions
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) |