Skip to content

Commit 217571e

Browse files
authored
Merge 904d990 into b62c743
2 parents b62c743 + 904d990 commit 217571e

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

lib/iris/mesh/components.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,22 @@ def __getattribute__(self, item):
28282828
# by calling the method on the base class `object`
28292829
updating = object.__getattribute__(self, "_updating")
28302830
if updating is False and item != "update_from_mesh":
2831-
object.__getattribute__(self, "update_from_mesh")()
2831+
# Don't update the points/bounds if you're only getting metadata
2832+
if item not in (
2833+
"_metadata_manager_temp",
2834+
"_metadata_manager",
2835+
"standard_name",
2836+
"long_name",
2837+
"var_name",
2838+
"units",
2839+
"attributes",
2840+
"climatological",
2841+
"coord_system",
2842+
"attributes",
2843+
):
2844+
object.__getattribute__(self, "update_from_mesh")(True)
2845+
else:
2846+
object.__getattribute__(self, "update_from_mesh")(False)
28322847
return super().__getattribute__(item)
28332848

28342849
# Define accessors for MeshCoord-specific properties mesh/location/axis.
@@ -2974,15 +2989,6 @@ def bounds(self, value):
29742989
@property
29752990
def _metadata_manager(self):
29762991
# sets the metadata
2977-
use_metadict = self._load_metadata()
2978-
2979-
self._metadata_manager_temp.standard_name = use_metadict["standard_name"]
2980-
self._metadata_manager_temp.long_name = use_metadict["long_name"]
2981-
self._metadata_manager_temp.var_name = use_metadict["var_name"]
2982-
self._metadata_manager_temp.units = use_metadict["units"]
2983-
self._metadata_manager_temp.attributes = use_metadict["attributes"]
2984-
self._metadata_manager_temp.coord_system = use_metadict["coord_system"]
2985-
self._metadata_manager_temp.climatological = use_metadict["climatological"]
29862992
return self._metadata_manager_temp
29872993

29882994
def __getitem__(self, keys):
@@ -2998,15 +3004,30 @@ def __getitem__(self, keys):
29983004
# Translate "self[:,]" as "self.copy()".
29993005
return self.copy()
30003006

3001-
def update_from_mesh(self):
3007+
def update_from_mesh(self, points_and_bounds=True):
30023008
try:
30033009
object.__setattr__(self, "_updating", True)
30043010
if (self._last_modified is None) or (
30053011
self._last_modified < self.mesh._last_modified
30063012
):
3007-
points, bounds = self._load_points_and_bounds()
3008-
super(MeshCoord, self.__class__).points.fset(self, points)
3009-
super(MeshCoord, self.__class__).bounds.fset(self, bounds)
3013+
# update metadata
3014+
use_metadict = self._load_metadata()
3015+
self._metadata_manager_temp.standard_name = use_metadict[
3016+
"standard_name"
3017+
]
3018+
self._metadata_manager_temp.long_name = use_metadict["long_name"]
3019+
self._metadata_manager_temp.var_name = use_metadict["var_name"]
3020+
self._metadata_manager_temp.units = use_metadict["units"]
3021+
self._metadata_manager_temp.attributes = use_metadict["attributes"]
3022+
self._metadata_manager_temp.coord_system = use_metadict["coord_system"]
3023+
self._metadata_manager_temp.climatological = use_metadict[
3024+
"climatological"
3025+
]
3026+
if points_and_bounds:
3027+
# update points and bounds
3028+
points, bounds = self._load_points_and_bounds()
3029+
super(MeshCoord, self.__class__).points.fset(self, points)
3030+
super(MeshCoord, self.__class__).bounds.fset(self, bounds)
30103031
object.__setattr__(self, "_last_modified", self.mesh._last_modified)
30113032
# Ensure errors aren't bypassed
30123033
except Exception as e:

0 commit comments

Comments
 (0)