Repository: ecmwf/earthkit-data
Pull request #128 (2023-06-29 07:23:39)

Use pdbufr minimum version 0.11.0


Patch:
diff --git a/earthkit/data/readers/bufr/pandas.py b/earthkit/data/readers/bufr/pandas.py
index f442dcc..8c72637 100644
--- a/earthkit/data/readers/bufr/pandas.py
+++ b/earthkit/data/readers/bufr/pandas.py
@@ -13,22 +13,6 @@ LOG = logging.getLogger(__name__)
 
 COLUMNS = ("latitude", "longitude", "data_datetime")
 
-# todo: remove it when pdbufr with message list support is released
-_MESSAGE_LIST_SUPPORT = None
-
-
-def has_message_list_support():
-    global _MESSAGE_LIST_SUPPORT
-    if _MESSAGE_LIST_SUPPORT is None:
-        try:
-            from pdbufr.bufr_read import _read_bufr  # noqa
-
-            _MESSAGE_LIST_SUPPORT = True
-        except Exception:
-            _MESSAGE_LIST_SUPPORT = False
-
-    return _MESSAGE_LIST_SUPPORT
-
 
 class PandasMixIn:
     def to_pandas(self, columns=COLUMNS, filters=None, **kwargs):
@@ -59,12 +43,4 @@ class PandasMixIn:
 
         filters = {} if filters is None else filters
 
-        if has_message_list_support():
-            return pdbufr.read_bufr(self, columns=columns, filters=filters, **kwargs)
-        else:
-            if hasattr(self, "path"):
-                return pdbufr.read_bufr(self.path, columns=columns, filters=filters)
-            else:
-                raise NotImplementedError(
-                    "to_pandas is only supported for single BUFR files"
-                )
+        return pdbufr.read_bufr(self, columns=columns, filters=filters, **kwargs)
diff --git a/environment.yml b/environment.yml
index a3ed7d6..e1ccf15 100644
--- a/environment.yml
+++ b/environment.yml
@@ -12,7 +12,7 @@ dependencies:
 - dask
 - netcdf4
 - cfgrib>=0.9.10.1
-- pdbufr>=0.10.3
+- pdbufr>=0.11.0
 - pyodc
 - filelock
 - pyyaml
diff --git a/setup.cfg b/setup.cfg
index edd69a1..6297c5b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -29,7 +29,7 @@ install_requires =
     jinja2
     multiurl
     netcdf4
-    pdbufr>=0.10.3
+    pdbufr>=0.11.0
     pyfdb
     pyodc
     pyyaml


Test patch:
diff --git a/tests/bufr/test_bufr_convert.py b/tests/bufr/test_bufr_convert.py
index 59c5611..9c37a3d 100644
--- a/tests/bufr/test_bufr_convert.py
+++ b/tests/bufr/test_bufr_convert.py
@@ -13,7 +13,6 @@ import pandas as pd
 import pytest
 
 from earthkit.data import from_source
-from earthkit.data.readers.bufr.pandas import has_message_list_support
 from earthkit.data.testing import earthkit_examples_file
 
 assert_frame_equal = pd.testing.assert_frame_equal
@@ -55,9 +54,7 @@ def test_bufr_to_pandas_filters():
     assert_frame_equal(res, ref[res.columns])
 
 
-@pytest.mark.skipif(not has_message_list_support(), reason="not implemented")
 def test_bufr_to_pandas_multi():
-    print(f"support={has_message_list_support()}")
     ds = from_source("file", earthkit_examples_file("temp_10.bufr")) + from_source(
         "file", earthkit_examples_file("synop_10.bufr")
     )
diff --git a/tests/environment-unit-tests.yml b/tests/environment-unit-tests.yml
index bad4df6..70c7236 100644
--- a/tests/environment-unit-tests.yml
+++ b/tests/environment-unit-tests.yml
@@ -13,7 +13,7 @@ dependencies:
 - dask
 - netcdf4
 - cfgrib>=0.9.10.1
-- pdbufr>=0.10.3
+- pdbufr>=0.11.0
 - pyodc
 - filelock
 - pyyaml