Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ The following people have made contributions to this project:
- [Albert Brotzer](https://github.com/albertbrotzer)
- [Alexandra Melzer](https://github.com/armelzer)
- [Francesc Lucas Carbó (cesclc)](https://github.com/cesclc)
- [Göte Kleringer (Grukank)](https://github.com/Grukank)
7 changes: 6 additions & 1 deletion satpy/enhancements/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
def lookup(img, **kwargs):
"""Assign values to channels based on a table."""
luts = np.array(kwargs["luts"], dtype=np.float32) / 255.0
return _lookup_table(img.data, luts=luts)
# Preserve NaNs
nans = np.isfinite(img.data)
_lookup_table(img.data, luts=luts)
# Replace lost NaNs
img.data = img.data.where(nans, np.nan)
return


@exclude_alpha
Expand Down
8 changes: 4 additions & 4 deletions satpy/tests/enhancement_tests/test_colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ def test_lookup(self):
"""Test the lookup enhancement function."""
from satpy.enhancements.colormap import lookup
expected = np.array([[
[0., 0., 0., 0.333333, 0.705882],
[np.nan, 0., 0., 0.333333, 0.705882],
[1., 1., 1., 1., 1.]]])
lut = np.arange(256.)
run_and_check_enhancement(lookup, self.ch1, expected, luts=lut)

expected = np.array([[[0., 0., 0., 0.333333, 0.705882],
expected = np.array([[[np.nan, 0., 0., 0.333333, 0.705882],
[1., 1., 1., 1., 1.]],
[[0., 0., 0., 0.333333, 0.705882],
[[np.nan, 0., 0., 0.333333, 0.705882],
[1., 1., 1., 1., 1.]],
[[0., 0., 0., 0.333333, 0.705882],
[[np.nan, 0., 0., 0.333333, 0.705882],
[1., 1., 1., 1., 1.]]])
lut = np.arange(256.)
lut = np.vstack((lut, lut, lut)).T
Expand Down
Loading