Skip to content

Commit

Permalink
Merge pull request #1663 from sfinkens/fix-combine-raw-metadata
Browse files Browse the repository at this point in the history
Ignore raw metadata when combining metadata
  • Loading branch information
mraspaud committed May 10, 2021
2 parents 3bbc79d + 5f747c4 commit 88575cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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])}},
{'_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

0 comments on commit 88575cc

Please sign in to comment.