Skip to content

Commit

Permalink
Merge pull request #1564 from djhoese/bugfix-difference-compositor
Browse files Browse the repository at this point in the history
Fix DifferenceCompositor ignoring YAML metadata
  • Loading branch information
djhoese committed Feb 24, 2021
2 parents d556c80 + 4aa6e0a commit feea149
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,14 @@ def check_areas(self, data_arrays):
class DifferenceCompositor(CompositeBase):
"""Make the difference of two data arrays."""

def __call__(self, projectables, nonprojectables=None, **info):
def __call__(self, projectables, nonprojectables=None, **attrs):
"""Generate the composite."""
if len(projectables) != 2:
raise ValueError("Expected 2 datasets, got %d" % (len(projectables),))
projectables = self.match_data_arrays(projectables)
info = combine_metadata(*projectables)
info['name'] = self.attrs['name']
info.update(attrs)

proj = projectables[0] - projectables[1]
proj.attrs = info
Expand Down
3 changes: 2 additions & 1 deletion satpy/tests/test_composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ def test_basic_diff(self):
"""Test that a basic difference composite works."""
from satpy.composites import DifferenceCompositor
comp = DifferenceCompositor(name='diff')
res = comp((self.ds1, self.ds2))
res = comp((self.ds1, self.ds2), standard_name='temperature_difference')
np.testing.assert_allclose(res.values, -2)
assert res.attrs.get('standard_name') == 'temperature_difference'

def test_bad_areas_diff(self):
"""Test that a difference where resolutions are different fails."""
Expand Down

0 comments on commit feea149

Please sign in to comment.