Machinery

Machinery#

DWD (German Weather Service)#

class KMLReader(station_ids: list[str], settings: wetterdienst.settings.Settings)

Read DWD XML Weather Forecast File of Type KML.

Initialization

Initialize KMLReader.

Args: station_ids: List of station IDs to read. settings: Settings object.

download(url: str) io.BytesIO

Download kml file as bytes.

https://stackoverflow.com/questions/37573483/progress-bar-while-download-file-over-http-with-requests

fetch(url: str) BinaryIO

Open the zipped mosmix KML as a streaming handle (decompressed lazily, not all at once).

read(url: str) None

Download and read DWD XML Weather Forecast File of Type KML.

iter_items() collections.abc.Iterator[xml.etree.ElementTree.Element]

Iterate over station forecasts, pruning parsed elements to bound memory.

get_metadata() polars.DataFrame

Get metadata as DataFrame.

_store_station_forecasts() None

Store station forecasts in self.data.

For mosmix we want the reader to only go once through the file and store all data (meaning all queried stations) in memory. This is to avoid multiple downloads/parses of the same file when users want to access data of multiple stations.

Returns: None

get_station_forecast(station_id: str) polars.DataFrame

Get forecasts as DataFrame.