Skip to content

Commit

Permalink
Fix Geosphere Observation parsing of dates in values -> thanks to @mh…
Browse files Browse the repository at this point in the history
…uber89 who discovered the bug and delivered a fix
  • Loading branch information
gutzbenj committed Jul 30, 2023
1 parent 3caa408 commit 5bccb01
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Development
***********

- Revise type hints for parameter and station_id
- Fix Geosphere Observation parsing of dates in values -> thanks to @mhuber89 who discovered the bug and delivered a fix

0.58.1 (26.07.2023)
*******************
Expand Down
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions tests/provider/geosphere/observation/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import datetime

import pytest

from wetterdienst import Parameter
from wetterdienst.provider.geosphere.observation import GeosphereObservationRequest, GeosphereObservationResolution


@pytest.mark.remote
def test_geopshere_observation_api():
"""Test the correct parsing of data, especially the dates -> thanks @mhuber89 for the discovery and fix"""
stations_at = GeosphereObservationRequest(
parameter=[Parameter.WIND_SPEED],
resolution=GeosphereObservationResolution.HOURLY,
start_date=datetime(2022, 6, 1),
end_date=datetime(2022, 6, 2),
)
station_at = stations_at.filter_by_station_id("4821")
df = station_at.values.all().df
assert df.get_column("value").is_not_null().sum() == 25
4 changes: 1 addition & 3 deletions wetterdienst/provider/geosphere/observation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,7 @@ def _collect_station_parameter(self, station_id: str, parameter: Enum, dataset:
)

return df.with_columns(
pl.col(Columns.DATE.value)
.str.strptime(pl.Datetime, fmt="%Y-%m-%dT%H:%M+%H:%M")
.dt.replace_time_zone("UTC"),
pl.col(Columns.DATE.value).str.strptime(pl.Datetime, fmt="%Y-%m-%dT%H:%M+%Z").dt.replace_time_zone("UTC"),
pl.col(Columns.PARAMETER.value).str.to_lowercase(),
pl.lit(station_id).alias(Columns.STATION_ID.value),
pl.lit(None, pl.Float64).alias(Columns.QUALITY.value),
Expand Down

0 comments on commit 5bccb01

Please sign in to comment.