Closed
Description
Is your feature request related to a problem?
If I want to write to a region of data in a zarr, I usually have some boilerplate code like this:
ds_existing = xr.open_zarr(path)
ds_new = xr.Dataset(...) # come up with some new data for a subset region of the existing zarr
start_idx = (ds_existing.time == ds_new.time[0]).argmax()
end_idx = (ds_existing.time == ds_new.time[-1]).argmax()
ds_new.to_zarr(path, region={"time": slice(start_idx, end_idx})
Describe the solution you'd like
It would be nice to automate this within to_zarr
, because having to drop into index-space always feels un-xarray-like to me.
There may be pitfalls I'm not thinking of, and I don't know exactly what the API would look like.
ds_new.to_zarr(path, region={"time": "auto"}) # ???
Describe alternatives you've considered
No response
Additional context
No response