Skip to content

Commit

Permalink
Fixed attribute handling in emergent constraint diagnostic for iris>=…
Browse files Browse the repository at this point in the history
…3.8 (#3605)
  • Loading branch information
schlunma committed May 21, 2024
1 parent b90e6e9 commit 7513b72
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions esmvaltool/diag_scripts/emergent_constraints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,16 @@ def _get_data_frame(var_type, cubes, label_all_data, group_by=None):

def _metadata_to_dict(metadata):
"""Convert :class:`iris.cube.CubeMetadata` to :obj:`dict`."""
new_dict = {}
for (key, val) in metadata._asdict().items():
if isinstance(val, dict):
new_dict.update(val)
else:
new_dict[key] = val
new_dict = dict(metadata.attributes)
other_keys = [
'standard_name',
'long_name',
'var_name',
'units',
'cell_methods',
]
for key in other_keys:
new_dict[key] = getattr(metadata, key)
return new_dict


Expand Down

0 comments on commit 7513b72

Please sign in to comment.