.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/run_large_array_ome_zarr.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_run_large_array_ome_zarr.py: Writing a Large Array ===================== This script shows how to store a larger-than-RAM array to a OME-Zarr dataset. The same method works for HCS datasets too. .. GENERATED FROM PYTHON SOURCE LINES 10-12 .. warning:: Executing this example will write a large file. Modify the store path manually. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: Python import numpy as np from tqdm import tqdm from iohub.ngff import open_ome_zarr store_path = "" .. GENERATED FROM PYTHON SOURCE LINES 20-25 Shape and data type of the large array this array is about 10 GB, each time point is about 100 MB. It may not be actually larger than RAM but enough for demo. Monitor the memory usage of Python when the following runs and it should take significantly less than 10 GB. .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: Python shape = (100, 2, 25, 1024, 1024) dtype = np.uint16 .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. note:: This will not run if the Zarr store path is not set above Store this array by looping through the time points .. GENERATED FROM PYTHON SOURCE LINES 33-47 .. code-block:: Python if store_path: with open_ome_zarr( store_path, layout="fov", mode="w-", channel_names=["DAPI", "GFP"] ) as dataset: img = dataset.create_zeros( name="0", shape=shape, dtype=dtype, chunks=(1, 1, 1, 1024, 1024), # chunk by XY planes ) for t in tqdm(range(shape[0])): # write 4D image data for the time point img[t] = np.ones(shape[1:]) * t dataset.print_tree() .. _sphx_glr_download_auto_examples_run_large_array_ome_zarr.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_large_array_ome_zarr.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_large_array_ome_zarr.py `