Skip to content

Commit

Permalink
CHG: Divison criteria between current and expected warnings changed f…
Browse files Browse the repository at this point in the history
…rom time to urgency attribute
  • Loading branch information
stephan192 committed Sep 26, 2020
1 parent 8b29dae commit 60b37eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.3 (2020-09-26)
### Added
- Urgency attribute added to warning dictionary
### Changed
- Divison criteria between current and expected warnings changed from time to urgency attribute

## 1.0.2 (2020-04-25)
### Added
- Input validation
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Python client to retrieve data provided by DWD via their geoserver WFS API

The DWD (Deutscher Wetterdienst) publishes various weather information for Germany.
The data is published via their [Geoserver](https://maps.dwd.de). For a more information have a look [here](https://www.dwd.de/DE/leistungen/geowebservice/geowebservice.html) and [here](https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities).
The data is published via their [Geoserver](https://maps.dwd.de). For a more information have a look [here](https://www.dwd.de/DE/leistungen/geodienste/geodienste.html) and [here](https://maps.dwd.de/geoserver/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities).

## Install
```
Expand Down Expand Up @@ -100,7 +100,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00
Range: 0 (=no warning) to 4 (=extreme weather)

- **`current_warnings : list of dicts`**
Dictionary containing all currently active warnings
Dictionary containing all currently active warnings ("Wetterwarnungen", urgency="immediate")

See section warning dictionary for more details

Expand All @@ -110,7 +110,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00
Range: 0 (=no warning) to 4 (=extreme weather)

- **`expected_warnings : list of dicts`**
Dictionary containung all expected warnings
Dictionary containing all expected warnings ("Vorabinformationen", urgency="future")

See section warning dictionary for more details
expected_warnings : dict
Expand All @@ -127,6 +127,8 @@ Last update: 2020-04-18 17:57:29.274000+00:00

- **`event_code: int`**
Integer representation of the warning event

For more details have a look [here](https://www.dwd.de/DE/leistungen/opendata/help/warnungen/gesamtueberblickII.pdf?__blob=publicationFile&v=3)

- **`headline : str`**
The official warning headline
Expand All @@ -137,6 +139,9 @@ Last update: 2020-04-18 17:57:29.274000+00:00
- **`instruction : str`**
Instructions and safety notices

- **`urgency : str`**
Warning urgency (either "immediate" or "future")

- **`level : int`**
Warning level

Expand All @@ -145,7 +150,7 @@ Last update: 2020-04-18 17:57:29.274000+00:00
- **`parameters : dict`**
Dictionary containing warning specific parameters

For more details have a look [here](https://www.dwd.de/DE/leistungen/gds/help/warnungen/cap_dwd_profile_en_pdf.pdf)
For more details have a look [here](https://www.dwd.de/DE/leistungen/opendata/help/warnungen/cap_dwd_profile_de_pdf_1_11.pdf?__blob=publicationFile&v=3)

- **`color : str`**
Warning color formatted #rrggbb
21 changes: 8 additions & 13 deletions dwdwfsapi/weatherwarnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def convert_warning_data(data_in):
"headline": None,
"description": None,
"instruction": None,
"urgency": "immediate",
"level": 0,
"parameters": None,
"color": "#000000",
Expand Down Expand Up @@ -62,7 +63,10 @@ def convert_warning_data(data_in):
if "instruction" in data_in:
data_out["instruction"] = data_in["instruction"]
if "urgency" in data_in:
data_out["urgency"] = data_in["urgency"]
if data_in["urgency"].lower() == "future":
data_out["urgency"] = "future"
else:
data_out["urgency"] = "immediate"
if "severity" in data_in:
try:
if data_in["severity"].lower() in weather_severity_mapping:
Expand Down Expand Up @@ -128,6 +132,8 @@ class DwdWeatherWarningsAPI:
a details warning description
instruction : str
instructions and safety notices
urgency: str
warning urgency (either "immediate" or "future")
level : int
warning level (0 - 4)
parameters : dict
Expand Down Expand Up @@ -285,17 +291,7 @@ def __parse_result(self, json_obj):
for feature in json_obj["features"]:
warning = convert_warning_data(feature["properties"])

current_time = datetime.datetime.now(datetime.timezone.utc)
# pylint: disable=bad-continuation
if (
warning["end_time"] is not None
and current_time > warning["end_time"]
):
continue

if (
warning["urgency"] == "Immediate"
):
if warning["urgency"] == "immediate":
current_warnings.append(warning)
current_maxlevel = max(
warning["level"], current_maxlevel
Expand All @@ -305,7 +301,6 @@ def __parse_result(self, json_obj):
expected_maxlevel = max(
warning["level"], expected_maxlevel
)
# pylint: enable=bad-continuation

self.current_warning_level = current_maxlevel
self.current_warnings = current_warnings
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
EMAIL = "[email protected]"
AUTHOR = "stephan192"
REQUIRES_PYTHON = ">=3.6"
VERSION = "1.0.2"
VERSION = "1.0.3"

# Define required packages
REQUIRES = ["requests>=2.23.0,<3", "ciso8601>=2.1.3,<3", "urllib3>=1.25.8,<2"]
Expand Down

0 comments on commit 60b37eb

Please sign in to comment.