Last active
November 27, 2025 15:02
-
-
Save akhanf/d943f10ec12f68e15463d979fe7cc5c6 to your computer and use it in GitHub Desktop.
ome-zarr-py writing to openstack 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
| import numpy as np | |
| import zarr | |
| import s3fs | |
| from zarr.storage import FsspecStore | |
| from ome_zarr.writer import write_image | |
| import os | |
| # Create data | |
| size_xy = 128 | |
| size_z = 10 | |
| rng = np.random.default_rng(0) | |
| data = rng.poisson(lam=10, size=(size_z, size_xy, size_xy)).astype(np.uint8) | |
| # Build S3 filesystem | |
| fs = s3fs.S3FileSystem( | |
| client_kwargs={"endpoint_url": "https://object-arbutus.cloud.computecanada.ca"}, | |
| asynchronous=True, | |
| config_kwargs={'request_checksum_calculation':'WHEN_REQUIRED','response_checksum_validation':'WHEN_REQUIRED'} | |
| ) | |
| # Build synchronous store | |
| store = FsspecStore( | |
| fs=fs, | |
| path="khanlab-lightsheet/test_ngff_image2.zarr", | |
| ) | |
| # Open root | |
| root = zarr.group(store=store) | |
| write_image( | |
| image=data, | |
| group=root, | |
| axes="zyx", | |
| storage_options=dict(chunks=(1, size_xy, size_xy)), | |
| ) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
assumes you have these:
~/.aws/config:
~/.aws/credentials: