I have a Zarr datastore, but I need to rename one of the dimensions. Let's say I have this (from xarray docs):
data = np.random.rand(4, 3)
locs = ["IA", "IL", "IN"]
times = pd.date_range("2000-01-01", periods=4)
da = xr.DataArray(data, coords=[times, locs], dims=["time", "space"])
ds = xr.Dataset({'my_var': da})
ds.to_zarr("my_zarr.zarr")
But I want to my space
dimension to actually to be called state
.
And I don't want to write a new Zarr store, I just want to change that one name.
How can I do that? (I've found one hacky way - see below)
My hacky solution is to rename them manually:
.zattts
files:OLD
my_zarr.zarr/my_var/.zattrs
OLD
my_zarr.zarr/state/.zattrs
NEW
my_zarr.zarr/my_var/.zattrs
NEW
my_zarr.zarr/state/.zattrs
And voila:
But that's pretty hacky and I don't like how manual it is. It beats writing a whole new zarr store, but is there a better way?