Skip to content

Commit

Permalink
Fix handling of list 'coordinates' in yaml reader
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jun 29, 2018
1 parent d8d24d6 commit bae9ef0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 0 additions & 2 deletions satpy/readers/viirs_sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ def get_dataset(self, dataset_id, ds_info):
"end_orbit": self.end_orbit_number,
})
i.update(dataset_id.to_dict())
# xarray bug does not allow differing list attributes
i.pop('coordinates', None)
data.attrs.update(i)
return data

Expand Down
10 changes: 10 additions & 0 deletions satpy/readers/yaml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ def load_ds_ids_from_config(self):
"""Get the dataset ids from the config."""
ids = []
for dataset in self.datasets.values():
# xarray doesn't like concatenating attributes that are lists
# https://github.com/pydata/xarray/issues/2060
if 'coordinates' in dataset and \
isinstance(dataset['coordinates'], list):
dataset['coordinates'] = tuple(dataset['coordinates'])
# Build each permutation/product of the dataset
id_kwargs = []
for key in DATASET_KEYS:
Expand Down Expand Up @@ -535,6 +540,11 @@ def add_ds_ids_from_files(self):
for ds_id, ds_info in avail_ids:
# don't overwrite an existing dataset
# especially from the yaml config
coordinates = ds_info.get('coordinates')
if isinstance(coordinates, list):
# xarray doesn't like concatenating attributes that are
# lists: https://github.com/pydata/xarray/issues/2060
ds_info['coordinates'] = tuple(ds_info['coordinates'])
self.ids.setdefault(ds_id, ds_info)

@staticmethod
Expand Down

0 comments on commit bae9ef0

Please sign in to comment.