Skip to content

Commit

Permalink
Ignore raw metadata when combining metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinkens committed May 6, 2021
1 parent 6df2f10 commit 202c6fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion satpy/dataset/metadata.py
Original file line number Diff line number Diff line change
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
are excluded as well.
Args:
*metadata_objects: MetadataObject or dict objects to combine
Expand All @@ -49,6 +50,10 @@ def combine_metadata(*metadata_objects, average_times=True):
return info_dicts[0].copy()

shared_keys = _shared_keys(info_dicts)
try:
shared_keys.remove('raw_metadata')
except KeyError:
pass

return _combine_shared_info(shared_keys, info_dicts, average_times)

Expand Down
6 changes: 4 additions & 2 deletions satpy/tests/test_dataset.py
Original file line number Diff line number Diff line change
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 202c6fd

Please sign in to comment.