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

Ignore raw metadata when combining metadata #1663

Merged
merged 3 commits into from May 10, 2021
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
4 changes: 3 additions & 1 deletion satpy/dataset/metadata.py
Expand Up @@ -33,7 +33,8 @@ def combine_metadata(*metadata_objects, average_times=True):
in them and consisting of datetime objects will be averaged. This
is to handle cases where data were observed at almost the same time
but not exactly. In the interest of time, lazy arrays are compared by
object identity rather than by their contents.
object identity rather than by their contents. Raw dataset metadata
(`raw_metadata` attribute) are excluded as well.

Args:
*metadata_objects: MetadataObject or dict objects to combine
Expand All @@ -49,6 +50,7 @@ def combine_metadata(*metadata_objects, average_times=True):
return info_dicts[0].copy()

shared_keys = _shared_keys(info_dicts)
shared_keys.discard('raw_metadata')

return _combine_shared_info(shared_keys, info_dicts, average_times)

Expand Down
6 changes: 4 additions & 2 deletions satpy/tests/test_dataset.py
Expand Up @@ -250,7 +250,8 @@ def test_combine_real_world_mda(self):
'cpp_reff_pal',
'-'],
'platform_name': 'NOAA-20',
'sensor': {'viirs'}},
'sensor': {'viirs'},
'raw_metadata': {'foo': np.array([1, 2, 3])}},
djhoese marked this conversation as resolved.
Show resolved Hide resolved
{'_FillValue': np.nan,
'valid_range': np.array([0., 0.00032], dtype=np.float32),
'ancillary_variables': ['cpp_status_flag',
Expand All @@ -259,7 +260,8 @@ def test_combine_real_world_mda(self):
'cpp_reff_pal',
'-'],
'platform_name': 'NOAA-20',
'sensor': {'viirs'}})
'sensor': {'viirs'},
'raw_metadata': {'foo': np.array([2, 3, 4])}})

expected = {'_FillValue': np.nan,
'valid_range': np.array([0., 0.00032], dtype=np.float32),
Expand Down