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

A collection of SNOTEL and CCSS automatic weather stations.

Deprecated since version 0.1.0: Use easysnowdata.stations.inventory() and easysnowdata.stations.load(). Removed in 0.2.0.

Parameters:
  • data_available (bool, optional) – If True (default), only include stations with a daily record — which is what “has a CSV file” meant in the old archive.

  • sortby_dist_to_geom (GeoDataFrame or tuple or shapely geometry, optional) – If provided, stations are sorted by distance to this geometry and a dist_km column is added to all_stations.

  • **kwargs – Passed to geopandas.read_file when the station inventory is read (e.g. rows=10).

all_stations#

All stations matching the filter criteria, indexed by station code.

Type:

geopandas.GeoDataFrame

stations#

The subset selected by the most recent choose_stations() call.

Type:

geopandas.GeoDataFrame or None

data#

Data returned by the most recent get_data() call.

Type:

pandas.DataFrame or xarray.Dataset or None

entire_data_archive#

Full dataset returned by get_entire_data_archive().

Type:

xarray.Dataset or None

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 – Sets self.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 – Sets self.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() or get_multiple_station_data() based on how many stations are selected, exactly as before.

Parameters:
  • stations (str, list of str, or GeoDataFrame, optional) – Station code(s) to fetch. Default "679_WA_SNTL" (Paradise, WA).

  • variables (str or list of str, optional) – Defaults to all six variables for a single station, or WTEQ for 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. dtype is applied to the result; other pandas.read_csv arguments no longer have a CSV to act on and are ignored with a warning.

Returns:

None – Sets self.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 – Sets self.data to a pandas.DataFrame indexed by datetime, 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 – Sets self.data to an xarray.Dataset with water-year coordinates WY and DOWY.

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_DIR moves the cache).

  • temp_dir – Accepted for compatibility and ignored: the archive is cached by the package (EASYSNOWDATA_CACHE_DIR moves the cache).

  • **kwargsdtype is applied to the result; anything else is ignored.

Returns:

xarray.DatasetWTEQ and SNWD for every station, with WY and DOWY coordinates. The archive holds no precipitation or temperature; use get_data() for those.