1414"""
1515import logging
1616import pathlib
17+ import zarr
1718from typing import Callable
19+ from typing import Mapping
1820from typing import Optional
1921from typing import Sequence
2022from typing import Union
@@ -33,6 +35,7 @@ def build_pyramid(
3335 coarsening_xy : int = 2 ,
3436 chunksize : Optional [Sequence [int ]] = None ,
3537 aggregation_function : Optional [Callable ] = None ,
38+ open_array_kwargs : Optional [Mapping ] = None ,
3639) -> None :
3740
3841 """
@@ -48,6 +51,7 @@ def build_pyramid(
4851 coarsening_xy: Linear coarsening factor between subsequent levels.
4952 chunksize: Shape of a single chunk.
5053 aggregation_function: Function to be used when downsampling.
54+ open_array_kwargs: Additional arguments for zarr.open.
5155 """
5256
5357 # Clean up zarrurl
@@ -100,10 +104,21 @@ def build_pyramid(
100104 f"{ str (newlevel_rechunked )} "
101105 )
102106
107+ if open_array_kwargs is None :
108+ open_array_kwargs = {}
109+
110+ zarrarr = zarr .open (
111+ f"{ zarrurl } /{ ind_level } " ,
112+ shape = newlevel_rechunked .shape ,
113+ chunks = newlevel_rechunked .chunksize ,
114+ dtype = newlevel_rechunked .dtype ,
115+ mode = "w" ,
116+ ** open_array_kwargs ,
117+ )
118+
103119 # Write zarr and store output (useful to construct next level)
104120 previous_level = newlevel_rechunked .to_zarr (
105- zarrurl ,
106- component = f"{ ind_level } " ,
121+ zarrarr ,
107122 overwrite = overwrite ,
108123 compute = True ,
109124 return_stored = True ,
0 commit comments