Skip to content

Commit 4b64351

Browse files
committed
add docstrings
1 parent 81c37fd commit 4b64351

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/pyramid_sampler/sampler.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ def _coarsen(
5252
class Downsampler:
5353
"""
5454
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.
5567
"""
5668

5769
def __init__(
@@ -154,6 +166,25 @@ def downsample(
154166
max_levels: int,
155167
zarr_field: str,
156168
) -> 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+
"""
157188
if max_levels <= 0:
158189
msg = f"max_level must exceed 0, found {max_levels}"
159190
raise ValueError(msg)
@@ -213,6 +244,30 @@ def initialize_test_image(
213244
overwrite_field: bool = True,
214245
dtype: str | type | None = None,
215246
) -> 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+
"""
216271
if dtype is None:
217272
dtype = np.float64
218273
field1 = zarr_store.create_group(zarr_field, overwrite=overwrite_field)

0 commit comments

Comments
 (0)