|
16 | 16 |
|
17 | 17 | try: |
18 | 18 | import dask.array as da |
19 | | - import zarr |
20 | | - from numcodecs import GZip |
21 | 19 | has_dask = True |
22 | 20 | except ImportError: |
23 | 21 | has_dask = False |
@@ -589,11 +587,7 @@ def make_scales_dask(data, data_path, is_n5, |
589 | 587 | elif downscale_factors is not None: |
590 | 588 | downsample_chunks = tuple(((64, 64, 64) for _ in range(len(downscale_factors)))) |
591 | 589 |
|
592 | | - if is_n5: |
593 | | - store = zarr.N5FSStore(data_path, overwrite=overwrite) |
594 | | - else: |
595 | | - store = zarr.DirectoryStore(data_path) |
596 | | - with zarr.open(store, mode='a') as group: |
| 590 | + with open_file(data_path, mode='a') as group: |
597 | 591 | # run all downsample steps for better data locality with dask |
598 | 592 | base_key = get_key(is_h5=False, timepoint=timepoint, setup_id=setup_id, scale=0) |
599 | 593 | have_data = base_key in group |
@@ -621,8 +615,11 @@ def make_scales_dask(data, data_path, is_n5, |
621 | 615 | save_chunks_all = [data.chunksize] |
622 | 616 | arrays = [] |
623 | 617 | for (k, v), save_chunks in zip(pyramid.items(), save_chunks_all): |
624 | | - arrays.append(group.zeros( |
625 | | - name=k, shape=v.shape, dtype=v.dtype, chunks=save_chunks, compressor=GZip(), overwrite=overwrite |
| 618 | + # deleting is required to over-write, because the shape may change |
| 619 | + if k in group and overwrite: |
| 620 | + del group[k] |
| 621 | + arrays.append(group.create_dataset( |
| 622 | + k, shape=v.shape, dtype=v.dtype, chunks=tuple(save_chunks), compression='gzip' |
626 | 623 | )) |
627 | 624 | array = da.store(pyramid.values(), arrays, lock=None, compute=compute, return_stored=return_stored) |
628 | 625 |
|
|
0 commit comments