Skip to contents

One daily water-temperature series per station, from the ECCC readings that water-temp-bc archives (about 340 BC stations, mostly hourly, from 2002), and from small-stream logger records wet pins (see "Logger records" below). Readings are reduced to a daily mean, minimum and maximum in the station's local standard time. The result has the shape of wet_station_daily(), so it feeds wet_window_stats() with value = "t_mean_c" (or t_min_c, t_max_c), level_anomaly = "absolute" and unit = "degC", and from there cd::cd_baseline(), cd::cd_anomaly() and cd::cd_trend().

Usage

wet_temp_daily(
  stations,
  from = NULL,
  to = Sys.Date(),
  valid = c(-1, 35),
  min_hours = 20,
  sources = c("provisional", names(wet_logger_versions))
)

Arguments

stations

Character vector of station numbers: HYDAT numbers ("08EE013") as water-temp-bc archives them, or logger ids ("NHG_01FW007").

from, to

Optional first and last date (a Date or a string as.Date() reads). NULL means no bound.

valid

Plausible range of a reading, in degrees C, both ends kept.

min_hours

Hours of the day (1 to 24) that must have a valid reading for the day to count.

sources

Which sources to read: "provisional", the ECCC archive, and the logger series codes ("nhg"). An id whose source is not named returns no days.

Value

data.frame(station_number, date, t_mean_c, t_min_c, t_max_c, n_hours, source, status), one row per station-day kept, ordered by station and date: the shape of wet_station_daily() with temperature columns in place of q_m3s, and no symbol. There is no ice flag, so wet_window_stats() reports frac_ice as NA, unknown, not zero. source is "provisional", the water-temp-bc archive, as in wet_station_daily(), or a logger day's series code ("nhg"), whose status is "provisional". status is "approved" only when every reading that day is final. No reading in the archive was final on 2026-10-06: its approvals are ECCC's codes 1 and 4, whose meanings were never published with the dump and are treated as provisional, none, or Provisional/Provisoire. The archive is read from option wet.temp_root (default s3://water-temp-bc/data/canonical/Parameter=5/) with duckdb.

How readings become days

  1. Readings outside valid are dropped: ECCC's sentinels (99999, 999, 99.9, -99999) and readings of a sensor in air or ice. A range cannot catch a logger out of the water in summer, when air and water temperatures overlap.

  2. Each reading is placed in its hour and day of local standard time (no daylight saving), from the station's offset in tidyhydat::allstations (UTC-8 for most BC stations, UTC-7 for the Peace and parts of the Kootenays). A station that table does not list is taken as UTC-8, with a warning. UTC days would split the afternoon maximum, which falls near 00:00 UTC.

  3. Readings are averaged within each hour, and t_mean_c is the mean of those hourly means, so a 15-minute hour does not outweigh an hourly one. t_min_c and t_max_c are over the readings themselves.

  4. A day is kept only when it has readings in at least min_hours of its 24 hours. Short days are dropped, not filled; n_hours is returned so a caller can be stricter.

Logger records

An id listed in a logger registry is read from that series' pinned files instead of the ECCC archive; every other id goes to the archive. The first series is UNBC's Northern Hydrometeorology Group's Nechako loggers (32 sites, 2019-2024, 15-minute readings, CC BY 4.0, Zenodo record 15053907), ids "NHG_<site code>". List a series' sites, with coordinates, credit and the sub-drainage that pools a logger with its ECCC neighbours in wet_temp_fill(), from its registry: read.csv(system.file("extdata", "temp_loggers", "nhg_15053907_sites.csv", package = "wet")). The files are fetched once per machine into tools::R_user_dir("wet", "cache") and held to their published checksums.

Logger days follow the steps above (with the readings' own clock), and three more rules screen what a gauge does not need screening for, in this order: runs of identical hourly means above 0.5 degrees C lasting more than 154 hours in May-September (a stuck sensor) are dropped before the hour rule; the first and last day of each deployment (readings with no gap over 6 hours) are dropped; and a May-September day whose range of hourly means exceeds its month's threshold (12.09 to 18.38 degrees C) is dropped as a logger reading air. The thresholds were measured on the ECCC archive and are registered in research/station_water_temperature.md. A series that cannot be read is skipped with a warning.

Baseline

Year-round records are short: few stations have most of their days in most years of any decade before the 2010s. A temperature departure is therefore taken against the recent decade, 2016-2025, never 1981-2010, and has to say so beside any flow departure on 1981-2010. The station counts behind that are in research/station_water_temperature.md.

With wet_window_stats()

Pass stats explicitly. frac_below needs a threshold in degrees C, and cov_day (when half a window's total has passed) means nothing for a temperature. One call takes one value column, so a window's highest daily maximum is a second call on t_max_c.

Examples

if (FALSE) { # \dontrun{
# Buck Creek at the mouth, since 2016
t <- wet_temp_daily("08EE013", from = "2016-01-01")
summary(t$t_max_c)

# Over the Chinook spawning window, one value per year: the mean of daily
# means, and the highest daily maximum
w <- data.frame(window = "ch_spawning", start = "08-01", end = "09-15")
s <- rbind(
  wet_window_stats(t, w, stats = "mean", value = "t_mean_c", prefix = "t",
                   level_anomaly = "absolute", unit = "degC"),
  wet_window_stats(t, w, stats = "max", value = "t_max_c", prefix = "tmax",
                   level_anomaly = "absolute", unit = "degC"))

# Departure in degrees C from 2016-2025, one series per cd call
m <- s[s$variable == "t_mean", ]
cd::cd_anomaly(m, cd::cd_baseline(m, 2016:2025))

# A small-stream logger, Otter Creek below Finger Lake in the Nechako
# (fetched once, 14 MB, from Zenodo)
o <- wet_temp_daily("NHG_01FW007", sources = "nhg")
range(o$date)
} # }