From db6626a6a1b507bb0f7ba4c4695a032c4a7481c5 Mon Sep 17 00:00:00 2001 From: Gerrit Holl Date: Tue, 17 Feb 2026 18:33:39 +0100 Subject: [PATCH 1/2] Add test case for cloud type as float Add a test case reproducing https://github.com/pytroll/satpy/issues/3338, where cloud type becomes a float. Test fails. --- satpy/tests/reader_tests/test_fci_l2_nc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/satpy/tests/reader_tests/test_fci_l2_nc.py b/satpy/tests/reader_tests/test_fci_l2_nc.py index 2761e92c60..82f30c161b 100644 --- a/satpy/tests/reader_tests/test_fci_l2_nc.py +++ b/satpy/tests/reader_tests/test_fci_l2_nc.py @@ -222,7 +222,7 @@ def test_dataset_with_scalar(self): with pytest.raises(NotImplementedError): self.fh.get_area_def(None) - def test_emumerations(self): + def test_enumerations(self): """Test the conversion of enumerated type information into flag_values and flag_meanings.""" dataset = self.fh.get_dataset(make_dataid(name="test_enum", resolution=2000), {"name": "quality_flag", @@ -234,6 +234,17 @@ def test_emumerations(self): assert attributes["flag_values"] == [0,1] assert "flag_meanings" in attributes assert attributes["flag_meanings"] == ["False","True"] + assert dataset.dtype == np.uint8 + + def test_enum_with_fill_value_remains_int(self): + """Test that enum with a fill value (such as cloud type) remains uint8.""" + dataset = self.fh.get_dataset(make_dataid(name="test_enum", resolution=2000), + {"name": "quality_flag", + "nc_key": "quality_flag", + "file_type": "test_file_type", + "import_enum_information": True, + "fill_value": -127}) + assert dataset.dtype == np.int8 def test_units_from_file(self): """Test units extraction from NetCDF file.""" From 752fafde728b2bcccb03458e543de470fdee7a90 Mon Sep 17 00:00:00 2001 From: Gerrit Holl Date: Wed, 18 Feb 2026 09:28:56 +0100 Subject: [PATCH 2/2] FCI L2: Don't turn categorical data into float In the FCI L2 data, do not convert categorical data types (quality, cloud type, cloud phase, cloud mask, etc.) into float. Fixes https://github.com/pytroll/satpy/issues/3338 --- satpy/readers/fci_l2_nc.py | 2 +- satpy/tests/reader_tests/test_fci_l2_nc.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/satpy/readers/fci_l2_nc.py b/satpy/readers/fci_l2_nc.py index 730d1ae7ae..d5b0e037ba 100644 --- a/satpy/readers/fci_l2_nc.py +++ b/satpy/readers/fci_l2_nc.py @@ -233,7 +233,7 @@ def get_dataset(self, dataset_id, dataset_info): if dataset_info["file_type"] == "nc_fci_test_clm": variable = self._decode_clm_test_data(variable, dataset_info) - if "fill_value" in dataset_info: + if "fill_value" in dataset_info and np.issubdtype(variable.dtype, np.inexact): variable = self._mask_data(variable, dataset_info["fill_value"]) variable = self._set_attributes(variable, dataset_info) diff --git a/satpy/tests/reader_tests/test_fci_l2_nc.py b/satpy/tests/reader_tests/test_fci_l2_nc.py index 82f30c161b..62c5f096be 100644 --- a/satpy/tests/reader_tests/test_fci_l2_nc.py +++ b/satpy/tests/reader_tests/test_fci_l2_nc.py @@ -234,7 +234,6 @@ def test_enumerations(self): assert attributes["flag_values"] == [0,1] assert "flag_meanings" in attributes assert attributes["flag_meanings"] == ["False","True"] - assert dataset.dtype == np.uint8 def test_enum_with_fill_value_remains_int(self): """Test that enum with a fill value (such as cloud type) remains uint8.""" @@ -244,7 +243,7 @@ def test_enum_with_fill_value_remains_int(self): "file_type": "test_file_type", "import_enum_information": True, "fill_value": -127}) - assert dataset.dtype == np.int8 + assert np.issubdtype(dataset.dtype, np.integer) def test_units_from_file(self): """Test units extraction from NetCDF file."""