diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2016-12-22 11:06:57 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2016-12-22 11:06:57 +0100 |
commit | bba2cf3a70849ba86f37520d3e909cf1c706f416 (patch) | |
tree | 57418b23b3da0ca1593ce842b3c8c90859636852 | |
parent | 5a04ad3061c1484b45703e44149f49ec97cfbf15 (diff) |
Fix reading in times from .out files
The code from the previous commit was broken. Also, the time
zone for the times that are read is now wet to 'UTC', in order to
avoid setting different time zones due to daylight savings, which
introduces artificial one-hour offsets on changeover days.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | DESCRIPTION | 2 | ||||
-rw-r--r-- | R/TOXSWA_cwa.R | 17 |
3 files changed, 28 insertions, 8 deletions
@@ -1,3 +1,20 @@ +commit 5a04ad3061c1484b45703e44149f49ec97cfbf15 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2016-12-14 16:52:14 +0100 + + 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. + +commit e51e063564bffcb75dbb6ab7a364704c8d8e992e +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2016-12-12 21:24:24 +0100 + + Fix reading .out for acronyms containing numbers + commit 9124e0f7d673c65584c1b2f838a3b944ea89c31d Author: Johannes Ranke <jranke@uni-bremen.de> Date: 2016-10-13 17:49:18 +0200 diff --git a/DESCRIPTION b/DESCRIPTION index 5c3d779..cfef009 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling Version: 0.3-9 -Date: 2016-12-12 +Date: 2016-12-22 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) Description: Utilities for simple calculations of predicted environmental diff --git a/R/TOXSWA_cwa.R b/R/TOXSWA_cwa.R index fcd070a..8de18a4 100644 --- a/R/TOXSWA_cwa.R +++ b/R/TOXSWA_cwa.R @@ -207,10 +207,11 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", cwa <- subset(cwa_all_segments, segment == self$segment, c("datetime", "t", "segment", "cwa", "cwa_tot")) lct <- Sys.getlocale("LC_TIME"); Sys.setlocale("LC_TIME", "C") - cwa$datetime <- strptime(cwa$datetime, "%d-%b-%Y-%H:%M") + cwa$datetime <- strptime(cwa$datetime, "%d-%b-%Y-%H:%M", tz = "UTC") Sys.setlocale("LC_TIME", lct) startyear = format(cwa$datetime[1], "%Y") - firstjan <- strptime(paste0(startyear, "-01-01"), "%Y-%m-%d") + firstjan <- strptime(paste0(startyear, "-01-01"), "%Y-%m-%d", + tz = "UTC") cwa$t_firstjan <- as.numeric(difftime(cwa$datetime, firstjan, units = "days")) @@ -262,15 +263,16 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", cwa <- data.frame( datetime = as.character(cwa_all_segments$X2), t = cwa_all_segments$X1, - cwa = cwa_all_segments[[3 + segment]] + cwa = cwa_all_segments[[3 + segment]], + stringsAsFactors = FALSE ) - # Append time "-00h00" to datetime if there is not time (only 11 characters) + # Append time "-00h00" to datetime if there is no 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), + datetime <- ifelse(nchar(datetime) == 11, paste0(datetime, "-00h00"), datetime)) @@ -280,11 +282,12 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", cwa$cwa_tot = cwa_tot_all_segments[[3 + segment]] } lct <- Sys.getlocale("LC_TIME"); Sys.setlocale("LC_TIME", "C") - cwa$datetime <- strptime(cwa$datetime, "%d-%b-%Y-%Hh%M") + cwa$datetime <- strptime(cwa$datetime, "%d-%b-%Y-%Hh%M", tz = "UTC") Sys.setlocale("LC_TIME", lct) startyear = format(cwa$datetime[1], "%Y") - firstjan <- strptime(paste0(startyear, "-01-01"), "%Y-%m-%d") + firstjan <- strptime(paste0(startyear, "-01-01"), "%Y-%m-%d", + tz = "UTC") cwa$t_firstjan <- as.numeric(difftime(cwa$datetime, firstjan, units = "days")) t_max = cwa[which.max(cwa$cwa), "t"] |