Wetterdienst Connection

WetterdienstPrediction

class eta_utility.connectors.WetterdienstPredictionConnection(*, nodes: Nodes[NW] | None = None, settings: Settings | None = None, **kwargs: Any)[source]

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: NodeWetterdienstPrediction | 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 – Single node or list/set of nodes to read data from

  • interval

    • Not used for prediction data

Returns:

Pandas DataFrame containing the data read from the connection

NodeWetterdienstPrediction

class eta_utility.connectors.node.NodeWetterdienstPrediction(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]

Node for the Wetterdienst API to get weather predictions. For more information see: https://wetterdienst.readthedocs.io/en/latest/data/provider/dwd/mosmix/

mosmix_type: str

Type of the MOSMIX prediction. Either ‘SMALL’ or ‘LARGE’

parameter: str

Parameter to read from wetterdienst (e.g HUMIDITY or TEMPERATURE_AIR_200)

station_id: str | None

The id of the weather station

latlon: str | None

latitude and longitude (not necessarily a weather station)

number_of_stations: int | None

Number of stations to be used for the query

name: str

Name for the node.

url: str

URL of the connection.

url_parsed: ParseResult

Parse result object of the URL (in case more post-processing is required).

usr: str | None

Username for login to the connection (default: None).

pwd: str | None

Password for login to the connection (default: None).

interval: str | None

Interval

dtype: Callable | None

Data type of the node (for value conversion). Note that strings will be interpreted as utf-8 encoded. If you do not want this behaviour, use ‘bytes’.

WetterdienstObservation

class eta_utility.connectors.WetterdienstObservationConnection(*, nodes: Nodes[NW] | None = None, settings: Settings | None = None, **kwargs: Any)[source]

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: NodeWetterdienstObservation | 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 – Single node or list/set of nodes to read data from

  • interval – Time interval between data points in seconds

Returns:

Pandas DataFrame containing the data read from the connection

NodeWetterdienstObservation

class eta_utility.connectors.node.NodeWetterdienstObservation(name: str, url: str, protocol: str, *args: Any, **kwargs: Any)[source]

Node for the Wetterdienst API to get weather observations. For more information see: https://wetterdienst.readthedocs.io/en/latest/data/provider/dwd/observation/

interval: str

Redeclare interval attribute, but don’t allow it to be optional

static convert_interval_to_resolution(interval: int | str | timedelta) str[source]
parameter: str

Parameter to read from wetterdienst (e.g HUMIDITY or TEMPERATURE_AIR_200)

station_id: str | None

The id of the weather station

latlon: str | None

latitude and longitude (not necessarily a weather station)

number_of_stations: int | None

Number of stations to be used for the query

name: str

Name for the node.

url: str

URL of the connection.

url_parsed: ParseResult

Parse result object of the URL (in case more post-processing is required).

usr: str | None

Username for login to the connection (default: None).

pwd: str | None

Password for login to the connection (default: None).

dtype: Callable | None

Data type of the node (for value conversion). Note that strings will be interpreted as utf-8 encoded. If you do not want this behaviour, use ‘bytes’.

Example

An example using the Wetterdienst connection:


# Construct a node with the necessary information to request data from the Wetterdienst API
node = (
    NodeWetterdienst(
        "Temperature_Darmstadt",
        "https://opendata.dwd.de",
        "wetterdienst_observation",
        parameter="TEMPERATURE_AIR_MEAN_200",
        station_id="00917",  # Darmstadt observation station ID
        interval=600,  # 10 minutes interval
    ),
)

# start connection from one or multiple nodes
# The 'Connection' class can be used for initializing the connection
connection = WetterdienstConnection.from_node(node)

# Define time interval as datetime values
from_datetime = datetime(2024, 1, 16, 12, 00)
to_datetime = datetime(2024, 1, 16, 18, 00)

# read_series will request data from specified connection and time interval
# The DataFrame will have index with time delta of the specified interval in seconds
# If a node  has a different interval than the requested interval, the data will be resampled.
if isinstance(connection, WetterdienstConnection):
    result = connection.read_series(from_time=from_datetime, to_time=to_datetime, interval=1200)
else:
    raise TypeError("The connection must be an WetterdienstConnection, to be able to call read_series.")
# Check out the WetterdienstConnection documentation for more information
# https://wetterdienst.readthedocs.io/en/latest/data/introduction.html