Skip to content

Commit

Permalink
Merge pull request #2933 from mraspaud/feature-no-op-enhancement
Browse files Browse the repository at this point in the history
Add no-op image_ready enhancement
  • Loading branch information
mraspaud authored Oct 17, 2024
2 parents a5a3227 + b408e65 commit 5a8b6cc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions satpy/enhancements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions satpy/etc/enhancements/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 16 additions & 4 deletions satpy/tests/enhancement_tests/test_enhancements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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

0 comments on commit 5a8b6cc

Please sign in to comment.