Skip to content

Commit

Permalink
Fix mergeback PR SciTools#4035
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Aug 8, 2021
1 parent 45e7a1c commit e7cb050
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/iris/fileformats/_nc_load_rules/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,23 @@ def action_ukmo_stash(engine):
attr_name = "ukmo__um_stash_source"
attr_value = getattr(var, attr_name, None)
if attr_value is None:
attr_altname = "um_stash_source" # legacy form
attr_value = getattr(var, attr_altname, None)
attr_name = "um_stash_source" # legacy form
attr_value = getattr(var, attr_name, None)
if attr_value is None:
rule_name += "(NOT-TRIGGERED)"
else:
# No helper routine : just do it
engine.cube.attributes["STASH"] = pp.STASH.from_msi(attr_value)
try:
stash_code = pp.STASH.from_msi(attr_value)
except (TypeError, ValueError):
engine.cube.attributes[attr_name] = attr_value
msg = (
"Unable to set attribute STASH as not a valid MSI "
f'string "mXXsXXiXXX", got {attr_value}'
)
warnings.warn(msg)
else:
engine.cube.attributes["STASH"] = stash_code

return rule_name

Expand Down

0 comments on commit e7cb050

Please sign in to comment.