Python API
Introduction
The API offers access to different data products. They are outlined in more detail within the data chapter. Please also check out complete examples about how to use the API in the examples folder. In order to explore all features interactively, you might want to try the cli. For managing general settings, please refer to the settings chapter.
Available APIs
The available APIs can be accessed by the top-level API Wetterdienst. This API also allows the user to discover the available APIs of each service included:
To load any of the available APIs pass the provider and the network of data to the Wetterdienst API:
Request arguments
A request is typically defined by three arguments:
parameters
start_date
end_date
Parameters can be requested in different ways e.g.
- using a tuple of resolution and dataset
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "climate_summary") # will resolve to all parameters of kl
)
- using a tuple of resolution, dataset, parameter
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "climate_summary", "precipitation_height")
)
- the same with the original names
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "rsk")
)
- using the metadata model
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationMetadata
request = DwdObservationRequest(
parameters=DwdObservationMetadata.daily.kl # will resolve to all parameters of kl
)
- using a list of tuples
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=[("daily", "climate_summary"), ("daily", "precipitation_more")]
)
- using a list of metadata
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationMetadata
request = DwdObservationRequest(
parameters=[DwdObservationMetadata.daily.kl, DwdObservationMetadata.daily.more_precip]
)
For some weather service one can select which period of the data is request with periods
.
Valid periods are historical
, recent
and now
. periods
can be given as a list or a single value.
The value can be a string, the enumeration value or the enumeration name e.g.
- by using the exact enumeration e.g.
- by using the enumeration name or value as string e.g. If a weather service has periods, the period argument typically can be used as replacement for the start_date and end_date arguments. In case both arguments are given they are used as a filter for the data.
Regarding the definition of requested parameters:
Data
In case of the DWD, requests can be defined by either of period or
start_date
and end_date
. Use DwdObservationRequest.discover()
to discover available parameters based on the given filter arguments.
Stations
all stations
Get station information for a given dataset/parameter and period.
shape: (5, 10) ┌────────────┬────────────┬───────────┬───────────┬───┬───────────┬────────┬───────────┬───────────┐ │ resolution ┆ dataset ┆ station_i ┆ start_dat ┆ … ┆ longitude ┆ height ┆ name ┆ state │ │ --- ┆ --- ┆ d ┆ e ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ --- ┆ --- ┆ ┆ f64 ┆ f64 ┆ str ┆ str │ │ ┆ ┆ str ┆ datetime[ ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ μs, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪═══════════╪═══════════╪═══╪═══════════╪════════╪═══════════╪═══════════╡ │ daily ┆ precipitat ┆ 00001 ┆ 1912-01-0 ┆ … ┆ 8.8493 ┆ 478.0 ┆ Aach ┆ Baden-Wür │ │ ┆ ion_more ┆ ┆ 1 ┆ ┆ ┆ ┆ ┆ ttemberg │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ daily ┆ precipitat ┆ 00002 ┆ 1951-01-0 ┆ … ┆ 6.0996 ┆ 138.0 ┆ Aachen ┆ Nordrhein │ │ ┆ ion_more ┆ ┆ 1 ┆ ┆ ┆ ┆ (Kläranla ┆ -Westfale │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ge) ┆ n │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ daily ┆ precipitat ┆ 00003 ┆ 1891-01-0 ┆ … ┆ 6.0941 ┆ 202.0 ┆ Aachen ┆ Nordrhein │ │ ┆ ion_more ┆ ┆ 1 ┆ ┆ ┆ ┆ ┆ -Westfale │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ n │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ daily ┆ precipitat ┆ 00004 ┆ 1951-01-0 ┆ … ┆ 6.1207 ┆ 243.0 ┆ Aachen-Br ┆ Nordrhein │ │ ┆ ion_more ┆ ┆ 1 ┆ ┆ ┆ ┆ and ┆ -Westfale │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ n │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ daily ┆ precipitat ┆ 00006 ┆ 1982-11-0 ┆ … ┆ 10.0598 ┆ 455.0 ┆ Aalen-Unt ┆ Baden-Wür │ │ ┆ ion_more ┆ ┆ 1 ┆ ┆ ┆ ┆ errombach ┆ ttemberg │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴───────────┴───────────┴───┴───────────┴────────┴───────────┴───────────┘
The function returns a Polars DataFrame with information about the available stations.
filter by station id
shape: (1, 10) ┌────────────┬────────────┬────────────┬────────────┬───┬───────────┬────────┬───────────┬─────────┐ │ resolution ┆ dataset ┆ station_id ┆ start_date ┆ … ┆ longitude ┆ height ┆ name ┆ state │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ datetime[μ ┆ ┆ f64 ┆ f64 ┆ str ┆ str │ │ ┆ ┆ ┆ s, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪════════════╪════════════╪═══╪═══════════╪════════╪═══════════╪═════════╡ │ daily ┆ precipitat ┆ 01048 ┆ 1926-04-25 ┆ … ┆ 13.7543 ┆ 228.0 ┆ Dresden-K ┆ Sachsen │ │ ┆ ion_more ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ lotzsche ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴────────────┴───┴───────────┴────────┴───────────┴─────────┘
filter by name
shape: (1, 10) ┌────────────┬────────────┬────────────┬────────────┬───┬───────────┬────────┬───────────┬─────────┐ │ resolution ┆ dataset ┆ station_id ┆ start_date ┆ … ┆ longitude ┆ height ┆ name ┆ state │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ datetime[μ ┆ ┆ f64 ┆ f64 ┆ str ┆ str │ │ ┆ ┆ ┆ s, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪════════════╪════════════╪═══╪═══════════╪════════╪═══════════╪═════════╡ │ daily ┆ precipitat ┆ 01048 ┆ 1926-04-25 ┆ … ┆ 13.7543 ┆ 228.0 ┆ Dresden-K ┆ Sachsen │ │ ┆ ion_more ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ lotzsche ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴────────────┴───┴───────────┴────────┴───────────┴─────────┘
filter by distance
Distance in kilometers (default)
shape: (5, 11) ┌────────────┬────────────┬────────────┬───────────┬───┬────────┬───────────┬───────────┬──────────┐ │ resolution ┆ dataset ┆ station_id ┆ start_dat ┆ … ┆ height ┆ name ┆ state ┆ distance │ │ --- ┆ --- ┆ --- ┆ e ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ --- ┆ ┆ f64 ┆ str ┆ str ┆ f64 │ │ ┆ ┆ ┆ datetime[ ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ μs, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪════════════╪═══════════╪═══╪════════╪═══════════╪═══════════╪══════════╡ │ hourly ┆ temperatur ┆ 01975 ┆ 1949-01-0 ┆ … ┆ 11.0 ┆ Hamburg-F ┆ Hamburg ┆ 9.1381 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ uhlsbütte ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ l ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 01981 ┆ 2005-03-0 ┆ … ┆ 4.0 ┆ Hamburg-N ┆ Hamburg ┆ 10.4279 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ euwiedent ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ hal ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00052 ┆ 1976-01-0 ┆ … ┆ 46.0 ┆ Ahrensbur ┆ Schleswig ┆ 18.3417 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ g-Wulfsdo ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ rf ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00760 ┆ 2017-12-0 ┆ … ┆ 83.0 ┆ Rosengart ┆ Niedersac ┆ 21.1875 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ en-Klecke ┆ hsen ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ n ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 04039 ┆ 1988-01-1 ┆ … ┆ 11.0 ┆ Quickborn ┆ Schleswig ┆ 21.6373 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴───────────┴───┴────────┴───────────┴───────────┴──────────┘
Distance in miles
shape: (5, 11) ┌────────────┬────────────┬────────────┬───────────┬───┬────────┬───────────┬───────────┬──────────┐ │ resolution ┆ dataset ┆ station_id ┆ start_dat ┆ … ┆ height ┆ name ┆ state ┆ distance │ │ --- ┆ --- ┆ --- ┆ e ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ --- ┆ ┆ f64 ┆ str ┆ str ┆ f64 │ │ ┆ ┆ ┆ datetime[ ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ μs, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪════════════╪═══════════╪═══╪════════╪═══════════╪═══════════╪══════════╡ │ hourly ┆ temperatur ┆ 01975 ┆ 1949-01-0 ┆ … ┆ 11.0 ┆ Hamburg-F ┆ Hamburg ┆ 9.1381 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ uhlsbütte ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ l ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 01981 ┆ 2005-03-0 ┆ … ┆ 4.0 ┆ Hamburg-N ┆ Hamburg ┆ 10.4279 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ euwiedent ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ hal ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00052 ┆ 1976-01-0 ┆ … ┆ 46.0 ┆ Ahrensbur ┆ Schleswig ┆ 18.3417 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ g-Wulfsdo ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ rf ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00760 ┆ 2017-12-0 ┆ … ┆ 83.0 ┆ Rosengart ┆ Niedersac ┆ 21.1875 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ en-Klecke ┆ hsen ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ n ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 04039 ┆ 1988-01-1 ┆ … ┆ 11.0 ┆ Quickborn ┆ Schleswig ┆ 21.6373 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴───────────┴───┴────────┴───────────┴───────────┴──────────┘
filter by rank
shape: (5, 11) ┌────────────┬────────────┬────────────┬───────────┬───┬────────┬───────────┬───────────┬──────────┐ │ resolution ┆ dataset ┆ station_id ┆ start_dat ┆ … ┆ height ┆ name ┆ state ┆ distance │ │ --- ┆ --- ┆ --- ┆ e ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ --- ┆ ┆ f64 ┆ str ┆ str ┆ f64 │ │ ┆ ┆ ┆ datetime[ ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ μs, UTC] ┆ ┆ ┆ ┆ ┆ │ ╞════════════╪════════════╪════════════╪═══════════╪═══╪════════╪═══════════╪═══════════╪══════════╡ │ hourly ┆ temperatur ┆ 01975 ┆ 1949-01-0 ┆ … ┆ 11.0 ┆ Hamburg-F ┆ Hamburg ┆ 9.1381 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ uhlsbütte ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ l ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 01981 ┆ 2005-03-0 ┆ … ┆ 4.0 ┆ Hamburg-N ┆ Hamburg ┆ 10.4279 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ euwiedent ┆ ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ hal ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00052 ┆ 1976-01-0 ┆ … ┆ 46.0 ┆ Ahrensbur ┆ Schleswig ┆ 18.3417 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ g-Wulfsdo ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ rf ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 00760 ┆ 2017-12-0 ┆ … ┆ 83.0 ┆ Rosengart ┆ Niedersac ┆ 21.1875 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ en-Klecke ┆ hsen ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ n ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ │ hourly ┆ temperatur ┆ 04039 ┆ 1988-01-1 ┆ … ┆ 11.0 ┆ Quickborn ┆ Schleswig ┆ 21.6373 │ │ ┆ e_air ┆ ┆ 1 ┆ ┆ ┆ ┆ -Holstein ┆ │ │ ┆ ┆ ┆ 00:00:00 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ ┆ UTC ┆ ┆ ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴───────────┴───┴────────┴───────────┴───────────┴──────────┘
filter by bbox
shape: (0, 10) ┌────────────┬─────────┬────────────┬───────────────────┬───┬───────────┬────────┬──────┬───────┐ │ resolution ┆ dataset ┆ station_id ┆ start_date ┆ … ┆ longitude ┆ height ┆ name ┆ state │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str ┆ datetime[μs, UTC] ┆ ┆ f64 ┆ f64 ┆ str ┆ str │ ╞════════════╪═════════╪════════════╪═══════════════════╪═══╪═══════════╪════════╪══════╪═══════╡ └────────────┴─────────┴────────────┴───────────────────┴───┴───────────┴────────┴──────┴───────┘
Values
Values are just an extension of requests:
from wetterdienst.provider.dwd.observation import DwdObservationRequest
from wetterdienst import Settings
# if no settings are provided, default settings are used which are
# Settings(ts_shape="long", ts_humanize=True, ts_si_units=True)
request = DwdObservationRequest(
parameters=[("daily", "kl"), ("daily", "solar")],
start_date="1990-01-01",
end_date="2020-01-01",
)
stations = request.filter_by_station_id(station_id=("00003", "01048"))
# From here you can query data by station
for result in stations.values.query():
# analyse the station here
print(result.df.drop_nulls().head())
# Query data all together
df = stations.values.all().df.drop_nulls()
print(df.head())
This gives us the most options to work with the data, getting multiple parameters at
once, parsed nicely into column structure with improved parameter names. Instead of
start_date
and end_date
you may as well want to use period
to update your
database once in a while with a fixed set of records.
In case you use filter_by_rank
you may want to skip empty stations. We can use the Settings from
settings to achieve that:
from wetterdienst import Settings
from wetterdienst.provider.dwd.observation import DwdObservationRequest
settings = Settings(ts_skip_empty=True, ts_skip_criteria="min", ignore_env=True)
karlsruhe = (49.19780976647141, 8.135207205143768)
request = DwdObservationRequest(
parameters=[("daily", "kl"), ("daily", "solar")],
start_date="2021-01-01",
end_date="2021-12-31",
settings=settings,
)
stations = request.filter_by_rank(latlon=karlsruhe, rank=2)
values = stations.values.all()
print(values.df.head())
# df_stations has only stations that appear in the values
print(values.df_stations.head())
Interpolation
Occasionally, you may require data specific to your precise location rather than relying on values measured at a
station's location. To address this need, we have introduced an interpolation feature, enabling you to interpolate data
from nearby stations to your exact coordinates. The function leverages the four closest stations to your specified
latitude and longitude and employs the bilinear interpolation method provided by the scipy package (interp2d) to
interpolate the given parameter values. Currently, this interpolation feature is exclusive to
DWDObservationRequest
and parameters temperature_air_mean_2m
, wind_speed
, precipitation_height
.
As it is in its early stages, we welcome feedback to enhance and refine its functionality. Interpolation by nearby
stations is limited to a distance of 40 km by default (20.0 km for precipitation). You can
change this by setting the ts_interpolation_station_distance
setting. An example is shown below.
The graphic below shows values of the parameter temperature_air_mean_2m
from multiple stations measured at the same time.
The blue points represent the position of a station and includes the measured value.
The red point represents the position of the interpolation and includes the interpolated value.
Values represented as a table:
station_id | resolution | dataset | parameter | date | value |
---|---|---|---|---|---|
02480 | daily | climate_summary | temperature_air_mean_2m | 2022-01-02 00:00:00+00:00 | 278.15 |
04411 | daily | climate_summary | temperature_air_mean_2m | 2022-01-02 00:00:00+00:00 | 277.15 |
07341 | daily | climate_summary | temperature_air_mean_2m | 2022-01-02 00:00:00+00:00 | 278.35 |
00917 | daily | climate_summary | temperature_air_mean_2m | 2022-01-02 00:00:00+00:00 | 276.25 |
The interpolated value looks like this:
resolution | dataset | parameter | date | value |
---|---|---|---|---|
daily | climate_summary | temperature_air_mean_2m | 2022-01-02 00:00:00+00:00 | 277.65 |
import datetime as dt
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("hourly", "temperature_air", "temperature_air_mean_2m"),
start_date=dt.datetime(2022, 1, 1),
end_date=dt.datetime(2022, 1, 20),
)
values = request.interpolate(latlon=(50.0, 8.9))
df = values.df
print(df.head())
shape: (5, 8) ┌────────────┬────────────┬────────────┬────────────┬────────────┬───────┬────────────┬────────────┐ │ station_id ┆ resolution ┆ dataset ┆ parameter ┆ date ┆ value ┆ distance_m ┆ taken_stat │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ean ┆ ion_ids │ │ str ┆ str ┆ str ┆ str ┆ datetime[μ ┆ f64 ┆ --- ┆ --- │ │ ┆ ┆ ┆ ┆ s, UTC] ┆ ┆ f64 ┆ list[str] │ ╞════════════╪════════════╪════════════╪════════════╪════════════╪═══════╪════════════╪════════════╡ │ f674568e ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.92 ┆ 13.37 ┆ ["02480", │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 00:00:00 ┆ ┆ ┆ "04411", … │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ "00917"] │ │ f674568e ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.89 ┆ 13.37 ┆ ["02480", │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 01:00:00 ┆ ┆ ┆ "04411", … │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ "00917"] │ │ f674568e ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.6 ┆ 13.37 ┆ ["02480", │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 02:00:00 ┆ ┆ ┆ "04411", … │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ "00917"] │ │ f674568e ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.54 ┆ 13.37 ┆ ["02480", │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 03:00:00 ┆ ┆ ┆ "04411", … │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ "00917"] │ │ f674568e ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.36 ┆ 13.37 ┆ ["02480", │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 04:00:00 ┆ ┆ ┆ "04411", … │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ "00917"] │ └────────────┴────────────┴────────────┴────────────┴────────────┴───────┴────────────┴────────────┘
Instead of a latlon you may alternatively use an existing station id for which to interpolate values in a manner of getting a more complete dataset:
import datetime as dt
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("hourly", "temperature_air", "temperature_air_mean_2m"),
start_date=dt.datetime(2022, 1, 1),
end_date=dt.datetime(2022, 1, 20),
)
values = request.interpolate_by_station_id(station_id="02480")
df = values.df
print(df.head())
shape: (5, 8) ┌────────────┬────────────┬────────────┬────────────┬────────────┬───────┬────────────┬────────────┐ │ station_id ┆ resolution ┆ dataset ┆ parameter ┆ date ┆ value ┆ distance_m ┆ taken_stat │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ean ┆ ion_ids │ │ str ┆ str ┆ str ┆ str ┆ datetime[μ ┆ f64 ┆ --- ┆ --- │ │ ┆ ┆ ┆ ┆ s, UTC] ┆ ┆ f64 ┆ list[str] │ ╞════════════╪════════════╪════════════╪════════════╪════════════╪═══════╪════════════╪════════════╡ │ 7f2e709d ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.9 ┆ 0.0 ┆ ["02480"] │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 00:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ │ │ 7f2e709d ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.8 ┆ 0.0 ┆ ["02480"] │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 01:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ │ │ 7f2e709d ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 12.0 ┆ 0.0 ┆ ["02480"] │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 02:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ │ │ 7f2e709d ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.6 ┆ 0.0 ┆ ["02480"] │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 03:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ │ │ 7f2e709d ┆ hourly ┆ temperatur ┆ temperatur ┆ 2022-01-01 ┆ 11.6 ┆ 0.0 ┆ ["02480"] │ │ ┆ ┆ e_air ┆ e_air_mean ┆ 04:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ _2m ┆ UTC ┆ ┆ ┆ │ └────────────┴────────────┴────────────┴────────────┴────────────┴───────┴────────────┴────────────┘
Increase maximum distance for interpolation:
import datetime as dt
from wetterdienst.provider.dwd.observation import DwdObservationRequest
from wetterdienst import Settings
settings = Settings(ts_interpolation_station_distance={"precipitation_height": 25.0})
request = DwdObservationRequest(
parameters=("hourly", "precipitation", "precipitation_height"),
start_date=dt.datetime(2022, 1, 1),
end_date=dt.datetime(2022, 1, 20),
settings=settings
)
values = request.interpolate(latlon=(52.8, 12.9))
df = values.df
print(df.head())
shape: (5, 8) ┌────────────┬────────────┬────────────┬────────────┬────────────┬───────┬────────────┬────────────┐ │ station_id ┆ resolution ┆ dataset ┆ parameter ┆ date ┆ value ┆ distance_m ┆ taken_stat │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ean ┆ ion_ids │ │ str ┆ str ┆ str ┆ str ┆ datetime[μ ┆ f64 ┆ --- ┆ --- │ │ ┆ ┆ ┆ ┆ s, UTC] ┆ ┆ f64 ┆ list[str] │ ╞════════════╪════════════╪════════════╪════════════╪════════════╪═══════╪════════════╪════════════╡ │ 084631fd ┆ hourly ┆ precipitat ┆ precipitat ┆ 2022-01-01 ┆ 0.0 ┆ 18.33 ┆ ["02733", │ │ ┆ ┆ ion ┆ ion_height ┆ 00:00:00 ┆ ┆ ┆ "00096", … │ │ ┆ ┆ ┆ ┆ UTC ┆ ┆ ┆ "03205"] │ │ 084631fd ┆ hourly ┆ precipitat ┆ precipitat ┆ 2022-01-01 ┆ 0.17 ┆ 18.33 ┆ ["02733", │ │ ┆ ┆ ion ┆ ion_height ┆ 01:00:00 ┆ ┆ ┆ "00096", … │ │ ┆ ┆ ┆ ┆ UTC ┆ ┆ ┆ "03205"] │ │ 084631fd ┆ hourly ┆ precipitat ┆ precipitat ┆ 2022-01-01 ┆ 0.35 ┆ 18.33 ┆ ["02733", │ │ ┆ ┆ ion ┆ ion_height ┆ 02:00:00 ┆ ┆ ┆ "00096", … │ │ ┆ ┆ ┆ ┆ UTC ┆ ┆ ┆ "03205"] │ │ 084631fd ┆ hourly ┆ precipitat ┆ precipitat ┆ 2022-01-01 ┆ 0.22 ┆ 18.33 ┆ ["02733", │ │ ┆ ┆ ion ┆ ion_height ┆ 03:00:00 ┆ ┆ ┆ "00096", … │ │ ┆ ┆ ┆ ┆ UTC ┆ ┆ ┆ "03205"] │ │ 084631fd ┆ hourly ┆ precipitat ┆ precipitat ┆ 2022-01-01 ┆ 0.0 ┆ 18.33 ┆ ["02733", │ │ ┆ ┆ ion ┆ ion_height ┆ 04:00:00 ┆ ┆ ┆ "00096", … │ │ ┆ ┆ ┆ ┆ UTC ┆ ┆ ┆ "03205"] │ └────────────┴────────────┴────────────┴────────────┴────────────┴───────┴────────────┴────────────┘
Summary
Similar to interpolation you may sometimes want to combine multiple stations to get a complete list of data. For that
reason you can use .summary(latlon)
, which goes through nearest stations and combines data from them meaningful. The
following figure visualizes how summary works. The first graph shows the summarized values of the parameter
temperature_air_mean_2m
from multiple stations.
The code to execute the summary is given below. It currently only works for DwdObservationRequest
and individual parameters.
Currently, the following parameters are supported (more will be added if useful): temperature_air_mean_2m
, wind_speed
, precipitation_height
.
import datetime as dt
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("hourly", "temperature_air", "temperature_air_mean_2m"),
start_date=dt.datetime(2022, 1, 1),
end_date=dt.datetime(2022, 1, 20),
)
values = request.summarize(latlon=(50.0, 8.9))
df = values.df
print(df.head())
shape: (5, 8) ┌────────────┬────────────┬─────────────┬─────────────┬────────────┬───────┬──────────┬────────────┐ │ station_id ┆ resolution ┆ dataset ┆ parameter ┆ date ┆ value ┆ distance ┆ taken_stat │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ion_id │ │ str ┆ str ┆ str ┆ str ┆ datetime[μ ┆ f64 ┆ f64 ┆ --- │ │ ┆ ┆ ┆ ┆ s, UTC] ┆ ┆ ┆ str │ ╞════════════╪════════════╪═════════════╪═════════════╪════════════╪═══════╪══════════╪════════════╡ │ fc5aa952 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.9 ┆ 9.76 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 00:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ fc5aa952 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.8 ┆ 9.76 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 01:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ fc5aa952 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 12.0 ┆ 9.76 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 02:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ fc5aa952 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.6 ┆ 9.76 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 03:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ fc5aa952 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.6 ┆ 9.76 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 04:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ └────────────┴────────────┴─────────────┴─────────────┴────────────┴───────┴──────────┴────────────┘
Instead of a latlon you may alternatively use an existing station id for which to summarize values in a manner of getting a more complete dataset:
import datetime as dt
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("hourly", "temperature_air", "temperature_air_mean_2m"),
start_date=dt.datetime(2022, 1, 1),
end_date=dt.datetime(2022, 1, 20),
)
values = request.summarize_by_station_id(station_id="02480")
df = values.df
print(df.head())
shape: (5, 8) ┌────────────┬────────────┬─────────────┬─────────────┬────────────┬───────┬──────────┬────────────┐ │ station_id ┆ resolution ┆ dataset ┆ parameter ┆ date ┆ value ┆ distance ┆ taken_stat │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ion_id │ │ str ┆ str ┆ str ┆ str ┆ datetime[μ ┆ f64 ┆ f64 ┆ --- │ │ ┆ ┆ ┆ ┆ s, UTC] ┆ ┆ ┆ str │ ╞════════════╪════════════╪═════════════╪═════════════╪════════════╪═══════╪══════════╪════════════╡ │ 73becd44 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.9 ┆ 0.0 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 00:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ 73becd44 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.8 ┆ 0.0 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 01:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ 73becd44 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 12.0 ┆ 0.0 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 02:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ 73becd44 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.6 ┆ 0.0 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 03:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ │ 73becd44 ┆ hourly ┆ temperature ┆ temperature ┆ 2022-01-01 ┆ 11.6 ┆ 0.0 ┆ 02480 │ │ ┆ ┆ _air ┆ _air_mean_2 ┆ 04:00:00 ┆ ┆ ┆ │ │ ┆ ┆ ┆ m ┆ UTC ┆ ┆ ┆ │ └────────────┴────────────┴─────────────┴─────────────┴────────────┴───────┴──────────┴────────────┘
Format
To Dict
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "temperature_air_mean_2m"),
start_date="2020-01-01",
end_date="2020-01-02"
)
stations = request.filter_by_station_id(station_id="01048")
values = stations.values.all()
print(values.to_dict(with_metadata=True, with_stations=True))
{'metadata': {'provider': {'name_local': 'Deutscher Wetterdienst', 'name_english': 'German Weather Service', 'country': 'Germany', 'copyright': '© Deutscher Wetterdienst (DWD), Climate Data Center (CDC)', 'url': 'https://opendata.dwd.de/climate_environment/CDC/'}, 'producer': {'name': 'wetterdienst', 'version': '0.106.0', 'repository': 'https://github.com/earthobservations/wetterdienst', 'documentation': 'https://wetterdienst.readthedocs.io', 'doi': '10.5281/zenodo.3960624'}}, 'stations': [{'resolution': 'daily', 'dataset': 'climate_summary', 'station_id': '01048', 'start_date': '1934-01-01T00:00:00+00:00', 'end_date': '2025-03-19T00:00:00+00:00', 'latitude': 51.1278, 'longitude': 13.7543, 'height': 228.0, 'name': 'Dresden-Klotzsche', 'state': 'Sachsen'}], 'values': [{'station_id': '01048', 'resolution': 'daily', 'dataset': 'climate_summary', 'parameter': 'temperature_air_mean_2m', 'date': '2020-01-01T00:00:00+00:00', 'value': 2.4, 'quality': 10.0}, {'station_id': '01048', 'resolution': 'daily', 'dataset': 'climate_summary', 'parameter': 'temperature_air_mean_2m', 'date': '2020-01-02T00:00:00+00:00', 'value': 0.2, 'quality': 10.0}]}
To Json
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "temperature_air_mean_2m"),
start_date="2020-01-01",
end_date="2020-01-02"
)
stations = request.filter_by_station_id(station_id="01048")
values = stations.values.all()
print(values.to_json(with_metadata=True, with_stations=True))
{ "metadata": { "provider": { "name_local": "Deutscher Wetterdienst", "name_english": "German Weather Service", "country": "Germany", "copyright": "\u00a9 Deutscher Wetterdienst (DWD), Climate Data Center (CDC)", "url": "https://opendata.dwd.de/climate_environment/CDC/" }, "producer": { "name": "wetterdienst", "version": "0.106.0", "repository": "https://github.com/earthobservations/wetterdienst", "documentation": "https://wetterdienst.readthedocs.io", "doi": "10.5281/zenodo.3960624" } }, "stations": [ { "resolution": "daily", "dataset": "climate_summary", "station_id": "01048", "start_date": "1934-01-01T00:00:00+00:00", "end_date": "2025-03-19T00:00:00+00:00", "latitude": 51.1278, "longitude": 13.7543, "height": 228.0, "name": "Dresden-Klotzsche", "state": "Sachsen" } ], "values": [ { "station_id": "01048", "resolution": "daily", "dataset": "climate_summary", "parameter": "temperature_air_mean_2m", "date": "2020-01-01T00:00:00+00:00", "value": 2.4, "quality": 10.0 }, { "station_id": "01048", "resolution": "daily", "dataset": "climate_summary", "parameter": "temperature_air_mean_2m", "date": "2020-01-02T00:00:00+00:00", "value": 0.2, "quality": 10.0 } ] }
To Ogc Feature Collection
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "temperature_air_mean_2m"),
start_date="2020-01-01",
end_date="2020-01-02"
)
stations = request.filter_by_station_id(station_id="01048")
values = stations.values.all()
print(values.to_ogc_feature_collection(with_metadata=True))
{'metadata': {'provider': {'name_local': 'Deutscher Wetterdienst', 'name_english': 'German Weather Service', 'country': 'Germany', 'copyright': '© Deutscher Wetterdienst (DWD), Climate Data Center (CDC)', 'url': 'https://opendata.dwd.de/climate_environment/CDC/'}, 'producer': {'name': 'wetterdienst', 'version': '0.106.0', 'repository': 'https://github.com/earthobservations/wetterdienst', 'documentation': 'https://wetterdienst.readthedocs.io', 'doi': '10.5281/zenodo.3960624'}}, 'data': {'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {'resolution': 'daily', 'dataset': 'climate_summary', 'id': '01048', 'name': 'Dresden-Klotzsche', 'state': 'Sachsen', 'start_date': '1934-01-01T00:00:00+00:00', 'end_date': '2025-03-19T00:00:00+00:00'}, 'geometry': {'type': 'Point', 'coordinates': [13.7543, 51.1278, 228.0]}, 'values': [{'resolution': 'daily', 'dataset': 'climate_summary', 'parameter': 'temperature_air_mean_2m', 'date': '2020-01-01T00:00:00+00:00', 'value': 2.4, 'quality': 10.0}, {'resolution': 'daily', 'dataset': 'climate_summary', 'parameter': 'temperature_air_mean_2m', 'date': '2020-01-02T00:00:00+00:00', 'value': 0.2, 'quality': 10.0}]}]}}
To GeoJson
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "temperature_air_mean_2m"),
start_date="2020-01-01",
end_date="2020-01-02"
)
stations = request.filter_by_station_id(station_id="01048")
values = stations.values.all()
print(values.to_geojson(with_metadata=True))
{ "metadata": { "provider": { "name_local": "Deutscher Wetterdienst", "name_english": "German Weather Service", "country": "Germany", "copyright": "© Deutscher Wetterdienst (DWD), Climate Data Center (CDC)", "url": "https://opendata.dwd.de/climate_environment/CDC/" }, "producer": { "name": "wetterdienst", "version": "0.106.0", "repository": "https://github.com/earthobservations/wetterdienst", "documentation": "https://wetterdienst.readthedocs.io", "doi": "10.5281/zenodo.3960624" } }, "data": { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "resolution": "daily", "dataset": "climate_summary", "id": "01048", "name": "Dresden-Klotzsche", "state": "Sachsen", "start_date": "1934-01-01T00:00:00+00:00", "end_date": "2025-03-19T00:00:00+00:00" }, "geometry": { "type": "Point", "coordinates": [ 13.7543, 51.1278, 228.0 ] }, "values": [ { "resolution": "daily", "dataset": "climate_summary", "parameter": "temperature_air_mean_2m", "date": "2020-01-01T00:00:00+00:00", "value": 2.4, "quality": 10.0 }, { "resolution": "daily", "dataset": "climate_summary", "parameter": "temperature_air_mean_2m", "date": "2020-01-02T00:00:00+00:00", "value": 0.2, "quality": 10.0 } ] } ] } }
To CSV
from wetterdienst.provider.dwd.observation import DwdObservationRequest
request = DwdObservationRequest(
parameters=("daily", "kl", "temperature_air_mean_2m"),
start_date="2020-01-01",
end_date="2020-01-02"
)
stations = request.filter_by_station_id(station_id="01048")
values = stations.values.all()
print(values.to_csv())
station_id,resolution,dataset,parameter,date,value,quality 01048,daily,climate_summary,temperature_air_mean_2m,2020-01-01T00:00:00+00:00,2.4,10.0 01048,daily,climate_summary,temperature_air_mean_2m,2020-01-02T00:00:00+00:00,0.2,10.0
SQL
Querying data using SQL is provided by an in-memory DuckDB_ database. In order to explore what is possible, please have a look at the DuckDB SQL introduction.
The result data is provided through a virtual table called data
.
from wetterdienst import Settings
from wetterdienst.provider.dwd.observation import DwdObservationRequest
settings = Settings(ts_shape="long", ts_humanize=True, ts_convert_units=True) # defaults
request = DwdObservationRequest(
parameters=("hourly", "temperature_air", "temperature_air_mean_2m"),
start_date="2019-01-01",
end_date="2020-01-01",
settings=settings
)
stations = request.filter_by_station_id(station_id=[1048])
values = stations.values.all()
df = values.filter_by_sql("parameter='temperature_air_mean_2m' AND value < -7.0;")
print(df.head())
Export
Data can be exported to SQLite, DuckDB, InfluxDB, CrateDB and more targets. A target is identified by a connection string.
Examples:
- sqlite:///dwd.sqlite?table=weather
- duckdb:///dwd.duckdb?table=weather
- influxdb://localhost/?database=dwd&table=weather
- crate://localhost/?database=dwd&table=weather
from wetterdienst import Settings
from wetterdienst.provider.dwd.observation import DwdObservationRequest
settings = Settings(ts_shape="long", ts_humanize=True, ts_convert_units=True) # defaults
request = DwdObservationRequest(
parameters=("hourly", "temperature_air"),
start_date="2019-01-01",
end_date="2020-01-01",
settings=settings
)
stations = request.filter_by_station_id(station_id=[1048])
values = stations.values.all()
values.to_target("influxdb://localhost/?database=dwd&table=weather")
Caching
The backbone of wetterdienst uses fsspec caching. It requires to create a directory under /home
for the
most cases. If you are not allowed to write into /home
you will run into OSError
. For this purpose you can set
an environment variable WD_CACHE_DIR
to define the place where the caching directory should be created.
To find out where your cache is located you can use the following code:
/home/docs/.cache/wetterdienst
Or similarly with the cli:
FSSPEC
FSSPEC is used for flexible file caching. It relies on the two libraries requests and aiohttp. Aiohttp is used for asynchronous requests and may swallow some errors related to proxies, ssl or similar. Use the defined variable FSSPEC_CLIENT_KWARGS to pass your very own client kwargs to fsspec e.g.
from wetterdienst import Settings
from wetterdienst.provider.dwd.observation import DwdObservationRequest
settings = Settings(fsspec_client_kwargs={"trust_env": True}) # use proxy from environment variables
stations = DwdObservationRequest(
parameters=("hourly", "temperature_air"),
settings=settings
).filter_by_station_id(station_id=[1048])