read functions & time zones

Ask questions or report problems
calvarezgarreton
Posts: 2
Joined: Tue Oct 06, 2020 1:35 pm

read functions & time zones

Postby calvarezgarreton » Tue Oct 06, 2020 2:23 pm

Hi,
I am having problems with the reading functions and the time zones of the example data from The Nith river model (Raven Tutorial #2). Context: I am in Chile (Sys.timezone() = "America/Santiago").
While the hyd.read allows specifying the time zone of the input data, the forcings.read function does not and thus uses the local time zone. In southern hemisphere, the local time is different than the time zone of the example data and the conversion with as.POSIXct generates some NA values for some specific dates/hours. forcings.read.R line 11,12:

Code: Select all

date.time <- as.POSIXct(paste(watersheds$date, watersheds$hour), format = "%Y-%m-%d %H:%M:%S"))

These NA values generate error in forcings.read.R line 46:

Code: Select all

watersheds <- xts(order.by = date.time, x = watersheds)

I am able to avoid the error by editing the body of the forcings.read with trace("forcings.read", edit=TRUE) and manually change the time zone in line 12, but ideally users should be able to change it from the arguments of the function, just as with hyd.read(ff = NA, tzone = "").
Do you think it would be possible to add the tz argument to forcings.read.R function?
Thanks,
Camila

calvarezgarreton
Posts: 2
Joined: Tue Oct 06, 2020 1:35 pm

Re: read functions & time zones

Postby calvarezgarreton » Tue Oct 06, 2020 3:36 pm

Hi,
I am encountering the same time zone problem with the other read functions as well, e.g., watershed.read, custom.read. None of them allow time zone as input argument. Furthermore, the edits that I can do with trace+edit function are valid only for the current R session, and changes are disregarded for new sessions.
Do you have any suggestions on how to avoid this problem?
Thanks,
Camila

rchlumsk
Posts: 156
Joined: Fri Sep 16, 2016 3:18 pm

Re: read functions & time zones

Postby rchlumsk » Wed Oct 07, 2020 12:10 pm

Hi Camila

Thanks for the response. I think adding the tz argument to all the read functions and handle things the way the hyd.read function does makes the most sense. I will make that change and note it on Github in the dev_RC branch when I do.

https://github.com/rchlumsk/RavenR/issues/36

Thanks!
Rob
Robert Chlumsky
rchlumsk@uwaterloo.ca


Return to “Help & Support”