@@ -52,6 +52,18 @@ def _coarsen(
52
52
class Downsampler :
53
53
"""
54
54
A class for downsampling a pre-existing 3D zarr array.
55
+
56
+ Parameters
57
+ ----------
58
+ zarr_store_path:
59
+ will be passed to zarr.open(zarr_store_path)
60
+ refine_factor:
61
+ refinement factor in each dimension, e.g., (2,2,2)
62
+ level_0_res:
63
+ resolution of the base array to be downsampled
64
+ chunks:
65
+ chunk size of the base array to be downsampled. The
66
+ same chunk size will be used for all levels.
55
67
"""
56
68
57
69
def __init__ (
@@ -154,6 +166,25 @@ def downsample(
154
166
max_levels : int ,
155
167
zarr_field : str ,
156
168
) -> None :
169
+ """
170
+ Downsample a 3D zarr array.
171
+
172
+ Will proceed until max_levels is reached or until the array can
173
+ no longer be subdivided (the array is a single chunk).
174
+
175
+ Parameters
176
+ ----------
177
+ max_levels:
178
+ maximum levels to allow
179
+ zarr_field:
180
+ the field to downsample. Assumes the base level 0 array exists
181
+ at zarr_store[zarr_field][0].
182
+
183
+ Returns
184
+ -------
185
+ None
186
+ results written to the zarr store.
187
+ """
157
188
if max_levels <= 0 :
158
189
msg = f"max_level must exceed 0, found { max_levels } "
159
190
raise ValueError (msg )
@@ -213,6 +244,30 @@ def initialize_test_image(
213
244
overwrite_field : bool = True ,
214
245
dtype : str | type | None = None ,
215
246
) -> None :
247
+ """
248
+ create a 3D base level 0 array in an active zarr store.
249
+
250
+ Array values will be random + an offset in the lower quadrant
251
+ of the array. For float dtypes, random values are in range 0,1 with
252
+ an offset of 0.5 while for int dtypes, values or in 0, 100 with offset of
253
+ 50.
254
+
255
+ Parameters
256
+ ----------
257
+ zarr_store:
258
+ the open zarr store
259
+ zarr_field:
260
+ the field to create. Array will be stored at zarr_store[zarr_field][0]
261
+ base_resolution:
262
+ the resolution of the array
263
+ chunks:
264
+ the chunk sizes for the array along each dimension. If a single value,
265
+ will use the same for all dimensions. Defaults to (64,64,64).
266
+ overwrite_field:
267
+ if True (default False), will overwrite existing field.
268
+ dtype:
269
+ the dtype to use, defaults to float64.
270
+ """
216
271
if dtype is None :
217
272
dtype = np .float64
218
273
field1 = zarr_store .create_group (zarr_field , overwrite = overwrite_field )
0 commit comments