Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with read functions & time zones #36

Closed
calvarezgarreton opened this issue Oct 7, 2020 · 2 comments
Closed

Problem with read functions & time zones #36

calvarezgarreton opened this issue Oct 7, 2020 · 2 comments

Comments

@calvarezgarreton
Copy link

calvarezgarreton commented Oct 7, 2020

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. When the local time is different than the time zone of the example data, the conversion with as.POSIXct may generate some NA values at specific dates/hours.
forcings.read.R line 11,12:
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:
watersheds <- xts(order.by = date.time, x = watersheds)

The same time zone problem occurs with other read functions (e.g., watershed.read, custom.read) since they don't allow time zone as input argument. I am able to avoid the error by editing the body of the function with trace("forcings.read", edit=TRUE) and manually change the time zone in as.POSIXct arguments, but ideally users should be able to change it from the arguments of the function, just as with hyd.read(ff = NA, tzone = ""). 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 think it would be possible to add the tz argument to the *.read functions? Or do you have any suggestions on how may I permanently avoid this problem ?

Thanks, and congratulations for the great repository and modelling framework. Looking forward to implement the model in Chilean basins.
Camila

@rchlumsk
Copy link
Owner

rchlumsk commented Oct 7, 2020

Hi Camila

Thanks for reaching out and taking the time to flag this isue. As you point out, I think that simply including the tz argument in all of the read functions is the best way to achieve this. I am currently undertaking an update of the package on the dev_RC branch, so I will make those changes there in the short term. I will make a note here and close this issue once I do so. I might suggest that you use the dev_RC branch to rebuild the package for usage once I do so, which will hopefully address that (and other) issues.

Thanks again for the feedback, and please open more issues if you find any bugs or have suggestions! I will respond on the Raven forum as well.

Thanks,
Rob

rchlumsk added a commit that referenced this issue Oct 15, 2020
@rchlumsk
Copy link
Owner

Hi Camila, I have added time zone arguments to all of the read functions with the latest push to the dev_RC branch. This branch will replace the master branch by the end of the year. Let me know if you have nay further issues or comments, and thanks for starting this thread!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants