eta_utility.connectors.wetterdienst_connection module
- class eta_utility.connectors.wetterdienst_connection.WetterdienstConnection(*, nodes: Nodes[NW] | None = None, settings: Settings | None = None, **kwargs: Any)[source]
Bases:
Generic
[NW
],SeriesConnection
[NW
],ABC
The WetterdienstConnection class is a connector to the Wetterdienst API for retrieving weather data. This class is an abstract base class and should not be used directly. Instead, use the subclasses
WetterdienstObservationConnection
andWetterdienstPredictionConnection
.- Parameters:
url – The base URL of the Wetterdienst API
nodes – Nodes to select in connection
settings – Wetterdienst settings object
- abstract read_series(from_time: datetime, to_time: datetime, nodes: Nodes[NW] | None = None, interval: TimeStep = 60, **kwargs: Any) pd.DataFrame [source]
Abstract base method for read_series(). Is fully implemented in
read_series()
andread_series()
.- Parameters:
nodes – List of nodes to read values from.
from_time – Starting time to begin reading (included in output).
to_time – Time to stop reading at (not included in output).
interval – interval between time steps. It is interpreted as seconds if given as integer.
kwargs – additional argument list, to be defined by subclasses.
- Returns:
pandas.DataFrame containing the data read from the connection.
- read(nodes: Nodes[NW] | None = None) pd.DataFrame [source]
Warning
Cannot read single values from the Wetterdienst API. Use read_series instead
- Parameters:
nodes – List of nodes to read values from
- Returns:
Pandas DataFrame containing the data read from the connection
- write(values: Mapping[NW, Any], time_interval: timedelta | None = None) None [source]
Warning
Cannot write to the Wetterdienst API.
- Parameters:
values – Dictionary of nodes and data to write. {node: value}
time_interval – Interval between datapoints, default 1s
- subscribe(handler: SubscriptionHandler, nodes: Nodes[NW] | None = None, interval: TimeStep = 1) None [source]
Subscribe to nodes and call handler when new data is available. This will return only the last available values.
- Parameters:
handler – SubscriptionHandler object with a push method that accepts node, value pairs
interval – interval for receiving new data. It is interpreted as seconds when given as an integer.
nodes – identifiers for the nodes to subscribe to
- subscribe_series(handler: SubscriptionHandler, req_interval: TimeStep, offset: TimeStep | None = None, nodes: Nodes[NW] | None = None, interval: TimeStep = 1, data_interval: TimeStep = 1, **kwargs: Any) None [source]
Warning
Not implemented: Cannot subscribe to data from the Wetterdienst API.
- Parameters:
handler – SubscriptionHandler object with a push method that accepts node, value pairs
req_interval – Duration covered by requested data (time interval). Interpreted as seconds if given as int
offset – Offset from datetime.now from which to start requesting data (time interval). Interpreted as seconds if given as int. Use negative values to go to past timestamps.
data_interval – Time interval between values in returned data. Interpreted as seconds if given as int.
interval – interval (between requests) for receiving new data. It it interpreted as seconds when given as an integer.
nodes – identifiers for the nodes to subscribe to
- close_sub() None [source]
Warning
Not implemented: Cannot subscribe to data from the the Wetterdienst API.
- retrieve_stations(node: NodeWetterdienst, request: wetterdienst.provider.dwd.observation.api.DwdObservationRequest) pandas.DataFrame [source]
Retrieve stations from the Wetterdienst API and return the values as a pandas DataFrame Stations are filtered by the node’s station_id or latlon and number_of_stations
- Parameters:
node – Node to retrieve stations for
request – Wetterdienst request object, containing the station data
- class eta_utility.connectors.wetterdienst_connection.WetterdienstObservationConnection(*, nodes: Nodes[NW] | None = None, settings: Settings | None = None, **kwargs: Any)[source]
Bases:
WetterdienstConnection
[NodeWetterdienstObservation
]The WetterdienstObservationConnection class is a connector to the Wetterdienst API for retrieving weather observation data. Data can only be read with
read_series()
.- read_series(from_time: datetime, to_time: datetime, nodes: Nodes[NodeWetterdienstObservation] | None = None, interval: TimeStep = 60, **kwargs: Any) pd.DataFrame [source]
Read weather observation data from the Wetterdienst API for the given nodes and time interval
- Parameters:
from_time – Start time for the data retrieval
to_time – End time for the data retrieval
nodes – Nodes to read data from
interval – Time interval between data points in seconds
- Returns:
Pandas DataFrame containing the data read from the connection
- class eta_utility.connectors.wetterdienst_connection.WetterdienstPredictionConnection(*, nodes: Nodes[NW] | None = None, settings: Settings | None = None, **kwargs: Any)[source]
Bases:
WetterdienstConnection
[NodeWetterdienstPrediction
]The WetterdienstPredictionConnection class is a connector to the Wetterdienst API for retrieving weather prediction data (MOSMIX). Data can only be read with
read_series()
.- read_series(from_time: datetime, to_time: datetime, nodes: Nodes[NodeWetterdienstPrediction] | None = None, interval: TimeStep = 0, **kwargs: Any) pd.DataFrame [source]
Read weather prediction data from the Wetterdienst API for the given nodes. The interval parameter is not used for prediction data, as predictions are always given hourly.
- Parameters:
from_time – Start time for the data retrieval
to_time – End time for the data retrieval
nodes – Nodes to read data from
interval –
Not used for prediction data
- Returns:
Pandas DataFrame containing the data read from the connection