bluegreen-labs / snotelr

a snow data network (SNOTEL) R package
https://bluegreen-labs.github.io/snotelr/
GNU Affero General Public License v3.0
15 stars 10 forks source link

Metric conversion of snow depth may be incorrect #35

Open realmiketalbot opened 4 days ago

realmiketalbot commented 4 days ago

I was just examining some data and noticed that the snow_depth values returned appear to be off by an order of magnitude. For example, look at the depths reported here on 2024-03-15 (81 inches = 2,057 mm) and compare it with the result of the below, which is 206:

library(tidyverse)
library(snotelr)

snotel_site_id <- "335"
start_date <- as_date("2024-03-15")
end_date <- as_date("2024-09-30")

# Download site data
snotel_download(site_id = snotel_site_id, internal = TRUE) %>%
  as_tibble() %>%
  mutate(date = as_date(date)) %>%
  filter(date == as_date("2024-03-15")) %>%
  select(date, snow_depth)

I haven't looked at this in detail, but I wonder if the raw snow depth values are returned in tenths of an inch. For my purposes, I can make this assumption for now, but I thought I'd raise the issue since it appears there's currently a discrepancy between the units being reported for SWE (mm) and depth (potentially cm) and it isn't documented.

khufkens commented 3 days ago

Thanks for highlighting this, I assumed this would be simple inches as with the precip. values sigh. Seriously, they should stick to metric already. I'll double check the units.

khufkens commented 3 days ago

Ok, to make matters worse. Reporting is done in a mix of imperial and metric. I can confirm that when data is reported as metric the output is in cm. When in inches I convert to mm. So I'll have to add another routine to trap the inconsistencies.

khufkens commented 3 days ago

@realmiketalbot

Fixed per https://github.com/bluegreen-labs/snotelr/commit/4998e942f9c2cd1261709ca72a19d5c02dd2f1dd

You can install from github to double check. If you validate I'll push to CRAN.