Replies: 3 comments 2 replies
-
This is pretty straightforward to do if you use Zarr together with Xarray. See https://docs.xarray.dev/en/stable/user-guide/io.html#zarr for details about how to load Zarr data from Xarray. |
Beta Was this translation helpful? Give feedback.
-
I realise it might be more helpful to explain why I am not finding xarray as useful as I had hoped. For example, if I have a Zarr array and want to turn it into an xarray dataset I can do this as follows: import zarr
import xarray as xr
array = zarr.open("large-array.zarr")
dataset = xr.DataArray(array, dims=("t", "y", "x", "c")) However, this loads the whole zarr array in to memory. I see that xarray has a way to open a zarr group as a dataset but not a zarr array without loading it all into memory. Additionally, the zarr must have special additional metadata for the dimensions. There does not appear to be a way to specify the dimensions when creating a Dataset if this is missing. The datasets which I have do not have this special metadata and so this is a big pain. |
Beta Was this translation helpful? Give feedback.
-
The best solution I have found so far is to use dask e.g.: import tifffile
import dask.array
with tifffile.imread('temp.ome.tif', aszarr=True) as store:
array = dask.array.from_zarr(store, 0)
array = dask.array.moveaxis(array, (0, 1, 2), (2, 0, 1)) It just seems like something that should be doable with zarr as kind of view. I may go with this for now but it would be nice to not add dask and a lot of other child dependencies for this. |
Beta Was this translation helpful? Give feedback.
-
I am frequently coming across situations where I would like to view zarr arrays with the axes in a new order. I can do this with numpy using np.moveaxis to get a view. Is this possible with zarr? It looks like I could do this with dask but it seem silly to add a bunch of extra dependencies for a simple alternative view into the data like this. Any advice? Is this already possible or something that could be added if not?
Beta Was this translation helpful? Give feedback.
All reactions