diff --git a/earthkit/data/readers/grib/metadata.py b/earthkit/data/readers/grib/metadata.py index af4ea5c3..d591244d 100644 --- a/earthkit/data/readers/grib/metadata.py +++ b/earthkit/data/readers/grib/metadata.py @@ -365,6 +365,12 @@ class RestrictedGribMetadata(GribMetadata): EKD_NAMESPACE = "grib" INTERNAL_KEYS = [ + "minimum", + "maximum", + "average", + "standardDeviation", + "skewness", + "kurtosis", "min", "max", "avg", diff --git a/tests/core/test_metadata.py b/tests/core/test_metadata.py index 598d8810..7e752d9f 100644 --- a/tests/core/test_metadata.py +++ b/tests/core/test_metadata.py @@ -122,19 +122,22 @@ def test_grib_metadata_get(): ds = from_source("file", earthkit_examples_file("test.grib")) md = ds[0].metadata() - assert len(md) == 192 + # the number/order of metadata keys can vary with the ecCodes version + md_num = len(md) + assert md_num > 100 + keys = list(md.keys()) - assert len(keys) == 192 - assert keys[0] == "globalDomain" - assert keys[10] == "wrongPadding" + assert len(keys) == md_num + assert "shortName" in keys + assert "maximum" in keys keys = [k for k in md] - assert len(keys) == 192 - assert keys[0] == "globalDomain" - assert keys[10] == "wrongPadding" + assert len(keys) == md_num + assert "shortName" in keys + assert "maximum" in keys items = {k: v for k, v in md.items()} - assert len(items) == 192 + assert len(items) == md_num assert items["shortName"] == "2t" assert items["typeOfLevel"] == "surface" diff --git a/tests/grib/test_grib_metadata.py b/tests/grib/test_grib_metadata.py index 6edc1f45..850beda2 100644 --- a/tests/grib/test_grib_metadata.py +++ b/tests/grib/test_grib_metadata.py @@ -421,27 +421,31 @@ def test_grib_metadata_namespace(mode): } assert r == ref + # The number/order of metadata keys can vary with the ecCodes version. + # The same is true for the namespaces. + r = f[0].metadata(namespace=None) assert isinstance(r, dict) - assert len(r) == 186 + md_num = len(r) + assert md_num > 100 assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace=[None]) assert isinstance(r, dict) - assert len(r) == 186 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace="") assert isinstance(r, dict) - assert len(r) == 186 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace=[""]) assert isinstance(r, dict) - assert len(r) == 186 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant" diff --git a/tests/numpy_fs/test_numpy_fs_metadata.py b/tests/numpy_fs/test_numpy_fs_metadata.py index ad505e33..8a9c8105 100644 --- a/tests/numpy_fs/test_numpy_fs_metadata.py +++ b/tests/numpy_fs/test_numpy_fs_metadata.py @@ -68,12 +68,15 @@ def test_numpy_fs_values_metadata_internal(): def test_numpy_fs_metadata_keys(): ds, _ = load_numpy_fs(1) - num = 183 + # The number/order of metadata keys can vary with the ecCodes version. + # The same is true for the namespaces. + md = ds[0].metadata() - assert len(md) == num + md_num = len(md) + assert md_num > 100 keys = md.keys() - assert len(keys) == num + assert len(keys) == md_num for k in md.keys(): assert isinstance(k, str) @@ -81,7 +84,7 @@ def test_numpy_fs_metadata_keys(): break items = md.items() - assert len(items) == num + assert len(items) == md_num for k, v in md.items(): assert isinstance(k, str) @@ -90,6 +93,7 @@ def test_numpy_fs_metadata_keys(): break assert "max" not in md + assert "maximum" not in md assert "statistics.max" not in md assert "validityDate" in md @@ -118,27 +122,31 @@ def test_numpy_fs_metadata_namespace(): } assert r == ref + # The number/order of metadata keys can vary with the ecCodes version. + # The same is true for the namespaces. + r = f[0].metadata(namespace=None) assert isinstance(r, dict) - assert len(r) == 177 + md_num = len(r) + assert md_num > 100 assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace=[None]) assert isinstance(r, dict) - assert len(r) == 177 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace="") assert isinstance(r, dict) - assert len(r) == 177 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant" r = f[0].metadata(namespace=[""]) assert isinstance(r, dict) - assert len(r) == 177 + assert len(r) == md_num assert r["level"] == 1000 assert r["stepType"] == "instant"