aboutsummaryrefslogtreecommitdiff
path: root/R/TOXSWA_cwa.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2016-12-14 16:52:14 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2016-12-14 16:52:14 +0100
commit5a04ad3061c1484b45703e44149f49ec97cfbf15 (patch)
treed61a3d5107cdcbc361f627c83e9e72c9db4a2d2f /R/TOXSWA_cwa.R
parente51e063564bffcb75dbb6ab7a364704c8d8e992e (diff)
Set time correctly for 00:00 hours in .out file
For ConLiqWatLayCur_xxxxx entries which are output at 00:00 (midnight), no time is listed in the .out file for this time. This commit introduces a workaround, setting the time to 00:00 when there is no time information.
Diffstat (limited to 'R/TOXSWA_cwa.R')
-rw-r--r--R/TOXSWA_cwa.R15
1 files changed, 10 insertions, 5 deletions
diff --git a/R/TOXSWA_cwa.R b/R/TOXSWA_cwa.R
index 45189f8..fcd070a 100644
--- a/R/TOXSWA_cwa.R
+++ b/R/TOXSWA_cwa.R
@@ -254,11 +254,6 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa",
cwa_all_segments <- read_fwf(paste(cwa_lines, collapse = "\n"),
fwf_empty(paste(tail(cwa_lines), collapse = "\n")))
- # Append time "-00h00" to datetime in first row, as this is not (always?) present
- # in the line ConLiqWatLayCur
- if (nchar(cwa_all_segments[1, "X2"]) == 11) {
- cwa_all_segments[1, "X2"] = paste0(cwa_all_segments[1, "X2"], "-00h00")
- }
available_segments = 1:(ncol(cwa_all_segments) - 3)
if (segment == "last") segment = max(available_segments)
@@ -269,6 +264,16 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa",
t = cwa_all_segments$X1,
cwa = cwa_all_segments[[3 + segment]]
)
+
+ # Append time "-00h00" to datetime if there is not time (only 11 characters)
+ # The fact that the time is missing at 00h00 was reported to Mark
+ # Liedekerke, Wim Beltman, Paulien Adriaanse, and Chris Lythgo
+ # on 14 December 2016
+ cwa <- within(cwa,
+ datetime <- ifelse(nchar(datetime == 11),
+ paste0(datetime, "-00h00"),
+ datetime))
+
if (total) {
cwa_tot_lines <- outfile[grep("ConSysWatLay_", outfile)] # hourly total conc.
cwa_tot_all_segments <- read.table(text = cwa_lines)

Contact - Imprint