easysnowdata.automatic_weather_stations.StationCollection#
- class easysnowdata.automatic_weather_stations.StationCollection(data_available: bool = True, sortby_dist_to_geom: GeoDataFrame | tuple | None = None, **kwargs: Any)[source]#
Bases:
objectA collection of SNOTEL and CCSS automatic weather stations.
Deprecated since version 0.1.0: Use
easysnowdata.stations.inventory()andeasysnowdata.stations.load(). Removed in 0.2.0.- Parameters:
data_available (
bool, optional) – IfTrue(default), only include stations with a daily record — which is what “has a CSV file” meant in the old archive.sortby_dist_to_geom (
GeoDataFrameortupleorshapely geometry, optional) – If provided, stations are sorted by distance to this geometry and adist_kmcolumn is added toall_stations.**kwargs – Passed to
geopandas.read_filewhen the station inventory is read (e.g.rows=10).
- all_stations#
All stations matching the filter criteria, indexed by station code.
- Type:
- stations#
The subset selected by the most recent
choose_stations()call.- Type:
- data#
Data returned by the most recent
get_data()call.- Type:
- entire_data_archive#
Full dataset returned by
get_entire_data_archive().- Type:
Examples
>>> sc = StationCollection() >>> sc.get_data(stations="679_WA_SNTL", variables=["WTEQ"], ... start_date="2020-10-01", end_date="2021-09-30")
Notes
Available variables:
WTEQ(SWE),SNWD(snow depth),PRCPSA(accumulated precipitation),TAVG,TMIN,TMAX. Values are in metres and °C, as they were in the frozen archive.- get_all_stations() None[source]#
Fetch station metadata and populate
all_stations.- Returns:
None– Setsself.all_stations.
- choose_stations(stations_input: GeoDataFrame | str | list) None[source]#
Select a subset of stations by code, list of codes, or GeoDataFrame.
- Returns:
None– Setsself.stations.
- get_data(stations: GeoDataFrame | str | list = '679_WA_SNTL', variables: str | list | None = None, start_date: str = '1900-01-01', end_date: str | None = None, **kwargs: Any) None[source]#
Fetch data for the given stations and variables.
Dispatches to
get_single_station_data()orget_multiple_station_data()based on how many stations are selected, exactly as before.- Parameters:
stations (
str,listofstr, orGeoDataFrame, optional) – Station code(s) to fetch. Default"679_WA_SNTL"(Paradise, WA).variables (
strorlistofstr, optional) – Defaults to all six variables for a single station, orWTEQfor several.start_date (
str, optional) – ISO date strings. end_date defaults to today.end_date (
str, optional) – ISO date strings. end_date defaults to today.**kwargs – Accepted for compatibility.
dtypeis applied to the result; otherpandas.read_csvarguments no longer have a CSV to act on and are ignored with a warning.
- Returns:
None– Setsself.data.
- get_single_station_data(variables: list[str] | None = None, start_date: str = '1900-01-01', end_date: str | None = None, **kwargs: Any) None[source]#
Fetch variables for the currently selected single station.
- Returns:
None– Setsself.datato apandas.DataFrameindexed bydatetime, one column per variable, in metres and °C.
- get_multiple_station_data(variables: str | list[str] = 'WTEQ', start_date: str = '1900-01-01', end_date: str | None = None, **kwargs: Any) None[source]#
Fetch one or more variables for all currently selected stations.
- Returns:
None– Setsself.datato anxarray.Datasetwith water-year coordinatesWYandDOWY.
- get_entire_data_archive(refresh: bool = True, temp_dir: str = '/tmp/', **kwargs: Any) Dataset[source]#
Every station’s whole daily record.
Deprecated since version 0.1.0: Use
easysnowdata.stations.archive.load().- Parameters:
refresh – Accepted for compatibility and ignored: the archive is cached by the package (
EASYSNOWDATA_CACHE_DIRmoves the cache).temp_dir – Accepted for compatibility and ignored: the archive is cached by the package (
EASYSNOWDATA_CACHE_DIRmoves the cache).**kwargs –
dtypeis applied to the result; anything else is ignored.
- Returns:
xarray.Dataset–WTEQandSNWDfor every station, withWYandDOWYcoordinates. The archive holds no precipitation or temperature; useget_data()for those.