From 0ddfb30f75b82dbbcdbf4d72f71244c4211fddc3 Mon Sep 17 00:00:00 2001 From: Kamil Monicz Date: Sat, 28 Feb 2026 21:43:47 +0100 Subject: [PATCH 1/2] Fix reduce_data argument forwarding --- AUTHORS.md | 1 + satpy/resample/kdtree.py | 3 ++- satpy/tests/test_resample.py | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 5d4cc8a82f..f921ac2c1f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -112,3 +112,4 @@ The following people have made contributions to this project: - [Xuanhan Lai (sgxl)](https://github.com/sgxl) - [Nalin Parihar(Nalin7parihar](https://github.com/Nalin7parihar) - [Francesc Lucas Carbó (cesclc)](https://github.com/cesclc) +- [Kamil Monicz (Zaczero)](https://github.com/Zaczero) diff --git a/satpy/resample/kdtree.py b/satpy/resample/kdtree.py index 8f6d298e67..ebad5dbbdc 100644 --- a/satpy/resample/kdtree.py +++ b/satpy/resample/kdtree.py @@ -229,7 +229,8 @@ def precompute(self, mask=None, radius_of_influence=50000, epsilon=0, target_geo_def=self.target_geo_def, radius_of_influence=radius_of_influence, neighbours=32, - epsilon=epsilon) + epsilon=epsilon, + reduce_data=reduce_data) self.resampler = XArrayBilinearResampler(**kwargs) try: diff --git a/satpy/tests/test_resample.py b/satpy/tests/test_resample.py index 32784e9696..8654e725d7 100644 --- a/satpy/tests/test_resample.py +++ b/satpy/tests/test_resample.py @@ -337,6 +337,21 @@ def test_reduce_first_dim_rechunk_second_dim_good(self): class TestBilinearResampler(unittest.TestCase): """Test the bilinear resampler.""" + @mock.patch("pyresample.bilinear.XArrayBilinearResampler") + def test_precompute_forwards_reduce_data(self, xr_resampler): + """Test that precompute forwards reduce_data to pyresample bilinear.""" + from satpy.resample.kdtree import BilinearResampler + + _, source_area, _, _, target_area = get_test_data() + resampler = BilinearResampler(source_area, target_area) + resampler.precompute() + assert xr_resampler.call_args.kwargs["reduce_data"] is True + + xr_resampler.reset_mock() + resampler = BilinearResampler(source_area, target_area) + resampler.precompute(reduce_data=False) + assert xr_resampler.call_args.kwargs["reduce_data"] is False + @mock.patch("satpy.resample.kdtree._move_existing_caches") @mock.patch("satpy.resample.kdtree.BilinearResampler._create_cache_filename") @mock.patch("pyresample.bilinear.XArrayBilinearResampler") From 879e80adb3dfca03ffcd21ff203851f6c0a6dfbf Mon Sep 17 00:00:00 2001 From: Kamil Monicz Date: Sat, 28 Feb 2026 23:11:51 +0100 Subject: [PATCH 2/2] Add optional limit_output switch to xarray bilinear resampling --- satpy/resample/kdtree.py | 5 +++-- satpy/tests/test_resample.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/satpy/resample/kdtree.py b/satpy/resample/kdtree.py index ebad5dbbdc..880cafa1d5 100644 --- a/satpy/resample/kdtree.py +++ b/satpy/resample/kdtree.py @@ -214,7 +214,7 @@ def __init__(self, source_geo_def, target_geo_def): self.resampler = None def precompute(self, mask=None, radius_of_influence=50000, epsilon=0, - reduce_data=True, cache_dir=False, **kwargs): + reduce_data=True, limit_output=True, cache_dir=False, **kwargs): """Create bilinear coefficients and store them for later use.""" try: from pyresample.bilinear import XArrayBilinearResampler @@ -230,7 +230,8 @@ def precompute(self, mask=None, radius_of_influence=50000, epsilon=0, radius_of_influence=radius_of_influence, neighbours=32, epsilon=epsilon, - reduce_data=reduce_data) + reduce_data=reduce_data, + limit_output=limit_output) self.resampler = XArrayBilinearResampler(**kwargs) try: diff --git a/satpy/tests/test_resample.py b/satpy/tests/test_resample.py index 8654e725d7..a936bd4dbf 100644 --- a/satpy/tests/test_resample.py +++ b/satpy/tests/test_resample.py @@ -338,20 +338,26 @@ class TestBilinearResampler(unittest.TestCase): """Test the bilinear resampler.""" @mock.patch("pyresample.bilinear.XArrayBilinearResampler") - def test_precompute_forwards_reduce_data(self, xr_resampler): - """Test that precompute forwards reduce_data to pyresample bilinear.""" + def test_precompute_forwards_bilinear_options(self, xr_resampler): + """Test that precompute forwards bilinear options to pyresample.""" from satpy.resample.kdtree import BilinearResampler _, source_area, _, _, target_area = get_test_data() resampler = BilinearResampler(source_area, target_area) resampler.precompute() assert xr_resampler.call_args.kwargs["reduce_data"] is True + assert xr_resampler.call_args.kwargs["limit_output"] is True xr_resampler.reset_mock() resampler = BilinearResampler(source_area, target_area) resampler.precompute(reduce_data=False) assert xr_resampler.call_args.kwargs["reduce_data"] is False + xr_resampler.reset_mock() + resampler = BilinearResampler(source_area, target_area) + resampler.precompute(limit_output=False) + assert xr_resampler.call_args.kwargs["limit_output"] is False + @mock.patch("satpy.resample.kdtree._move_existing_caches") @mock.patch("satpy.resample.kdtree.BilinearResampler._create_cache_filename") @mock.patch("pyresample.bilinear.XArrayBilinearResampler")