RAWSmet data time offset
Sillson opened this issue · 2 comments
I believe the RAWSmet package assumes data for WRCC stations is returned in UTC format, when it actually may be supplied as LST (local standard time). The data appears to have a reverse offset (-0700) for stations in the PNW.
Example station: Agness, Oregon
WRCC URL to validate data: WRCC Site (then select Daily Summary)
R Code to pull data for Agness:
library(MazamaSpatialUtils)
library(RAWSmet)
library(dplyr)
library(lubridate)
wrcc_meta <-
wrcc_loadMeta(stateCode = "OR") %>%
dplyr::filter(stateCode == "OR")
agness <- wrcc_loadYear(wrccID = "orOAGN",
meta = wrcc_meta,
year = lubridate::year(lubridate::today("PDT")),
password = "YOURPWD")
# View datetime:
tail(agness$data$datetime, n=1)
# Eyeball data vs. WRCC
tail(agness$data, n=5)
The datetime column of the agness$data
tibble created assumes UTC. "2021-04-01 01:00:00 UTC"
, and when comparing with the values on the WRCC site, it appears the offset for the America/Los_Angeles timezone is being applied (-0700) to the already America/Los_Angeles timezone, which still wouldn't be UTC.
For example, at 9AM L.S.T., WRCC shows Fuel Moisture Mean Percent as 25.1 , and the RAWSMet package shows the same value with a datetime-stamp of 2021-04-01 01:00:00 UTC
. I would expect this value to be 2021-04-01 16:00:00 UTC
-- right?
Perhaps I'm missing something, but it seems there is a negative offset being placed on the datetime column.
The following code exists in wrcc_createTimeseriesObject.R
# * Convert datetime to UTC ----
UTC_offset <-
MazamaSpatialUtils::SimpleTimezones@data %>%
dplyr::filter(.data$timezone == meta$timezone) %>%
dplyr::pull("UTC_offset")
# NOTE: The 'datetime' column is "local standard time all-year-round" for
# NOTE: which no timezone exists. So we have to convert it first to UTC
# NOTE: and then shift it by the UTC offset.
UTC_time <-
MazamaCoreUtils::parseDatetime(data$datetime, timezone = "UTC") +
lubridate::dhours(UTC_offset)
data$datetime <- UTC_time
I wonder if The AGNESS station reports in UTC rather than LST?
I believe this issue has been resolved with the latest release.
Thank you @jonathancallahan !