Skip to content

Commit 05382e8

Browse files
committed
Try the STASH attribute when checking for possible names (as is already done in the summary method)
1 parent 1ef03fa commit 05382e8

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/iris/_cube_coord_common.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# (C) British Crown Copyright 2010 - 2016, Met Office
1+
# (C) British Crown Copyright 2010 - 2018, Met Office
22
#
33
# This file is part of Iris.
44
#
@@ -88,12 +88,13 @@ def name(self, default='unknown'):
8888
"""
8989
Returns a human-readable name.
9090
91-
First it tries :attr:`standard_name`, then 'long_name', then 'var_name'
92-
before falling back to the value of `default` (which itself defaults to
93-
'unknown').
91+
First it tries :attr:`standard_name`, then 'long_name', then
92+
'var_name', then the STASH attribute before falling back to
93+
the value of `default` (which itself defaults to 'unknown').
9494
9595
"""
96-
return self.standard_name or self.long_name or self.var_name or default
96+
return self.standard_name or self.long_name or self.var_name or \
97+
str(self.attributes.get('STASH', default))
9798

9899
def rename(self, name):
99100
"""

lib/iris/cube.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# (C) British Crown Copyright 2010 - 2017, Met Office
1+
# (C) British Crown Copyright 2010 - 2018, Met Office
22
#
33
# This file is part of Iris.
44
#
@@ -1770,9 +1770,6 @@ def summary(self, shorten=False, name_padding=35):
17701770

17711771
nameunit = '{name} / ({units})'.format(name=self.name(),
17721772
units=self.units)
1773-
# If all unknown and a STASH attribute exists, use it.
1774-
if nameunit == 'unknown / (unknown)' and 'STASH' in self.attributes:
1775-
nameunit = '{}'.format(self.attributes['STASH'])
17761773
cube_header = '{nameunit!s:{length}} ({dimension})'.format(
17771774
length=name_padding,
17781775
nameunit=nameunit,

0 commit comments

Comments
 (0)