Skip to content

Commit

Permalink
Convert any attribute starting with "{" to string
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinkens committed Dec 18, 2023
1 parent 8b29b8f commit d9ec744
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions satpy/readers/satpy_cf_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,8 @@ def get_dataset(self, ds_id, ds_info):
return data

def _decode_dict_type_attrs(self, data):
for key in ["orbital_parameters", "time_parameters"]:
try:
data.attrs[key] = _str2dict(data.attrs[key])
except KeyError:
continue
for key, val in data.attrs.items():
data.attrs[key] = _str2dict(val)

def get_area_def(self, dataset_id):
"""Get area definition from CF complient netcdf."""
Expand All @@ -346,6 +343,6 @@ def _datetime_parser(json_dict):

def _str2dict(val):
"""Convert string to dictionary."""
if isinstance(val, str):
if isinstance(val, str) and val.startswith("{"):
val = json.loads(val, object_hook=_datetime_parser)
return val

0 comments on commit d9ec744

Please sign in to comment.