Created
January 16, 2025 10:32
-
-
Save d-v-b/48408024df375855523b47e7b5d6d592 to your computer and use it in GitHub Desktop.
zarr-python 3 array creation example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# requires-python = ">=3.11" | |
# dependencies = [ | |
# "zarr == 3.0.0", | |
# ] | |
# /// | |
from zarr import create_array | |
import numpy as np | |
data = np.arange(1024 ** 3).reshape((1024,) * 3).astype('uint8') | |
arr = create_array( | |
'path/to/data.zarr', # or s3://bucket/path/to/data.zarr | |
shape=data.shape, | |
dtype=data.dtype, | |
shards=data.shape, # just 1 shard | |
chunks=(64,) * 3, # nice small chunks | |
compressors='auto', # use default compression | |
) | |
arr[:] = data # fill the array with valus | |
print(arr.info_complete()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment