@@ -1699,7 +1699,11 @@ def get_x(self, var, coords=None):
16991699 triangles = self .get_triangles (var , coords )
17001700 centers = triangles .x [triangles .triangles ].mean (axis = - 1 )
17011701 x = self .get_nodes (self .get_mesh (var , coords ), coords )[0 ]
1702- return xr .IndexVariable (x .name , centers , attrs = x .attrs .copy ())
1702+ try :
1703+ cls = xr .IndexVariable
1704+ except AttributeError : # xarray < 0.9
1705+ cls = xr .Coordinate
1706+ return cls (x .name , centers , attrs = x .attrs .copy ())
17031707
17041708 @docstrings .dedent
17051709 def get_y (self , var , coords = None ):
@@ -1723,7 +1727,11 @@ def get_y(self, var, coords=None):
17231727 triangles = self .get_triangles (var , coords )
17241728 centers = triangles .y [triangles .triangles ].mean (axis = - 1 )
17251729 y = self .get_nodes (self .get_mesh (var , coords ), coords )[1 ]
1726- return xr .IndexVariable (y .name , centers , attrs = y .attrs .copy ())
1730+ try :
1731+ cls = xr .IndexVariable
1732+ except AttributeError : # xarray < 0.9
1733+ cls = xr .Coordinate
1734+ return cls (y .name , centers , attrs = y .attrs .copy ())
17271735
17281736
17291737# register the UGridDecoder
0 commit comments