From d62b5d2539a2789ff825b431af703cd931357d52 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Thu, 17 Oct 2024 14:26:00 +0200 Subject: [PATCH] Fix bogus no_op implementation --- doc/source/composites.rst | 5 +++-- satpy/enhancements/__init__.py | 5 ----- satpy/etc/enhancements/generic.yaml | 4 +--- satpy/tests/enhancement_tests/test_enhancements.py | 12 ------------ 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/doc/source/composites.rst b/doc/source/composites.rst index d0c494e414..dda071db24 100644 --- a/doc/source/composites.rst +++ b/doc/source/composites.rst @@ -579,8 +579,9 @@ the file) as:: default apply the :func:`~trollimage.xrimage.XRImage.stretch_linear` enhancement with cutoffs of 0.5% and 99.5%. If you want no enhancement at all (maybe you are enhancing a composite based on :class:`DayNightCompositor` where - the components have their own enhancements defined), you need to define - an enhancement that does nothing:: + the components have their own enhancements defined), you can use the `image_ready` standard name. + If this is not a suitable standard name, you can also define + an enhancement that does nothing: enhancements: day_x: diff --git a/satpy/enhancements/__init__.py b/satpy/enhancements/__init__.py index 95a147aafb..a44ca590cf 100644 --- a/satpy/enhancements/__init__.py +++ b/satpy/enhancements/__init__.py @@ -653,8 +653,3 @@ 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 7e23281531..cdfb7851ad 100644 --- a/satpy/etc/enhancements/generic.yaml +++ b/satpy/etc/enhancements/generic.yaml @@ -1288,6 +1288,4 @@ enhancements: image_ready: standard_name: image_ready - operations: - - name: no_op - method: !!python/name:satpy.enhancements.no_op + operations: [] diff --git a/satpy/tests/enhancement_tests/test_enhancements.py b/satpy/tests/enhancement_tests/test_enhancements.py index b0f2b3d31b..89ff21aafa 100644 --- a/satpy/tests/enhancement_tests/test_enhancements.py +++ b/satpy/tests/enhancement_tests/test_enhancements.py @@ -711,15 +711,3 @@ 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