From 366acf8a09be6930e25ed4e89565eecc09bee7a9 Mon Sep 17 00:00:00 2001 From: Sandor Kertesz Date: Thu, 6 Jun 2024 16:00:52 +0100 Subject: [PATCH] Fix rounding in grib resolution --- src/earthkit/data/readers/grib/metadata.py | 4 +++- tests/grib/test_grib_geography.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/earthkit/data/readers/grib/metadata.py b/src/earthkit/data/readers/grib/metadata.py index d51877a8..2998790c 100644 --- a/src/earthkit/data/readers/grib/metadata.py +++ b/src/earthkit/data/readers/grib/metadata.py @@ -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 diff --git a/tests/grib/test_grib_geography.py b/tests/grib/test_grib_geography.py index f76e0800..53744ab9 100644 --- a/tests/grib/test_grib_geography.py +++ b/tests/grib/test_grib_geography.py @@ -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):