easysnowdata.stations.clients.SouthernAndesClient#

class easysnowdata.stations.clients.SouthernAndesClient(path: str | PathLike | None = None, record_id: str | None = None, cache_dir: str | PathLike | None = None, timeout: int = 120, max_retries: int = 3, backoff: int = 4, session: Session | None = None)[source]#

Bases: object

Client for the Southern Andes Daily Snow Depth Dataset (Zenodo).

No credentials are needed.

Parameters:
  • path (str or Path, optional) – Folder holding the two CSVs (the data file and the station metadata); skips Zenodo entirely.

  • record_id (str, optional) – Pin a Zenodo record (e.g. "21577171"). Default: the latest version of concept record 19560127.

  • cache_dir (str or Path, optional) – Override easysnowdata.config.cache_dir("stations", "southern_andes").

  • timeout (int) – HTTP settings for the shared retry loop.

  • max_retries (int) – HTTP settings for the shared retry loop.

  • backoff (int) – HTTP settings for the shared retry loop.

  • session (requests.Session, optional) – Pre-configured session.

resolve_record() → dict[source]#

Zenodo record JSON for the pinned or latest version.

dataset_files() → tuple[Path, Path][source]#

Local (data CSV, metadata CSV), downloading them on first use.

Returns:

tuple[Path, Path]

Raises:

SouthernAndesError – If path= lacks the two CSVs, or nothing can be downloaded or found in the cache.

get_all_stations(active_only: bool = False, bbox: tuple[float, float, float, float] | None = None, networks: list[str] | str | None = None) → list[dict][source]#

Every station in the dataset.

Parameters:
  • active_only (bool) – Keep stations that reported in the dataset’s final year.

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

  • networks (list[str] or str, optional) – Keep these networks ("DGA", "IANIGLA", "CEAZA", "CIEP"; see NETWORKS).

Returns:

list[dict] – station_id, name, latitude, longitude, elevation_m, status, network (the source column), operator, country, basin, sensor, measurement_method, begin_date / end_date (as the metadata file gives them), potential_days, effective_days, first_obs / last_obs / n_snwd (from the data file), has_swe (always False), has_snwd and station_url (the network’s own portal).

Raises:

SouthernAndesError – On a download failure or an unknown network.

get_metadata(station_id: str) → dict[source]#

Station metadata plus data_variables.

Parameters:

station_id (str) – Id as in get_all_stations() ("5703009", "Capayan").

Returns:

dict – The station dict plus data_variables: one entry (SD) with name, type, interval ("daily"), units, description, notes, begin_date / end_date (first and last value in the data file) and n_obs.

Raises:

SouthernAndesError – If the station is not in the dataset.

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]#

Daily snow depth as flat records.

Parameters:
  • station_ids (list[str] or str or None) – Station id(s). Required unless bbox is given.

  • variables (list[str] or str or None) – "SD" or "snwd"; None = ["SD"].

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

  • begin_date (str or date, optional) – Inclusive YYYY-MM-DD bounds.

  • end_date (str or date, optional) – Inclusive YYYY-MM-DD bounds.

  • interval (str) – Only "daily".

  • include_flags (bool) – Add flag (always None: the dataset has no flags).

Returns:

list[dict] – {station_id, date, variable, type, value, units, interval} (+ flag), one per day with a value in the file (value is None only for a depth outside 0–15 m).

Raises:
  • ValueError – If neither station_ids nor bbox is given.

  • SouthernAndesError – On an unknown variable or station, an unsupported interval or a download failure.

Example

>>> client = SouthernAndesClient()
>>> records = client.get_data(
...     station_ids="5703009",
...     begin_date="2023-06-01",
...     end_date="2023-09-30",
... )
>>> records[0]["units"], records[0]["interval"]
('cm', 'daily')

Examples using easysnowdata.stations.clients.SouthernAndesClient#

Southern Andes daily snow depth (Chile and Argentina)

Southern Andes daily snow depth (Chile and Argentina)