From ac8d67b28b5658314070863e77b5216a344a82b3 Mon Sep 17 00:00:00 2001 From: david-i-berry Date: Mon, 18 Nov 2024 13:16:57 +0100 Subject: [PATCH] bug fix for single subset. --- bufr2geojson/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bufr2geojson/__init__.py b/bufr2geojson/__init__.py index 83f0f61..4e8ac36 100644 --- a/bufr2geojson/__init__.py +++ b/bufr2geojson/__init__.py @@ -855,10 +855,12 @@ def transform(data: bytes, serialize: bool = False, LOGGER.info(f"{nsubsets} subsets") collections = dict() for idx in range(nsubsets): - LOGGER.debug(f"Extracting subset {idx}") - codes_set(bufr_handle, "extractSubset", idx+1) - codes_set(bufr_handle, "doExtractSubsets", 1) - LOGGER.debug("Cloning subset to new message") + if nsubsets > 1: # we need to specify which subset to extract + LOGGER.debug(f"Extracting subset {idx}") + codes_set(bufr_handle, "extractSubset", idx+1) + codes_set(bufr_handle, "doExtractSubsets", 1) + LOGGER.debug("Cloning subset to new message") + single_subset = codes_clone(bufr_handle) LOGGER.debug("Unpacking") codes_set(single_subset, "unpack", True)