From 30ee8992cf62a27a084562265dbd20dee9b1f6e0 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Wed, 16 Oct 2024 18:00:04 +0200 Subject: [PATCH 1/4] Add no-op `image_ready` enhancement --- satpy/enhancements/__init__.py | 5 +++++ satpy/etc/enhancements/generic.yaml | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/satpy/enhancements/__init__.py b/satpy/enhancements/__init__.py index a44ca590cf..95a147aafb 100644 --- a/satpy/enhancements/__init__.py +++ b/satpy/enhancements/__init__.py @@ -653,3 +653,8 @@ def _jma_true_color_reproduction(img_data, platform=None): output = da.dot(img_data.T, ccm.T) return output.T + + +def no_op(img): + """Do not do anything to the image.""" + return img.data diff --git a/satpy/etc/enhancements/generic.yaml b/satpy/etc/enhancements/generic.yaml index 5d17154aab..7e23281531 100644 --- a/satpy/etc/enhancements/generic.yaml +++ b/satpy/etc/enhancements/generic.yaml @@ -1285,3 +1285,9 @@ enhancements: imager_with_lightning: standard_name: imager_with_lightning operations: [] + + image_ready: + standard_name: image_ready + operations: + - name: no_op + method: !!python/name:satpy.enhancements.no_op From 4c0b1e71f16a78dd70494664bfd23e5eb35bd3e3 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Wed, 16 Oct 2024 18:01:13 +0200 Subject: [PATCH 2/4] Fix style --- satpy/composites/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satpy/composites/__init__.py b/satpy/composites/__init__.py index b032f23a32..d7518be91d 100644 --- a/satpy/composites/__init__.py +++ b/satpy/composites/__init__.py @@ -721,7 +721,7 @@ def __init__(self, name, lim_low=85., lim_high=88., day_night="day_night", inclu self.day_night = day_night self.include_alpha = include_alpha self._has_sza = False - super(DayNightCompositor, self).__init__(name, **kwargs) + super().__init__(name, **kwargs) def __call__( self, From 3ab5c64ba18e504bd43bb3d184137971caa92c14 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Thu, 17 Oct 2024 08:23:31 +0200 Subject: [PATCH 3/4] Fix warning --- satpy/tests/enhancement_tests/test_enhancements.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/satpy/tests/enhancement_tests/test_enhancements.py b/satpy/tests/enhancement_tests/test_enhancements.py index b30a073968..89ff21aafa 100644 --- a/satpy/tests/enhancement_tests/test_enhancements.py +++ b/satpy/tests/enhancement_tests/test_enhancements.py @@ -456,10 +456,10 @@ def test_cmap_list(self): """Test that colors can be a list/tuple.""" from satpy.enhancements import create_colormap colors = [ - [0, 0, 1], - [1, 0, 1], - [0, 1, 1], - [1, 1, 1], + [0., 0., 1.], + [1., 0., 1.], + [0., 1., 1.], + [1., 1., 1.], ] values = [2, 4, 6, 8] cmap = create_colormap({"colors": colors, "color_scale": 1}) From b408e65f14c58b4df296262180b319b09989d1b0 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Thu, 17 Oct 2024 08:24:11 +0200 Subject: [PATCH 4/4] Test no-op --- satpy/tests/enhancement_tests/test_enhancements.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/satpy/tests/enhancement_tests/test_enhancements.py b/satpy/tests/enhancement_tests/test_enhancements.py index 89ff21aafa..b0f2b3d31b 100644 --- a/satpy/tests/enhancement_tests/test_enhancements.py +++ b/satpy/tests/enhancement_tests/test_enhancements.py @@ -711,3 +711,15 @@ def test_jma_true_color_reproduction(self): img = XRImage(self.rgb) with pytest.raises(KeyError, match="No conversion matrix found for platform Fakesat"): jma_true_color_reproduction(img) + + +def test_no_op_enhancement(): + """Test the no-op enhancement.""" + from satpy.enhancements import no_op + + data = da.arange(-100, 1000, 110).reshape(2, 5) + rgb_data = np.stack([data, data, data]) + rgb = xr.DataArray(rgb_data, dims=("bands", "y", "x"), + coords={"bands": ["R", "G", "B"]}, + attrs={"platform_name": "Himawari-8"}) + assert no_op(rgb) is rgb.data