From b777de5af66cfaa3b8099f91559aea1265c3a1a6 Mon Sep 17 00:00:00 2001 From: Pouria Khalaj Date: Tue, 19 Nov 2024 22:59:34 +0100 Subject: [PATCH 1/2] Fix bug #2981 --- satpy/readers/seviri_base.py | 2 +- satpy/tests/reader_tests/test_seviri_l1b_native.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/satpy/readers/seviri_base.py b/satpy/readers/seviri_base.py index aa224b0d6a..c9ad563899 100644 --- a/satpy/readers/seviri_base.py +++ b/satpy/readers/seviri_base.py @@ -700,7 +700,7 @@ def calibrate(self, data, calibration): "brightness_temperature"]: gain, offset = self.get_gain_offset() res = self._algo.convert_to_radiance( - data.astype(np.float32), gain, offset + data.astype(np.float32), np.float32(gain), np.float32(offset) ) else: raise ValueError( diff --git a/satpy/tests/reader_tests/test_seviri_l1b_native.py b/satpy/tests/reader_tests/test_seviri_l1b_native.py index e7a5d0f5f3..c5818bfa6a 100644 --- a/satpy/tests/reader_tests/test_seviri_l1b_native.py +++ b/satpy/tests/reader_tests/test_seviri_l1b_native.py @@ -1314,6 +1314,7 @@ def test_read_physical_seviri_nat_file(full_path): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=UserWarning) scene.load(["VIS006"]) + assert scene["VIS006"].dtype == np.float32 assert scene["VIS006"].shape == (3712, 3712) assert isinstance(scene["VIS006"], xr.core.dataarray.DataArray) From da848757a4f0bb786d53d67867aeeb374547b278 Mon Sep 17 00:00:00 2001 From: pkhalaj <11797985+pkhalaj@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:15:48 +0100 Subject: [PATCH 2/2] Check that the computed values have the correct `dtype` . Co-authored-by: Panu Lahtinen --- satpy/tests/reader_tests/test_seviri_l1b_native.py | 1 + 1 file changed, 1 insertion(+) diff --git a/satpy/tests/reader_tests/test_seviri_l1b_native.py b/satpy/tests/reader_tests/test_seviri_l1b_native.py index c5818bfa6a..5c6a86596e 100644 --- a/satpy/tests/reader_tests/test_seviri_l1b_native.py +++ b/satpy/tests/reader_tests/test_seviri_l1b_native.py @@ -1315,6 +1315,7 @@ def test_read_physical_seviri_nat_file(full_path): warnings.filterwarnings("ignore", category=UserWarning) scene.load(["VIS006"]) assert scene["VIS006"].dtype == np.float32 + assert scene["VIS006"].values.dtype == np.float32 assert scene["VIS006"].shape == (3712, 3712) assert isinstance(scene["VIS006"], xr.core.dataarray.DataArray)