Skip to content

Commit

Permalink
DWD Road: Use correct 15 minute resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Oct 6, 2024
1 parent 9bb43fe commit 33c59b5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 37 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
Development
***********

- DWD Road: Use correct 15 minute resolution

0.96.0 (05.10.2024)
*******************

- Bump polars to `>=1.0.0`
- Change `DWDMosmixValues` and `DWDDmoValues` to follow the core `_collect_station_parameter` method
- Allow only single issue retrieving with `DWDMosmixRequest` and `DWDDmoRequest`
Expand Down
4 changes: 2 additions & 2 deletions docs/data/coverage/dwd/road.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Overview
********

- weather data from German highway "road" stations.
- 10 minute resolution
- 15 minute resolution
- historical period

Structure
Expand All @@ -14,4 +14,4 @@ Structure
.. toctree::
:maxdepth: 1

road/minute_10
road/minute_15
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Minute_10
Minute_15
#########

Metadata
Expand All @@ -9,14 +9,14 @@ Metadata
:stub-columns: 1

* - original name
- 10_minutes
- 15_minutes
* - url
- `here <https://opendata.dwd.de/weather/weather_reports/road_weather_stations/>`_

Datasets
********

Minute_10
Minute_15
=========

Metadata
Expand All @@ -27,13 +27,13 @@ Metadata
:stub-columns: 1

* - original name
- minute_10
- minute_15
* - url
- `here <https://opendata.dwd.de/weather/weather_reports/road_weather_stations/>`_
* - description file
- missing
* - description
- 10 minute road weather data from DWD
- 15 minute road weather data from DWD

Parameters
----------
Expand Down
10 changes: 3 additions & 7 deletions tests/provider/dwd/road/test_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import polars as pl
import pytest

from wetterdienst import Settings
Expand All @@ -10,9 +9,8 @@

@pytest.mark.skipif(not ensure_eccodes() or not ensure_pdbufr(), reason="eccodes and/or pdbufr not installed")
@pytest.mark.remote
@pytest.mark.parametrize("parameter", ("minute_10", "temperature_air_mean_2m"))
def test_dwd_road_weather(parameter):
request = DwdRoadRequest(parameter).filter_by_station_id("A006")
def test_dwd_road_weather():
request = DwdRoadRequest(parameter="temperature_air_mean_2m").filter_by_station_id("A006")
item = request.to_dict()["stations"][0]
assert item == {
"station_id": "A006",
Expand All @@ -30,9 +28,7 @@ def test_dwd_road_weather(parameter):
"road_type": 1,
"station_group": "KK",
}
values = (
request.values.all().df.drop_nulls(subset="value").filter(pl.col("parameter").eq("temperature_air_mean_2m"))
)
values = request.values.all().df.drop_nulls(subset="value")
assert 230 <= values.get_column("value").min() <= 313 # approx. -+40 K


Expand Down
46 changes: 23 additions & 23 deletions wetterdienst/provider/dwd/road/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class DwdRoadParameter(DatasetTreeCore):
measured by dwd road weather stations
"""

class MINUTE_10(DatasetTreeCore):
class MINUTE_10(Enum):
class MINUTE_15(DatasetTreeCore):
class MINUTE_15(Enum):
# class ROAD_WEATHER(Enum):
HUMIDITY = "relativeHumidity"
PRECIPITATION_FORM = "precipitationType"
Expand All @@ -64,21 +64,21 @@ class MINUTE_10(Enum):
WIND_SPEED = "windSpeed"
# INTENSITY_OF_PHENOMENA = "intensityOfPhenomena" # noqa: ERA001

HUMIDITY = MINUTE_10.HUMIDITY
PRECIPITATION_FORM = MINUTE_10.PRECIPITATION_FORM
PRECIPITATION_HEIGHT = MINUTE_10.PRECIPITATION_HEIGHT
PRECIPITATION_INTENSITY = MINUTE_10.PRECIPITATION_INTENSITY
ROAD_SURFACE_CONDITION = MINUTE_10.ROAD_SURFACE_CONDITION
TEMPERATURE_AIR_MEAN_2M = MINUTE_10.TEMPERATURE_AIR_MEAN_2M
TEMPERATURE_DEW_POINT_MEAN_2M = MINUTE_10.TEMPERATURE_DEW_POINT_MEAN_2M
TEMPERATURE_SURFACE_MEAN = MINUTE_10.TEMPERATURE_SURFACE_MEAN
VISIBILITY_RANGE = MINUTE_10.VISIBILITY_RANGE
WATER_FILM_THICKNESS = MINUTE_10.WATER_FILM_THICKNESS
WIND_DIRECTION = MINUTE_10.WIND_DIRECTION
WIND_DIRECTION_GUST_MAX = MINUTE_10.WIND_DIRECTION_GUST_MAX
WIND_GUST_MAX = MINUTE_10.WIND_GUST_MAX
WIND_SPEED = MINUTE_10.WIND_SPEED
# INTENSITY_OF_PHENOMENA = MINUTE_10.INTENSITY_OF_PHENOMENA # noqa: ERA001
HUMIDITY = MINUTE_15.HUMIDITY
PRECIPITATION_FORM = MINUTE_15.PRECIPITATION_FORM
PRECIPITATION_HEIGHT = MINUTE_15.PRECIPITATION_HEIGHT
PRECIPITATION_INTENSITY = MINUTE_15.PRECIPITATION_INTENSITY
ROAD_SURFACE_CONDITION = MINUTE_15.ROAD_SURFACE_CONDITION
TEMPERATURE_AIR_MEAN_2M = MINUTE_15.TEMPERATURE_AIR_MEAN_2M
TEMPERATURE_DEW_POINT_MEAN_2M = MINUTE_15.TEMPERATURE_DEW_POINT_MEAN_2M
TEMPERATURE_SURFACE_MEAN = MINUTE_15.TEMPERATURE_SURFACE_MEAN
VISIBILITY_RANGE = MINUTE_15.VISIBILITY_RANGE
WATER_FILM_THICKNESS = MINUTE_15.WATER_FILM_THICKNESS
WIND_DIRECTION = MINUTE_15.WIND_DIRECTION
WIND_DIRECTION_GUST_MAX = MINUTE_15.WIND_DIRECTION_GUST_MAX
WIND_GUST_MAX = MINUTE_15.WIND_GUST_MAX
WIND_SPEED = MINUTE_15.WIND_SPEED
# INTENSITY_OF_PHENOMENA = MINUTE_15.INTENSITY_OF_PHENOMENA # noqa: ERA001


class DwdRoadUnit(DatasetTreeCore):
Expand All @@ -87,8 +87,8 @@ class DwdRoadUnit(DatasetTreeCore):
measured by dwd road weather stations
"""

class MINUTE_10(DatasetTreeCore):
class MINUTE_10(UnitEnum):
class MINUTE_15(DatasetTreeCore):
class MINUTE_15(UnitEnum):
HUMIDITY = OriginUnit.PERCENT.value, SIUnit.PERCENT.value
PRECIPITATION_FORM = OriginUnit.DIMENSIONLESS.value, OriginUnit.DIMENSIONLESS.value
PRECIPITATION_HEIGHT = OriginUnit.MILLIMETER.value, SIUnit.KILOGRAM_PER_SQUARE_METER.value
Expand All @@ -107,15 +107,15 @@ class MINUTE_10(UnitEnum):


class DwdRoadResolution(Enum):
MINUTE_10 = Resolution.MINUTE_10.value
MINUTE_15 = Resolution.MINUTE_15.value


class DwdRoadPeriod(Enum):
HISTORICAL = Period.HISTORICAL.value


class DwdRoadDataset(Enum):
MINUTE_10 = Resolution.MINUTE_10.value
MINUTE_15 = Resolution.MINUTE_15.value


class DwdRoadStationGroup(Enum):
Expand Down Expand Up @@ -181,7 +181,7 @@ def _collect_station_parameter(self, station_id: str, parameter: Enum, dataset:
)
station_group = DwdRoadStationGroup(station_group)
if parameter == dataset:
parameters = [par.value for par in DwdRoadParameter.MINUTE_10 if hasattr(par, "name")]
parameters = [par.value for par in DwdRoadParameter.MINUTE_15 if hasattr(par, "name")]
else:
parameters = [parameter.value]
try:
Expand Down Expand Up @@ -423,7 +423,7 @@ def __init__(
):
super().__init__(
parameter=parameter,
resolution=Resolution.MINUTE_10,
resolution=Resolution.MINUTE_15,
period=Period.HISTORICAL,
start_date=start_date,
end_date=end_date,
Expand Down

0 comments on commit 33c59b5

Please sign in to comment.