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:
objectClient for the Southern Andes Daily Snow Depth Dataset (Zenodo).
No credentials are needed.
- Parameters:
path (
strorPath, 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 (
strorPath, optional) – Overrideeasysnowdata.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.
- 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:
- Returns:
list[dict]–station_id,name,latitude,longitude,elevation_m,status,network(thesourcecolumn),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_snwdandstation_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 inget_all_stations()("5703009","Capayan").- Returns:
dict– The station dict plusdata_variables: one entry (SD) withname,type,interval("daily"),units,description,notes,begin_date/end_date(first and last value in the data file) andn_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]orstrorNone) – Station id(s). Required unlessbboxis given.variables (
list[str]orstrorNone) –"SD"or"snwd";None=["SD"].bbox (
tuple, optional) –(min_lon, min_lat, max_lon, max_lat).begin_date (
strordate, optional) – InclusiveYYYY-MM-DDbounds.end_date (
strordate, optional) – InclusiveYYYY-MM-DDbounds.interval (
str) – Only"daily".include_flags (
bool) – Addflag(alwaysNone: 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 (valueisNoneonly for a depth outside 0–15 m).- Raises:
ValueError – If neither
station_idsnorbboxis 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)