Skip to content
Snippets Groups Projects
Commit d3bac131 authored by fima's avatar fima :beers:
Browse files

Zarr update to supoort data from Dask

parent a96611b1
Branches
No related tags found
No related merge requests found
...@@ -24,7 +24,6 @@ Example: ...@@ -24,7 +24,6 @@ Example:
import datetime import datetime
import os import os
import dask.array as da import dask.array as da
import h5py import h5py
import nibabel as nib import nibabel as nib
...@@ -269,14 +268,21 @@ class DataSaver: ...@@ -269,14 +268,21 @@ class DataSaver:
zarr.core.Array: The Zarr array saved on disk. zarr.core.Array: The Zarr array saved on disk.
""" """
# Old version that is using dask if isinstance(data, da.Array):
# If the data is a Dask array, save using dask
# assert isinstance(data, da.Array), 'data must be a dask array' if self.chunk_shape:
log.info("Rechunking data to shape %s", self.chunk_shape)
data = data.rechunk(self.chunk_shape)
log.info("Saving Dask array to Zarr array on disk")
da.to_zarr(data, path, overwrite=self.replace)
# # forces compute when saving to zarr else:
# da.to_zarr(data, path, compute=True, overwrite=self.replace, compressor=zarr.Blosc(cname='zstd', clevel=3, shuffle=2))
zarr_array = zarr.open( zarr_array = zarr.open(
path, mode="w", shape=data.shape, chunks=self.chunk_shape, dtype=data.dtype path,
mode="w",
shape=data.shape,
chunks=self.chunk_shape,
dtype=data.dtype,
) )
zarr_array[:] = data zarr_array[:] = data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment