Skip to content

Commit

Permalink
Add unconfigured_noop enhancement for RGBs
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jun 12, 2019
1 parent 2b3910a commit aefe7a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions satpy/enhancements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ def noop(img, **kwargs):
return img


def unconfigured_noop(img, **kwargs):
"""Do nothing and warn that no enhancement was configured."""
import warnings
name = img.data.attrs.get('name', '<unknown>')
warnings.warn("No enhancement configured for '{}'. Will not stretch and "
"assuming already 0-1 normalized.".format(name))
return noop(img, **kwargs)


def stretch(img, **kwargs):
"""Perform stretch."""
return img.stretch(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/enhancements/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enhancements:
mode: RGB
operations:
- name: passive
method: !!python/name:satpy.enhancements.noop
method: !!python/name:satpy.enhancements.unconfigured_noop
reflectance_default:
standard_name: toa_bidirectional_reflectance
operations:
Expand Down
4 changes: 2 additions & 2 deletions satpy/tests/compositor_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def test_basic_sza(self):
comp = DayNightCompositor(name='dn_test')
res = comp((self.data_a, self.data_b, self.sza))
res = res.compute()
expected = np.array([[0., 0.2985455], [0.51680423, 1.]])
expected = np.array([[0.1, 0.20499086], [0.48003658, 0.75]])
np.testing.assert_allclose(res.values[0], expected)

def test_basic_area(self):
Expand All @@ -391,7 +391,7 @@ def test_basic_area(self):
comp = DayNightCompositor(name='dn_test')
res = comp((self.data_a, self.data_b))
res = res.compute()
expected = np.array([[0., 0.33164983], [0.66835017, 1.]])
expected = np.array([[0.1, 0.2], [0.3, 0.4]])
np.testing.assert_allclose(res.values[0], expected)


Expand Down

0 comments on commit aefe7a4

Please sign in to comment.