Skip to content

Commit

Permalink
Rename SimpleMaskingCompositor to MaskingCompositor
Browse files Browse the repository at this point in the history
  • Loading branch information
pnuu committed Dec 10, 2019
1 parent db9da2e commit 3f4ab07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ def __call__(self, projectables, *args, **kwargs):
return res


class SimpleMaskingCompositor(GenericCompositor):
class MaskingCompositor(GenericCompositor):
"""A compositor that masks e.g. IR 10.8 channel data using cloud products from NWC SAF."""

def __init__(self, name, transparency=None, **kwargs):
Expand All @@ -1555,7 +1555,7 @@ def __init__(self, name, transparency=None, **kwargs):
raise ValueError("No transparency configured for simple masking compositor")
self.transparency = transparency

super(SimpleMaskingCompositor, self).__init__(name, **kwargs)
super(MaskingCompositor, self).__init__(name, **kwargs)

def __call__(self, projectables, *args, **kwargs):
"""Call the compositor."""
Expand Down Expand Up @@ -1592,5 +1592,5 @@ def __call__(self, projectables, *args, **kwargs):
alpha = xr.DataArray(data=alpha, attrs=alpha_attrs,
dims=data[0].dims, coords=data[0].coords)
data.append(alpha)
res = super(SimpleMaskingCompositor, self).__call__(data, **kwargs)
res = super(MaskingCompositor, self).__call__(data, **kwargs)
return res
4 changes: 2 additions & 2 deletions satpy/etc/composites/seviri.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ modifiers:
composites:

ct_masked_ir:
compositor: !!python/name:satpy.composites.SimpleMaskingCompositor
compositor: !!python/name:satpy.composites.MaskingCompositor
prerequisites:
- IR_108
- ct
Expand All @@ -28,7 +28,7 @@ composites:
10: 35

nwc_geo_ct_masked_ir:
compositor: !!python/name:satpy.composites.SimpleMaskingCompositor
compositor: !!python/name:satpy.composites.MaskingCompositor
prerequisites:
- IR_108
- ct
Expand Down
24 changes: 10 additions & 14 deletions satpy/tests/compositor_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,24 +1162,24 @@ def test_get_angles(self, get_satpos):
self.assertEqual(args[6], 0)


class TestSimpleMaskingCompositor(unittest.TestCase):
class TestMaskingCompositor(unittest.TestCase):
"""Test case for the simple masking compositor."""

def test_init(self):
"""Test the initializiation of compositor."""
from satpy.composites import SimpleMaskingCompositor
from satpy.composites import MaskingCompositor

# No transparency given raises ValueError
with self.assertRaises(ValueError):
comp = SimpleMaskingCompositor("name")
comp = MaskingCompositor("name")

# transparency defined
comp = SimpleMaskingCompositor("name", transparency=0)
comp = MaskingCompositor("name", transparency=0)
self.assertEqual(comp.transparency, 0)

def test_call(self):
"""Test call the compositor."""
from satpy.composites import SimpleMaskingCompositor
from satpy.composites import MaskingCompositor

flag_meanings = ['Cloud-free_land', 'Cloud-free_sea']
flag_values = np.array([1, 2])
Expand All @@ -1205,16 +1205,14 @@ def test_call(self):
reference_alpha = xr.DataArray(reference_alpha, dims=['y', 'x'])

# Test with numerical transparency data
comp = SimpleMaskingCompositor("name",
transparency=transparency_data_v1)
comp = MaskingCompositor("name", transparency=transparency_data_v1)
res = comp([data, ct_data])
self.assertTrue(res.mode == 'LA')
np.testing.assert_allclose(res.sel(bands='L'), data)
np.testing.assert_allclose(res.sel(bands='A'), reference_alpha)

# Test with named fields
comp = SimpleMaskingCompositor("name",
transparency=transparency_data_v2)
comp = MaskingCompositor("name", transparency=transparency_data_v2)
res = comp([data, ct_data])
self.assertTrue(res.mode == 'LA')
np.testing.assert_allclose(res.sel(bands='L'), data)
Expand All @@ -1228,8 +1226,7 @@ def test_call(self):
'y': np.arange(3),
'x': np.arange(3)})

comp = SimpleMaskingCompositor("name",
transparency=transparency_data_v1)
comp = MaskingCompositor("name", transparency=transparency_data_v1)
res = comp([data, ct_data])
self.assertTrue(res.mode == 'RGBA')
np.testing.assert_allclose(res.sel(bands='R'), data.sel(bands='R'))
Expand All @@ -1244,8 +1241,7 @@ def test_call(self):
'y': np.arange(3),
'x': np.arange(3)})

comp = SimpleMaskingCompositor("name",
transparency=transparency_data_v2)
comp = MaskingCompositor("name", transparency=transparency_data_v2)
res = comp([data, ct_data])
self.assertTrue(res.mode == 'RGBA')
np.testing.assert_allclose(res.sel(bands='R'), data.sel(bands='R'))
Expand Down Expand Up @@ -1283,7 +1279,7 @@ def suite():
mysuite.addTest(loader.loadTestsFromTestCase(TestStaticImageCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestPSPAtmosphericalCorrection))
mysuite.addTest(loader.loadTestsFromTestCase(TestPSPRayleighReflectance))
mysuite.addTest(loader.loadTestsFromTestCase(TestSimpleMaskingCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestMaskingCompositor))

return mysuite

Expand Down

0 comments on commit 3f4ab07

Please sign in to comment.