Skip to content

Commit

Permalink
Don't call v.values
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jul 11, 2024
1 parent 3aa592e commit fa5de06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/anemoi/datasets/create/functions/sources/xarray/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ def __init__(self, owner, selection):
coordinate = owner.by_name[coord_name]
self._md[coord_name] = coordinate.normalise(extract_single_value(coord_value))

values = self.selection.values
# print(values.ndim, values.shape, selection.dims)
# By now, the only dimensions should be latitude and longitude
self._shape = tuple(list(values.shape)[-2:])
if math.prod(self._shape) != math.prod(values.shape):
print(values.ndim, values.shape)
self._shape = tuple(list(self.selection.shape)[-2:])
if math.prod(self._shape) != math.prod(self.selection.shape):
print(self.selection.ndim, self.selection.shape)
print(self.selection)
raise ValueError("Invalid shape for selection")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,16 @@ def _is_x(self, c, *, axis, name, long_name, standard_name, units):
if standard_name == "projection_x_coordinate":
return XCoordinate(c)

if name == "x":
return XCoordinate(c)

def _is_y(self, c, *, axis, name, long_name, standard_name, units):
if standard_name == "projection_y_coordinate":
return YCoordinate(c)

if name == "y":
return YCoordinate(c)

def _is_time(self, c, *, axis, name, long_name, standard_name, units):
if standard_name == "time":
return TimeCoordinate(c)
Expand Down

0 comments on commit fa5de06

Please sign in to comment.