-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eb6ea7
commit a4e1381
Showing
4 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import polars as pl | ||
|
||
class TestLocations: | ||
|
||
def __getLocations(self): | ||
# Locations are Canary Wharf and Manchester | ||
return pl.DataFrame( | ||
{"lat": [51.5054, 53.4808], "lon": [-0.027176, 2.2426]} | ||
).to_arrow() | ||
|
||
def test_with_zero_hour_run_and_hour_3(self, resource): | ||
from gribtoarrow import GribReader | ||
|
||
locations = self.__getLocations() | ||
|
||
reader = GribReader( | ||
str(resource) + "/gep01.t00z.pgrb2a.0p50.f003" | ||
).withLocations(locations) | ||
|
||
df = pl.concat( | ||
pl.from_arrow(message.getDataWithLocations()) for message in reader | ||
) | ||
|
||
date_hours = df.select(pl.col("datetime").dt.hour().unique())['datetime'].to_list() | ||
forecast_hours = df.select(pl.col("forecast_date").dt.hour().unique())['forecast_date'].to_list() | ||
|
||
assert all(x == 3 for x in date_hours) | ||
assert all(x == 0 for x in forecast_hours) | ||
|
||
def test_with_18_hour_run_and_hour_6(self, resource): | ||
from gribtoarrow import GribReader | ||
|
||
locations = self.__getLocations() | ||
|
||
reader = GribReader( | ||
str(resource) + "/ecmwfaifs0h.grib" | ||
).withLocations(locations) | ||
|
||
df = pl.concat( | ||
pl.from_arrow(message.getDataWithLocations()) for message in reader | ||
) | ||
|
||
date_hours = df.select(pl.col("datetime").dt.hour().unique())['datetime'].to_list() | ||
forecast_hours = df.select(pl.col("forecast_date").dt.hour().unique())['forecast_date'].to_list() | ||
|
||
assert all(x == 0 for x in date_hours) | ||
assert all(x == 18 for x in forecast_hours) | ||
|