Skip to content

Instantly share code, notes, and snippets.

@d-v-b
Created January 16, 2025 10:32
Show Gist options
  • Save d-v-b/48408024df375855523b47e7b5d6d592 to your computer and use it in GitHub Desktop.
Save d-v-b/48408024df375855523b47e7b5d6d592 to your computer and use it in GitHub Desktop.
zarr-python 3 array creation example
# /// 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