easysnowdata.stations.clients.AlbertaClient#
- class easysnowdata.stations.clients.AlbertaClient(base_url: str = 'https://rivers.alberta.ca', timeout: int = 120, max_retries: int = 3, backoff: int = 4, session: Session | None = None)[source]#
Bases:
objectClient for snow data on the Alberta River Basins site (rivers.alberta.ca).
No credentials are needed.
- Parameters:
base_url (
str) – Site root (https://rivers.alberta.ca).timeout (
int) – HTTP timeout in seconds.max_retries (
int) – Retry attempts on transient errors (5xx, network).backoff (
int) – Base backoff delay in seconds (delay = backoff × attempt).session (
requests.SessionorNone) – Optional pre-configured session.
- get_all_stations(active_only: bool = False, bbox: tuple[float, float, float, float] | None = None) list[dict][source]#
All ARB stations with automated or manual SWE / snow depth.
- Parameters:
- Returns:
list[dict]–station_id,name,latitude,longitude,elevation_m(alwaysNone: not published),status,source_status,state(AB/BC/MT/SK),operator,operator_code,measurement_method,has_swe,has_snwd,has_pillow_swe,has_survey,begin_date,end_date,parametersandstation_url. Stations without coordinates are dropped whenbboxis given.- Raises:
AlbertaError – On a catalog query failure.
- get_metadata(station_id: str) dict[source]#
Metadata and series inventory for one station.
- Parameters:
station_id (
str) – ARB station number, e.g."05BB803".- Returns:
dict– Theget_all_stations()dict plusdata_variables(one entry per parameter × supported interval) withname,type,interval,units(emitted),description,notes,begin_date,end_dateandn_obs(None), plus the WISKIts_id/ts_name. Dates are MST.- Raises:
AlbertaError – If the station is not a snow station in the ARB catalog.
- download_series(ts_id: str, begin_date: str, end_date: str) tuple[dict, list[tuple[datetime, Any]]][source]#
Raw WISKI download for one time series.
- Parameters:
- Returns:
tuple[dict,list[tuple[datetime,Any]]]–(header, rows);headeris the download’s metadata (station_no,stationparameter_name,ts_name, …) and rows are(naive MST datetime, raw value)in native units.- Raises:
AlbertaError – On a failed request (HTTP 500 for an unknown
tsId) or an unexpected payload.
- 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 | date | None = None, end_date: str | date | None = None, interval: str = 'daily', include_flags: bool = False) list[dict][source]#
Standardized data fetch — returns a flat list of observation records.
- Parameters:
station_ids (
list[str]orstrorNone) – ARB station numbers, e.g."05BB803". Required unlessbboxis given.variables (
list[str]orstrorNone) – Native parameters ("SW","SW-SS") or standardized types ("swe"). A type resolves to the parameters available atinterval(swe→SWfor daily/hourly,SW-SSfor periodic).None= snow only.bbox (
tuple, optional) –(min_lon, min_lat, max_lon, max_lat).begin_date (
strordate, optional) – InclusiveYYYY-MM-DDbounds in MST. Default: the series’ first value / today.end_date (
strordate, optional) – InclusiveYYYY-MM-DDbounds in MST. Default: the series’ first value / today.interval (
str) –"daily"(default),"hourly","sub_hourly"or"periodic". See the module docstring for conventions.include_flags (
bool) – Addflag(alwaysNone: the source has no flags).
- Returns:
list[dict]–{station_id, date, variable, type, value, units, interval}(+datetimeISO 8601 with-07:00for hourly/sub_hourly). Unknown stations and failed downloads are logged and skipped; parameters a station does not have are skipped silently.- Raises:
ValueError – If neither
station_idsnorbboxis given.AlbertaError – On an unknown variable or unsupported interval.
Example
>>> client = AlbertaClient() >>> records = client.get_data( ... station_ids="05BB803", ... variables=["swe"], ... begin_date="2026-03-01", ... end_date="2026-03-15", ... ) >>> records[0]["units"] 'cm'
Examples using easysnowdata.stations.clients.AlbertaClient#
Alberta snow pillows and snow courses (Alberta River Basins)