
Daily flow at hydrometric stations, from HYDAT through to the present
Source:R/wet_station_daily.R
wet_station_daily.RdOne daily discharge series per station. Approved HYDAT flows come first; after HYDAT's last approved day, ECCC provisional daily means fill in, and the real-time feed covers the days since. Each day keeps the source it came from and its HYDAT symbol, so a result built on the series can say what it rests on (ice-affected winter flows are estimates).
Arguments
- stations
Character vector of station numbers: HYDAT's (
"08EE013"), the provincial network's ("08EE0001"), a Water Tool gauge's ("HRB3142") or a Hakai watershed's ("WTS693"), mixed freely.- hydat
Path to the HYDAT sqlite database. Defaults to tidyhydat's download location.
- from, to
Optional first and last date (a
Dateor a stringas.Date()reads).NULLmeans no bound.- sources
Which sources to read, from
"hydat","provisional","realtime","bcenv","bcwatertool"and"hakai". The first three read HYDAT-numbered stations only, and each continues the one before it, per station, from that source's last day over its whole record: provisional days are used only after HYDAT's last day, and real-time days only after both, whateverfromandtoare."provisional"reads the water-temp-bc archive of ECCC daily means (optionwet.provisional_root, defaults3://water-temp-bc/data/canonical/Parameter=6/) with duckdb, and"realtime"callstidyhydat::realtime_ws()for the days after the other sources end (at most about 18 months back)."bcenv"reads the provincial network's stations named insnapshot's station registry, from the province's hourly files (Open Government Licence - British Columbia), with duckdb: a day is a local-standard-time day with at least 20 hours, hours graded Unusable left out, and a day above a plausibility bound measured on HYDAT dropped."bcwatertool"reads the Water Tool's third-party gauges from a pinned snapshot of its daily files (the terms each publisher's file states, given ascreditbywet_station_list()): a day as the Tool gives it, a day above the same bound (its sub-drainage taken from the nearest HYDAT station) dropped; and the days of a Tool gauge at a provincial station's site before that station's record begins, under the provincial number."hakai"reads Hakai Institute's published discharge package (Korver et al., doi:10.21966/J99C-9C14 , CC-BY 4.0) for its own four watersheds' days, 2013 to 2019, and for the days, 2014 to 2019, before three Calvert and Hecate island stations' provincial records begin, under the provincial number: a day is a Pacific Standard Time day with at least 20 of Hakai's hourly means, a day above the same bound dropped. Its file is fetched once from the package's pinned commit and kept in wet's cache. A station's own source comes first, and a second publisher's gauge at its site only for the days before it.- snapshot
The provincial snapshot to read, as
YYYYMMDD; each pinned snapshot's files are held to md5s tracked in the package. Read only for stations that are not HYDAT-numbered. The Water Tool's snapshot is the one the package pins; a number both its registry andsnapshot's hold is refused.
Value
data.frame(station_number, date, q_m3s, symbol, source, status),
one row per station-day that has a flow, ordered by station and date.
symbol is HYDAT's daily symbol ("B" ice, "E" estimated, "A"
partial day, "D" dry) or NA. status is "approved" for HYDAT and
for an ECCC day whose approval says final, and "provisional" for any
other ECCC day. A provincial day is "provisional" when every hour in it
carries a grade and "unchecked" when any hour is graded Undefined or
Unspecified: the province's files carry no approval, so none is
"approved". A Water Tool day is "provisional" where the Tool marks it
quality checked and "unchecked" where it does not. A Hakai day is
"approved" where Hakai accepted every hour of it after quality control
(Hakai's approval, not Water Survey of Canada's) and "provisional"
otherwise. Provisional, provincial, Tool and Hakai days carry no ice
symbol, so their NA means "not recorded", not "open water".
A gap between the end of one source and the start of the next (for
example an old HYDAT ending before the provisional archive begins) is
left unfilled and reported with a warning when it overlaps from-to. A source that fails is skipped
with a warning and the others are returned.
Details
Stations of the province's non-integrated hydrometric network (numbers such
as "08EE0001", listed by wet_station_list()) are read from a pinned
snapshot of the province's hourly files instead. Such a station keeps its
own number: where it sits at a HYDAT station's site, the two records are not
joined, and wet_station_list() names the HYDAT station so a caller can.
The third-party gauges the BC Water Tool serves (regional districts,
industry, BC Hydro, research projects; numbers such as "HRB3142" or
"ogc_1002", listed by wet_station_list()) are read from a pinned
snapshot of the Tool's daily files. Where such a gauge sits at a provincial
station's site, its record continues the provincial one instead: its days
before the provincial record begins (the first day the province's files hold
any hour of the station) come back under the provincial number, with
source "bcwatertool", and none from that day on. Hakai Institute's
published package does the same for three Calvert and Hecate island
watersheds (H08KC0626, H08KC0703 and H08KC0844): its days from 2014 to
2019 come back under the provincial number with source "hakai". Its
other four watersheds are stations of their own, read under the package's
numbers ("WTS693", "WTS708", "WTS819", "WTS1015"). Each station's
regulation, natural, regulated or unknown, is wet_station_list()'s
regulation.
Ported from ngr::ngr_hyd_q_daily(), which joined HYDAT with about 18
months of real-time flow.
Examples
if (FALSE) { # \dontrun{
# Buck Creek at the mouth, from the start of its record to last week
q <- wet_station_daily("08EE013")
table(q$source, q$status)
# Deep Creek, a provincial station near Smithers
d <- wet_station_daily("08EE0001")
table(d$source, d$status)
# Rosewall Creek on Vancouver Island: the province's years from 2021, and
# BC Conservation Foundation's 2012-2015 gauge at the site before them
r <- wet_station_daily("08HB0008")
table(format(r$date, "%Y"), r$source)
# Calvert Island Watershed 626: Hakai's published years, 2014-2019, then the
# province's from 2021
k <- wet_station_daily("H08KC0626", sources = c("bcenv", "hakai"))
table(format(k$date, "%Y"), k$source)
} # }