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: object

Client 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.Session or None) – 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:
  • active_only (bool) – Keep stations with a current automated snow series or a snow survey in the last 550 days.

  • bbox (tuple, optional) – (min_lon, min_lat, max_lon, max_lat).

Returns:

list[dict] – station_id, name, latitude, longitude, elevation_m (always None: 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, parameters and station_url. Stations without coordinates are dropped when bbox is 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 – The get_all_stations() dict plus data_variables (one entry per parameter × supported interval) with name, type, interval, units (emitted), description, notes, begin_date, end_date and n_obs (None), plus the WISKI ts_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:
  • ts_id (str) – WISKI time-series id (tsID / TsIdLowres from the catalog).

  • begin_date (str) – Inclusive YYYY-MM-DD bounds (MST).

  • end_date (str) – Inclusive YYYY-MM-DD bounds (MST).

Returns:

tuple[dict, list[tuple[datetime, Any]]] – (header, rows); header is 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] or str or None) – ARB station numbers, e.g. "05BB803". Required unless bbox is given.

  • variables (list[str] or str or None) – Native parameters ("SW", "SW-SS") or standardized types ("swe"). A type resolves to the parameters available at interval (swe → SW for daily/hourly, SW-SS for periodic). None = snow only.

  • bbox (tuple, optional) – (min_lon, min_lat, max_lon, max_lat).

  • begin_date (str or date, optional) – Inclusive YYYY-MM-DD bounds in MST. Default: the series’ first value / today.

  • end_date (str or date, optional) – Inclusive YYYY-MM-DD bounds 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) – Add flag (always None: the source has no flags).

Returns:

list[dict] – {station_id, date, variable, type, value, units, interval} (+ datetime ISO 8601 with -07:00 for 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_ids nor bbox is 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)

Alberta snow pillows and snow courses (Alberta River Basins)