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

Fix DifferenceCompositor not using metadata from YAML #2054

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def __call__(self, projectables, nonprojectables=None, **attrs):
projectables = self.match_data_arrays(projectables)
info = combine_metadata(*projectables)
info['name'] = self.attrs['name']
info.update(attrs)
info.update(self.attrs) # attrs from YAML/__init__
info.update(attrs) # overwriting of DataID properties

proj = projectables[0] - projectables[1]
proj.attrs = info
Expand Down
4 changes: 2 additions & 2 deletions satpy/tests/test_composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ def setUp(self):
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), standard_name='temperature_difference')
comp = DifferenceCompositor(name='diff', standard_name='temperature_difference')
res = comp((self.ds1, self.ds2))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was incorrect. Passing standard_name to the __call__ method of a compositor will never happen. Only the Scene calls __call__ and it passed the DataID properties computed during dependency decisions. The __init__ method is when metadata from the YAML are passed.

np.testing.assert_allclose(res.values, -2)
assert res.attrs.get('standard_name') == 'temperature_difference'

Expand Down