Skip to content

Commit

Permalink
Fix rounding in grib resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz committed Jun 6, 2024
1 parent 0603bc5 commit 366acf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/earthkit/data/readers/grib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ def resolution(self):
if grid_type in ("reduced_gg", "reduced_rotated_gg"):
return self.metadata.get("gridName")

if grid_type == "regular_ll":
if grid_type in ("regular_ll", "rotated_ll"):
x = self.metadata.get("DxInDegrees")
y = self.metadata.get("DyInDegrees")
x = round(x * 1_000_000) / 1_000_000
y = round(y * 1_000_000) / 1_000_000
assert x == y, (x, y)
return x

Expand Down
1 change: 1 addition & 0 deletions tests/grib/test_grib_geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def test_grib_projection_mercator(fl_type, array_backend):
(earthkit_examples_file("test.grib"), 4.0),
(earthkit_test_data_file("rgg_small_subarea_cellarea_ref.grib"), "O1280"),
(earthkit_test_data_file("rotated_N32_subarea.grib"), "N32"),
(earthkit_test_data_file("rotated_wind_20x20.grib"), 20),
],
)
def test_grib_resolution(path, expected_value):
Expand Down

0 comments on commit 366acf8

Please sign in to comment.