Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-op image_ready enhancement #2933

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pnuu marked this conversation as resolved.
Show resolved Hide resolved
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
Loading