
Daily flow on FWA segments, by day of a common year
Source:R/wet_segment_daily.R
wet_segment_daily.RdReads mean flow per day of the year on Freshwater Atlas stream segments, by
source, from wet's published discharge/fwa/v1/segment_daily
(wet_catalog()): doy 1-365 on a common year, 29 February folded into 28
February. Each day is the mean flow on that day over the period, so
wet_flow_window() gives a window's flow from the days themselves
(basis = "daily") rather than from monthly means.
Usage
wet_segment_daily(
conn,
segments,
source = c("pcic_routed", "wet_balance"),
scenario = "historical",
groups = NULL,
catalog = NULL
)Arguments
- conn
NULL, or a DBI::DBIConnection to Postgres: the databasewet_db_load()wrote to forfrom = "published", fwapg forfrom = "fwapg".- segments
linear_feature_ids. Repeats are read once.- source
Any of
"pcic_routed"(PCIC's routed flow placed on the FWA) and"wet_balance"(wet's open water balance). Left out, every sourcefromholds: both for"published","pcic_routed"for"fwapg".- scenario
Scenario of the published product, e.g.
"historical". fwapg's run is"historical"only.- groups
Watershed group codes that hold the segments: required when reading the parts (no
conn), optional withconn. A segment outside them reads as missing.- catalog
For parts read without
conn: the output ofwet_catalog(), which is read whenNULL.
Value
data.frame(linear_feature_id, doy, q_m3s, source, pick), ordered
by source as given, segment as given and day. pick is logical, TRUE
where the source is the segment's default, as in wet_segment_monthly().
A segment with no value for a source has all 365 rows, with q_m3s and
pick NA.
What the days are
For wet_balance the days are its published months laid out with a
within-month shape fitted at HYDAT gauges (scripts/wb_shape_daily.R), so
the mean of a calendar month's days is the month wet_segment_monthly()
reads. For pcic_routed they are PCIC's routed day-of-year climatology,
placed on the FWA by fwapg and routed and clamped at zero day by day, so
where a clamp applied the mean of a month's days can sit above the
published month; and 28 February also carries 29 February's flow, which
the month weights by how often the period holds each day, so February's
plain day mean can sit above or below it. Neither has an annual row: month
0 is not the mean of the 365 days.
Where the values come from
From the Postgres table discharge.fwa_v1_segment_daily that
wet_db_load() writes when conn is given, otherwise from the parquet
parts the manifest lists, through duckdb. Each part holds one watershed
group, so a read of the parts needs groups and opens only those groups'
parts.
See also
wet_flow_window() for flow over month-day windows;
wet_segment_monthly() for monthly and annual flow.
Examples
if (FALSE) { # \dontrun{
# Buck Creek at its mouth, where gauge 08EE013 sits, from the published
# parts over HTTPS
q <- wet_segment_daily(NULL, 17094080, groups = "BULK")
wet_flow_window(q, wet_windows_calendar())
} # }