Page 1 of 1

read functions & time zones

Posted: Tue Oct 06, 2020 2:23 pm
by calvarezgarreton
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

Re: read functions & time zones

Posted: Tue Oct 06, 2020 3:36 pm
by calvarezgarreton
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

Re: read functions & time zones

Posted: Wed Oct 07, 2020 12:10 pm
by rchlumsk
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