1

Suppose I had a zarr file that has n groups each of which have only one zarr array and share at least 3 dimensions but may have others as well, how would I load an xarray Dataset from said zarr root file while aligning their common dimensions and preserving attributes?

Currently I am experimenting with a hack where I list the individual zarr groups using glob and feeding them as a list to xr.open_mfdataset(list_of_zarr_groups,engine=‘zarr’, but surely there must be a better way.

1
  • 1
    The ability to work with multiple groups and other tree-like/hierarchical structures is part of the xarray development roadmap. But for now, your approach sounds fine! Commented Jul 29, 2022 at 5:46

1 Answer 1

2

Using xarray-datatree you can open all groups in a Zarr store at once as a single DataTree object. You can then extract the different groups as individual xarray.Dataset objects. Just call datatree.open_datatree(zarr_store, engine="zarr").

(As @michael-delgado said, this is being actively developed as part of the xarray roadmap.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.