## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", eval = FALSE)

## -----------------------------------------------------------------------------
# library(hydrocan)
# library(dplyr)

## -----------------------------------------------------------------------------
# hc_list_sources()

## -----------------------------------------------------------------------------
# stations <- hc_read_stations()
# stations
# 
# # Filter to a region
# stations |>
#   filter(latitude > 48, latitude < 50, longitude > -74, longitude < -72)

## -----------------------------------------------------------------------------
# # CEHQ station (natural river gauge) + Hydro-Quebec station (reservoir)
# daily <- hc_read_daily_flows(
#   station_id = c("023301", "3-230"),
#   start_date = Sys.Date() - 7,
#   end_date = Sys.Date()
# )
# 
# daily

## -----------------------------------------------------------------------------
# cehq_data <- hc_read_daily_flows(
#   station_id = c("023301", "030101"),
#   start_date = "2015-01-01",
#   end_date = "2020-12-31",
#   source = "cehq"
# )
# 
# hq_data <- hc_read_daily_flows(
#   station_id = "3-230",
#   start_date = Sys.Date() - 7,
#   end_date = Sys.Date(),
#   source = "hydroquebec"
# )
# 
# # Stack: works because the schema is identical
# all_flows <- bind_rows(cehq_data, hq_data)
# 
# all_flows |>
#   count(provider_name)

## -----------------------------------------------------------------------------
# daily |>
#   mutate(year = as.integer(format(date, "%Y"))) |>
#   group_by(station_id, provider_name, year) |>
#   summarise(
#     mean_flow = mean(value, na.rm = TRUE),
#     .groups = "drop"
#   ) |>
#   arrange(year, provider_name)

## -----------------------------------------------------------------------------
# hc_read_daily_flows(
#   station_id = c("023301", "030101", "040110"),
#   start_date = "2010-01-01",
#   end_date = "2023-12-31",
#   source = "cehq"
# )

