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

Drop non-dimensional coordinates in Compositor #796

Merged
merged 8 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
17 changes: 15 additions & 2 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@

LOG = logging.getLogger(__name__)

NEGLIBLE_COORDS = ['time']
"""Keywords identifying non-dimensional coordinates to be ignored during composite generation."""


class IncompatibleAreas(Exception):
"""Error raised upon compositing things of different shapes."""
Expand Down Expand Up @@ -310,7 +313,7 @@ def apply_modifier_info(self, origin, destination):
d[k] = o[k]

def check_areas(self, data_arrays):
"""Check that the areas of the *data_arrays* are compatible."""
"""Check that the areas of the *data_arrays* are compatible and drop neglible non-dimensional coordinates."""
if len(data_arrays) == 1:
return data_arrays

Expand All @@ -334,7 +337,17 @@ def check_areas(self, data_arrays):
"'{}'".format(self.attrs['name']))
raise IncompatibleAreas("Areas are different")

return data_arrays
# Drop neglible non-dimensional coordinates (understood to be "close-enough" for most operations)
sfinkens marked this conversation as resolved.
Show resolved Hide resolved
new_arrays = []
for ds in data_arrays:
drop = [coord for coord in ds.coords
if coord not in ds.dims and any([neglible in coord for neglible in NEGLIBLE_COORDS])]
if drop:
new_arrays.append(ds.drop(drop))
else:
new_arrays.append(ds)

return new_arrays


class SunZenithCorrectorBase(CompositeBase):
Expand Down
8 changes: 8 additions & 0 deletions satpy/tests/compositor_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def test_mult_ds_diff_size(self):
comp = CompositeBase('test_comp')
self.assertRaises(IncompatibleAreas, comp.check_areas, (ds1, ds2))

def test_nondimensional_coords(self):
from satpy.composites import CompositeBase
ds = self._get_test_ds(shape=(2, 2))
ds['acq_time'] = ('y', [0, 1])
comp = CompositeBase('test_comp')
ret_datasets = comp.check_areas([ds, ds])
self.assertNotIn('acq_time', ret_datasets[0].coords)


class TestRatioSharpenedCompositors(unittest.TestCase):
"""Test RatioSharpenedRGB and SelfSharpendRGB compositors."""
Expand Down