Skip to content

Commit 4f1b9ba

Browse files
committed
hacky solution for meshgrid issue in grid.py
1 parent 4abd0cc commit 4f1b9ba

File tree

1 file changed

+14
-4
lines changed
  • src/anemoi/datasets/create/functions/sources/xarray

1 file changed

+14
-4
lines changed

src/anemoi/datasets/create/functions/sources/xarray/grid.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, lat, lon, variable_dims):
3535
super().__init__()
3636
self.lat = lat
3737
self.lon = lon
38+
self.variable_dims = variable_dims
3839

3940

4041
class XYGrid(Grid):
@@ -48,10 +49,19 @@ class MeshedGrid(LatLonGrid):
4849
@cached_property
4950
def grid_points(self):
5051

51-
lat, lon = np.meshgrid(
52-
self.lat.variable.values,
53-
self.lon.variable.values,
54-
)
52+
if self.variable_dims == ("longitude", "latitude"):
53+
lat, lon = np.meshgrid(
54+
self.lat.variable.values,
55+
self.lon.variable.values,
56+
)
57+
elif self.variable_dims == ("latitude", "longitude"):
58+
lon, lat = np.meshgrid(
59+
self.lon.variable.values,
60+
self.lat.variable.values,
61+
)
62+
63+
else:
64+
raise NotImplementedError(f"MeshedGrid.grid_points: unrecognized variable_dims {self.variable_dims}")
5565

5666
return lat.flatten(), lon.flatten()
5767

0 commit comments

Comments
 (0)