Closed Huite closed 3 months ago
Fix is more or less this in StructuredGrid1d:
@property
def coords(self) -> dict:
coords = {self.name: self.index}
if isinstance(self.dvalue, np.ndarray):
coords[self.dname] = (self.name, self.dvalue)
else:
coords[self.dname] = self.dvalue
return coords
In fact, a non-scalar for dvalue
always fails regardless of origin:
x = np.arange(xmin, xmax, 1000.0)
y = np.arange(xmin, xmax, 1000.0)
da = xr.DataArray(
data=np.zeros((y.size, x.size)),
coords={"y": y, "x": x, "dx": ("x", np.full(x.size, 1000.0)), "dy": ("y", np.full(y.size, 1000.0))},
dims=["y", "x"]
)
The snippet below fails because a dx and dy coordinate is generated as a numpy array internally. Then it tries to assign it via assign_coords to the regridded result, but is missing the dx dim. It should be marked as dependent on x: coord = ("x", dx)