Python Examples

Python Examples#

DWD#

Observation#

Get available parameters for daily historical data of DWD:

1from wetterdienst.provider.dwd.observation import DwdObservationRequest
2
3metadata = DwdObservationRequest.discover(
4    resolutions="daily",
5)
6
7metadata
{'daily': {'climate_summary': [{'name': 'wind_gust_max',
    'name_original': 'fx',
    'unit_type': 'speed',
    'unit': 'meter_per_second'},
   {'name': 'wind_speed',
    'name_original': 'fm',
    'unit_type': 'speed',
    'unit': 'meter_per_second'},
   {'name': 'precipitation_height',
    'name_original': 'rsk',
    'unit_type': 'precipitation',
    'unit': 'millimeter'},
   {'name': 'precipitation_form',
    'name_original': 'rskf',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'sunshine_duration',
    'name_original': 'sdk',
    'unit_type': 'time',
    'unit': 'hour'},
   {'name': 'snow_depth',
    'name_original': 'shk_tag',
    'unit_type': 'length_short',
    'unit': 'centimeter'},
   {'name': 'cloud_cover_total',
    'name_original': 'nm',
    'unit_type': 'fraction',
    'unit': 'one_eighth'},
   {'name': 'pressure_vapor',
    'name_original': 'vpm',
    'unit_type': 'pressure',
    'unit': 'hectopascal'},
   {'name': 'pressure_air_site',
    'name_original': 'pm',
    'unit_type': 'pressure',
    'unit': 'hectopascal'},
   {'name': 'temperature_air_mean_2m',
    'name_original': 'tmk',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'humidity',
    'name_original': 'upm',
    'unit_type': 'fraction',
    'unit': 'percent'},
   {'name': 'temperature_air_max_2m',
    'name_original': 'txk',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_air_min_2m',
    'name_original': 'tnk',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_air_min_0_05m',
    'name_original': 'tgk',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'}],
  'precipitation_more': [{'name': 'precipitation_height',
    'name_original': 'rs',
    'unit_type': 'precipitation',
    'unit': 'millimeter'},
   {'name': 'precipitation_form',
    'name_original': 'rsf',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'snow_depth',
    'name_original': 'sh_tag',
    'unit_type': 'length_short',
    'unit': 'centimeter'},
   {'name': 'snow_depth_new',
    'name_original': 'nsh_tag',
    'unit_type': 'length_short',
    'unit': 'centimeter'}],
  'solar': [{'name': 'radiation_sky_long_wave',
    'name_original': 'atmo_strahl',
    'unit_type': 'energy_per_area',
    'unit': 'joule_per_square_centimeter'},
   {'name': 'radiation_sky_short_wave_diffuse',
    'name_original': 'fd_strahl',
    'unit_type': 'energy_per_area',
    'unit': 'joule_per_square_centimeter'},
   {'name': 'radiation_global',
    'name_original': 'fg_strahl',
    'unit_type': 'energy_per_area',
    'unit': 'joule_per_square_centimeter'},
   {'name': 'sunshine_duration',
    'name_original': 'sd_strahl',
    'unit_type': 'time',
    'unit': 'hour'}],
  'temperature_soil': [{'name': 'temperature_soil_mean_0_02m',
    'name_original': 'v_te002m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_soil_mean_0_05m',
    'name_original': 'v_te005m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_soil_mean_0_1m',
    'name_original': 'v_te010m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_soil_mean_0_2m',
    'name_original': 'v_te020m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_soil_mean_0_5m',
    'name_original': 'v_te050m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'},
   {'name': 'temperature_soil_mean_1m',
    'name_original': 'v_te100m',
    'unit_type': 'temperature',
    'unit': 'degree_celsius'}],
  'water_equivalent': [{'name': 'snow_depth_excelled',
    'name_original': 'ash_6',
    'unit_type': 'length_short',
    'unit': 'centimeter'},
   {'name': 'snow_depth',
    'name_original': 'sh_tag',
    'unit_type': 'length_short',
    'unit': 'centimeter'},
   {'name': 'water_equivalent_snow_depth',
    'name_original': 'wash_6',
    'unit_type': 'precipitation',
    'unit': 'millimeter'},
   {'name': 'water_equivalent_snow_depth_excelled',
    'name_original': 'waas_6',
    'unit_type': 'precipitation',
    'unit': 'millimeter'}],
  'weather_phenomena': [{'name': 'count_weather_type_fog',
    'name_original': 'nebel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_thunder',
    'name_original': 'gewitter',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_storm_strong_wind',
    'name_original': 'sturm_6',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_storm_stormier_wind',
    'name_original': 'sturm_8',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_dew',
    'name_original': 'tau',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_glaze',
    'name_original': 'glatteis',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_ripe',
    'name_original': 'reif',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_sleet',
    'name_original': 'graupel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_hail',
    'name_original': 'hagel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'}],
  'weather_phenomena_more': [{'name': 'count_weather_type_sleet',
    'name_original': 'rr_graupel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_hail',
    'name_original': 'rr_hagel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_fog',
    'name_original': 'rr_nebel',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'},
   {'name': 'count_weather_type_thunder',
    'name_original': 'rr_gewitter',
    'unit_type': 'dimensionless',
    'unit': 'dimensionless'}]}}

Get stations for daily historical precipitation:

 1from wetterdienst.provider.dwd.observation import DwdObservationRequest
 2
 3request = DwdObservationRequest(
 4    parameters=("daily", "precipitation_more"),
 5    periods="historical",
 6)
 7
 8stations = request.all()
 9df = stations.df
10df
shape: (6_156, 10)
resolutiondatasetstation_idstart_dateend_datelatitudelongitudeheightnamestate
strstrstrdatetime[μs, UTC]datetime[μs, UTC]f64f64f64strstr
"daily""precipitation_more""00001"1912-01-01 00:00:00 UTC1986-06-30 00:00:00 UTC47.84138.8493478.0"Aach""Baden-Württemberg"
"daily""precipitation_more""00002"1951-01-01 00:00:00 UTC2006-12-31 00:00:00 UTC50.80666.0996138.0"Aachen (Kläranlage)""Nordrhein-Westfalen"
"daily""precipitation_more""00003"1891-01-01 00:00:00 UTC2011-03-31 00:00:00 UTC50.78276.0941202.0"Aachen""Nordrhein-Westfalen"
"daily""precipitation_more""00004"1951-01-01 00:00:00 UTC1979-10-31 00:00:00 UTC50.76836.1207243.0"Aachen-Brand""Nordrhein-Westfalen"
"daily""precipitation_more""00006"1982-11-01 00:00:00 UTC2026-07-08 00:00:00 UTC48.836110.0598455.0"Aalen-Unterrombach""Baden-Württemberg"
"daily""precipitation_more""20107"2025-03-27 00:00:00 UTC2026-07-08 00:00:00 UTC49.96876.8272311.0"Wittlich-Bergweiler""Rheinland-Pfalz"
"daily""precipitation_more""20108"2025-05-01 00:00:00 UTC2026-07-08 00:00:00 UTC51.15436.504956.0"Mönchengladbach-Schelsen""Nordrhein-Westfalen"
"daily""precipitation_more""20110"1969-01-01 00:00:00 UTC2005-07-31 00:00:00 UTC52.318311.567764.0"Colbitz""Sachsen-Anhalt"
"daily""precipitation_more""20189"2025-10-01 00:00:00 UTC2026-04-30 00:00:00 UTC47.675912.47687.0"Reit im Winkl (Kaiserweg)""Bayern"
"daily""precipitation_more""20191"2025-09-01 00:00:00 UTC2026-07-08 00:00:00 UTC50.923814.357375.0"Sebnitz-Hinterhermsdorf""Sachsen"

Get data for a dataset:

 1from wetterdienst.provider.dwd.observation import DwdObservationRequest
 2
 3request = DwdObservationRequest(
 4    parameters=("daily", "precipitation_more"),
 5    periods="historical",
 6)
 7
 8first_values = next(request.all().values.query())
 9df = first_values.df
10df
shape: (80_073, 7)
station_idresolutiondatasetparameterdatevaluequality
strstrstrstrdatetime[μs, UTC]f64f64
"00001""daily""precipitation_more""precipitation_form"1912-01-01 00:00:00 UTC0.01.0
"00001""daily""precipitation_more""precipitation_form"1912-01-02 00:00:00 UTC1.01.0
"00001""daily""precipitation_more""precipitation_form"1912-01-03 00:00:00 UTC0.01.0
"00001""daily""precipitation_more""precipitation_form"1912-01-04 00:00:00 UTC1.01.0
"00001""daily""precipitation_more""precipitation_form"1912-01-05 00:00:00 UTC7.01.0
"00001""daily""precipitation_more""snow_depth_new"1986-06-26 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""snow_depth_new"1986-06-27 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""snow_depth_new"1986-06-28 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""snow_depth_new"1986-06-29 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""snow_depth_new"1986-06-30 00:00:00 UTC0.010.0

Get data for a parameter:

 1from wetterdienst.provider.dwd.observation import DwdObservationRequest
 2
 3request = DwdObservationRequest(
 4    parameters=("daily", "climate_summary", "precipitation_height"),
 5    periods="historical",
 6)
 7
 8first_values = next(request.all().values.query())
 9df = first_values.df
10df
shape: (17_347, 7)
station_idresolutiondatasetparameterdatevaluequality
strstrstrstrdatetime[μs, UTC]f64f64
"00001""daily""climate_summary""precipitation_height"1937-01-01 00:00:00 UTC0.05.0
"00001""daily""climate_summary""precipitation_height"1937-01-02 00:00:00 UTC0.05.0
"00001""daily""climate_summary""precipitation_height"1937-01-03 00:00:00 UTC0.05.0
"00001""daily""climate_summary""precipitation_height"1937-01-04 00:00:00 UTC0.05.0
"00001""daily""climate_summary""precipitation_height"1937-01-05 00:00:00 UTC0.05.0
"00001""daily""climate_summary""precipitation_height"1986-06-26 00:00:00 UTC0.010.0
"00001""daily""climate_summary""precipitation_height"1986-06-27 00:00:00 UTC0.010.0
"00001""daily""climate_summary""precipitation_height"1986-06-28 00:00:00 UTC0.010.0
"00001""daily""climate_summary""precipitation_height"1986-06-29 00:00:00 UTC0.010.0
"00001""daily""climate_summary""precipitation_height"1986-06-30 00:00:00 UTC0.010.0

Get data for a parameter from another dataset:

 1from wetterdienst.provider.dwd.observation import DwdObservationRequest
 2
 3request = DwdObservationRequest(
 4    parameters=[("daily", "precipitation_more", "precipitation_height")],
 5    periods="historical",
 6)
 7
 8first_values = next(request.all().values.query())
 9df = first_values.df
10df
shape: (26_479, 7)
station_idresolutiondatasetparameterdatevaluequality
strstrstrstrdatetime[μs, UTC]f64f64
"00001""daily""precipitation_more""precipitation_height"1912-01-01 00:00:00 UTC0.01.0
"00001""daily""precipitation_more""precipitation_height"1912-01-02 00:00:00 UTC0.21.0
"00001""daily""precipitation_more""precipitation_height"1912-01-03 00:00:00 UTC0.01.0
"00001""daily""precipitation_more""precipitation_height"1912-01-04 00:00:00 UTC1.01.0
"00001""daily""precipitation_more""precipitation_height"1912-01-05 00:00:00 UTC2.11.0
"00001""daily""precipitation_more""precipitation_height"1986-06-26 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""precipitation_height"1986-06-27 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""precipitation_height"1986-06-28 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""precipitation_height"1986-06-29 00:00:00 UTC0.010.0
"00001""daily""precipitation_more""precipitation_height"1986-06-30 00:00:00 UTC0.010.0

Mosmix#

Get stations for MOSMIX-SMALL:

1from wetterdienst.provider.dwd.mosmix import DwdMosmixRequest
2
3request = DwdMosmixRequest(
4    parameters=("hourly", "small"),
5)
6
7stations = request.all()
8df = stations.df
9df
shape: (5_649, 11)
resolutiondatasetstation_idicao_idstart_dateend_datelatitudelongitudeheightnamestate
strstrstrstrdatetime[μs, UTC]datetime[μs, UTC]f64f64f64strstr
"hourly""small""01001""ENJA"nullnull70.93-8.6710.0"JAN MAYEN"null
"hourly""small""01008""ENSB"nullnull78.2515.4729.0"SVALBARD"null
"hourly""small""01025"nullnullnull69.6818.9210.0"TROMSOE"null
"hourly""small""01028""ENBJ"nullnull74.5219.0216.0"BJORNOYA"null
"hourly""small""01049""ENAT"nullnull69.9823.373.0"ALTA LUFTHAVN"null
"hourly""small""Z944"nullnullnull47.6512.821615.0"WARTSTEINHUETTE"null
"hourly""small""Z946"nullnullnull47.5712.971420.0"KUEHROINT"null
"hourly""small""Z947"nullnullnull47.4812.972520.0"FUNTENSEETAUERN"null
"hourly""small""Z948"nullnullnull47.6213.0660.0"HOELLGRABEN"null
"hourly""small""Z949"nullnullnull47.5813.021200.0"JENNER"null

Get data for MOSMIX-LARGE:

1from wetterdienst.provider.dwd.mosmix import DwdMosmixRequest
2
3stations = DwdMosmixRequest(
4    parameters=("hourly", "large"),
5)
6
7stations = request.all()
8df = stations.df
9df
shape: (5_649, 11)
resolutiondatasetstation_idicao_idstart_dateend_datelatitudelongitudeheightnamestate
strstrstrstrdatetime[μs, UTC]datetime[μs, UTC]f64f64f64strstr
"hourly""small""01001""ENJA"nullnull70.93-8.6710.0"JAN MAYEN"null
"hourly""small""01008""ENSB"nullnull78.2515.4729.0"SVALBARD"null
"hourly""small""01025"nullnullnull69.6818.9210.0"TROMSOE"null
"hourly""small""01028""ENBJ"nullnull74.5219.0216.0"BJORNOYA"null
"hourly""small""01049""ENAT"nullnull69.9823.373.0"ALTA LUFTHAVN"null
"hourly""small""Z944"nullnullnull47.6512.821615.0"WARTSTEINHUETTE"null
"hourly""small""Z946"nullnullnull47.5712.971420.0"KUEHROINT"null
"hourly""small""Z947"nullnullnull47.4812.972520.0"FUNTENSEETAUERN"null
"hourly""small""Z948"nullnullnull47.6213.0660.0"HOELLGRABEN"null
"hourly""small""Z949"nullnullnull47.5813.021200.0"JENNER"null

Radar#

Sites#

Retrieve information about all OPERA radar sites.

1from wetterdienst.provider.eumetnet.opera.sites import OperaRadarSites
2
3# Acquire information for all OPERA sites.
4sites = OperaRadarSites().all()
5print(f"Number of OPERA radar sites: {len(sites)}")
6
7# Acquire information for a specific OPERA site.
8site_ukdea = OperaRadarSites().by_odim_code("ukdea")
9site_ukdea
Number of OPERA radar sites: 205
{'number': 1312,
 'country': 'United Kingdom',
 'countryid': 'EGRR61',
 'oldcountryid': 'UK61',
 'wmocode': 3859,
 'wigosid': None,
 'odimcode': 'ukdea',
 'location': 'Dean Hill',
 'status': True,
 'latitude': 51.0307,
 'longitude': -1.6534,
 'heightofstation': 155.0,
 'band': 'C',
 'doppler': True,
 'polarization': 'D',
 'maxrange': 255,
 'startyear': 2005,
 'heightantenna': 180.0,
 'diametrantenna': 3.66,
 'beam': 1.0,
 'gain': 43.0,
 'frequency': 5.627,
 'stratus': None,
 'cirusnimbus': None,
 'wrwp': None}

Retrieve information about the DWD radar sites.

1from wetterdienst.provider.dwd.radar.api import DwdRadarSites
2
3# Acquire information for a specific site.
4site_asb = DwdRadarSites().by_odim_code("ASB")
5site_asb
{'number': 1389,
 'country': 'Germany',
 'countryid': 'EDZW40',
 'oldcountryid': 'DL40',
 'wmocode': 10103,
 'wigosid': None,
 'odimcode': 'deasb',
 'location': 'Isle of Borkum',
 'status': True,
 'latitude': 53.564,
 'longitude': 6.7482,
 'heightofstation': 4.0,
 'band': 'C',
 'doppler': True,
 'polarization': 'S',
 'maxrange': 180,
 'startyear': 2018,
 'heightantenna': 36.2,
 'diametrantenna': 2.4,
 'beam': 1.57,
 'gain': 41.55,
 'frequency': 5.64,
 'stratus': None,
 'cirusnimbus': None,
 'wrwp': None}

Data#

To use DWDRadarRequest, you have to provide a RadarParameter, which designates the type of radar data you want to obtain. There is radar data available at different locations within the DWD data repository:

For RADOLAN_CDC-data, the time resolution parameter (either hourly or daily) must be specified.

The date_times (list of datetimes or strings) or a start_date and end_date parameters can optionally be specified to obtain data from specific points in time.

For RADOLAN_CDC-data, datetimes are rounded to HH:50min, as the data is packaged for this minute step.

This is an example on how to acquire RADOLAN_CDC data using wetterdienst and process it using wradlib.

For more examples, please have a look at examples/provider/dwd/radar.

 1from wetterdienst.provider.dwd.radar import DwdRadarValues, DwdRadarParameter, DwdRadarResolution
 2import wradlib as wrl
 3
 4radar = DwdRadarValues(
 5    parameter=DwdRadarParameter.RADOLAN_CDC,
 6    resolution=DwdRadarResolution.DAILY,
 7    start_date="2020-09-04T12:00:00",
 8    end_date="2020-09-04T12:00:00"
 9)
10
11for item in radar.query():
12    # Decode data using wradlib.
13    data, attributes = wrl.io.read_radolan_composite(item.data)
14
15    # Do something with the data (numpy.ndarray) here.
16    break
17    
18attributes
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[10], line 2
      1 from wetterdienst.provider.dwd.radar import DwdRadarValues, DwdRadarParameter, DwdRadarResolution
----> 2 import wradlib as wrl
      3 
      4 radar = DwdRadarValues(
      5     parameter=DwdRadarParameter.RADOLAN_CDC,

ModuleNotFoundError: No module named 'wradlib'