Zarr chunks keys in xarray

Reposting from gitter, as I think it’ll get more attention here:

If I have a zarr-backed xarray dataset, is there a way to go from coordinate location to zarr chunk key without attempting to load the data?

Can I .map() this information, i.e., create a dataset whose value is a function of that filename, e.g., whether it exists or not?

2 Likes

Rather than call ds.sel(lon=45) you would get the Pandas index directly, e.g. ds.indexes['lon'] , and then use the index to map your selection to logical coordinates. From there, it’s straightforward to map array indices to chunk indices.

The Pangeo Forge (internal) ChunkGrid object could be useful there: pangeo-forge-recipes/chunk_grid.py at master · pangeo-forge/pangeo-forge-recipes · GitHub

2 Likes