easysnowdata.stations.clients.DataBCClient#
- class easysnowdata.stations.clients.DataBCClient(timeout: int = 120, max_retries: int = 3, backoff: int = 5, session: Session | None = None)[source]#
Bases:
objectClient for BC snow survey data via BC Data Catalogue.
Provides access to both Automated Snow Weather Station (ASWS) data and Manual Snow Survey (MSS) data through publicly available BC government endpoints. Also provides access to ASWS station photos via the AQRT BCMOE portal.
- Parameters:
- get_asws_stations(active_only: bool = False) list[dict][source]#
Get Automated Snow Weather Station (ASWS) locations from WFS.
These are automated snow pillow stations that report daily SWE. Location IDs end in
P(e.g.1A01P).- Parameters:
active_only (
bool) – If True, filter to Active stations only.- Returns:
list[dict]– One dict per station with keys:location_id,name,elevation_m,latitude,longitude,status,operator,camera_url,station_type,station_url.
- get_mss_stations(active_only: bool = False) list[dict][source]#
Get Manual Snow Survey (MSS) site locations from WFS.
These are periodic manual snow course measurement sites. Location IDs do NOT end in
P(e.g.1A06A,1A10).- Parameters:
active_only (
bool) – If True, filter to Active sites only.- Returns:
list[dict]– One dict per site with keys:location_id,name,elevation_m,latitude,longitude,status,station_type,station_url.
- get_all_stations(active_only: bool = False, bbox: tuple[float, float, float, float] | None = None) list[dict][source]#
Get both ASWS and MSS stations.
- get_metadata(station_id: str) dict[source]#
Full metadata for a single station, including its variable inventory.
Combines the WFS station record with this client’s variable registry: ASWS stations share one CSV-file variable suite; MSS sites carry the periodic survey variables.
- get_data(station_ids: list[str] | str | None = None, variables: list[str] | str | None = None, bbox: tuple[float, float, float, float] | None = None, begin_date: str | None = None, end_date: str | None = None, interval: str = 'daily', include_flags: bool = False) list[dict][source]#
Standardized data fetch — returns a flat list of observation records.
For ASWS stations, daily SWE is sourced from
SWDaily.csv(16:00 UTC reading). For MSS stations, all survey variables are returned withinterval="periodic".- Parameters:
station_ids (
list[str]orstrorNone) – Location ID(s), e.g."1A01P"(ASWS) or"1A01"(MSS). Required unlessbboxis provided.variables (
list[str]orstrorNone) – DataBC variable keys (e.g."swe_mm") or standardized types (e.g."swe").Nonereturns all variables inVARIABLESavailable for the given station type.bbox (
tuple, optional) –(min_lon, min_lat, max_lon, max_lat).interval (
str) –"daily"fetches ASWS daily data (16:00 UTC canonical reading; SWE from the pre-aggregatedSWDaily.csv);"hourly"/"sub_daily"fetch all hourly ASWS readings (records carry adatetimekey);"periodic"fetches MSS survey data. Any other value raisesDataBCError.include_flags (
bool) – If True, MSS survey codes are included as"flag"field.
- Returns:
list[dict]–Flat list of observation records:
{ "station_id": "1A01P", "date": "2024-01-15", "variable": "swe_mm", "type": "swe", "value": 45.0, # mm ÷ 10 → cm for swe_mm "units": "cm", "interval": "daily", # "flag": None (only when include_flags=True) }
Notes
swe_mmvalues are converted to cm (÷ 10) in this method so that the returned"units"is always"cm"for type"swe".- Raises:
ValueError – If neither
station_idsnorbboxis provided.DataBCError – On network / data-loading failure.
- get_station_image_url(location_id: str) str | None[source]#
Get the station photo URL for an ASWS station from the AQRT BCMOE portal.
Scrapes
https://bcmoe-prod.aquaticinformatics.net(the public BC Ministry of Environment AQUARIUS Web Portal). The portal requires accepting a one-time disclaimer; this client does so lazily and reuses the session for subsequent calls.The returned URL is a direct
GetFileByIdlink that can be embedded in an<img>tag. ReturnsNoneif the station has no photo or the portal is unreachable.