Skip to content

Zarr

linc_convert.utils.io.zarr

ZarrIO module for handling Zarr data structures.

ZarrPythonArray

ZarrPythonArray(array)

Bases: ZarrArray

Zarr Array implementation using the zarr-python library.

Initialize the ZarrPythonArray with a zarr.Array.

Parameters:

Name Type Description Default
array Array

Underlying Zarr array.

required

ndim property

ndim

Number of dimensions of the array.

shape property

shape

Shape of the array.

dtype property

dtype

Data type of the array.

chunks property

chunks

Chunk shape for the array.

shards property

shards

Shard shape, if supported; otherwise None.

attrs property

attrs

Access metadata/attributes for this node.

zarr_version property

zarr_version

Get the Zarr format version.

__getitem__

__getitem__(key)

Read data from the array.

__setitem__

__setitem__(key, value)

Write data to the array.

__getattr__

__getattr__(name)

Delegate any unknown attributes to the underlying array.

ZarrPythonGroup

ZarrPythonGroup(zarr_group)

Bases: ZarrGroup

Zarr Group implementation using the zarr-python library.

Initialize the ZarrPythonGroup with a zarr.Group.

Parameters:

Name Type Description Default
zarr_group Group

Underlying Zarr Python group.

required

attrs property

attrs

Access metadata/attributes for this node.

zarr_version property

zarr_version

Get the Zarr format version.

from_config classmethod

from_config(out, zarr_config)

Create a Zarr group from a configuration object.

keys

keys()

Get the names of all subgroups and arrays in this group.

__getitem__

__getitem__(key)

Get a subgroup or array by name within this group.

__setitem__

__setitem__(key, value)

Set a subgroup or array by name within this group.

__delitem__

__delitem__(key)

Delete a subgroup or array by name within this group.

__iter__

__iter__()

Iterate over the names of all subgroups and arrays in this group.

__getattr__

__getattr__(name)

Delegate attribute access to the underlying Zarr group.

create_group

create_group(name, overwrite=False)

Create or open a subgroup within this group.

create_array

create_array(name, shape, dtype, *, zarr_config=None, data=None, **kwargs)

Create a new array within this group.

create_array_from_base

create_array_from_base(name, shape, data=None, **kwargs)

Create a new array using the properties from a base_level object.

ZarrTSArray

ZarrTSArray(ts_array)

Bases: ZarrArray

Zarr array backed by TensorStore.

Initialize the ZarrTSArray with a TensorStore array.

Parameters:

Name Type Description Default
ts_array TensorStore

Underlying TensorStore array.

required

ndim property

ndim

Number of dimensions of the array.

shape property

shape

Shape of the array.

dtype property

dtype

Data type of the array.

chunks property

chunks

Chunk shape for the array.

shards property

shards

Shard shape, if supported; otherwise None.

attrs property

attrs

Access metadata/attributes for this node.

zarr_version property

zarr_version

Get the Zarr format version.

__getitem__

__getitem__(key)

Read data from the array.

__setitem__

__setitem__(key, value)

Write data to the array.

open classmethod

open(path, mode='a', *, zarr_version=3)

Open an existing Zarr array.

Parameters:

Name Type Description Default
path Union[str, PathLike]

Path to the array’s directory.

required
zarr_version (2, 3)

Zarr format version to use.

2
mode (r, 'r+', a, w, 'w-')

Persistence mode: 'r' means read only (must exist); 'r+' means read/write (must exist); 'a' means read/write (create if doesn't exist); 'w' means create (overwrite if exists); 'w-' means create (fail if exists).

'r','r+','a','w','w-'

Returns:

Type Description
ZarrTSArray

ZarrTSGroup

ZarrTSGroup(store_path)

Bases: ZarrGroup

Zarr Group implementation using TensorStore as backend.

Initialize the ZarrTSGroup.

Parameters:

Name Type Description Default
store_path Union[str, PathLike]

Path to the group’s directory.

required

attrs property

attrs

Access attributes for this node.

metadata property

metadata

Access metadata for this node.

zarr_version property

zarr_version

Get the Zarr format version.

from_config classmethod

from_config(out, zarr_config)

Create a ZarrTSGroup from a configuration object.

Parameters:

Name Type Description Default
zarr_config ZarrConfig

Configuration with .out and .zarr_version.

required

Returns:

Type Description
ZarrTSGroup

open classmethod

open(path, mode='a', *, zarr_version=3)

Open or create a Zarr group backed by TensorStore.

Parameters:

Name Type Description Default
path Union[str, PathLike]

Path to the Zarr group.

required
mode (r, 'r+', a, w, 'w-')

Persistence mode: 'r' means read only (must exist); 'r+' means read/write (must exist); 'a' means read/write (create if doesn't exist); 'w' means create (overwrite if exists); 'w-' means create (fail if exists).

'r','r+','a','w','w-'
zarr_version (2, 3)

Zarr format version.

2,3

Returns:

Type Description
ZarrTSGroup

__getitem__

__getitem__(key)

Get a subgroup or array by name within this group.

__setitem__

__setitem__(key, value)

Set a subgroup or array by name within this group.

__delitem__

__delitem__(key)

Delete a subgroup or array by name within this group.

keys

keys()

Get the names of all subgroups and arrays in this group.

__contains__

__contains__(name)

Check whether a subgroup or array exists in this group.

create_group

create_group(name, overwrite=False)

Create or open a subgroup within this group.

Parameters:

Name Type Description Default
name str
required
overwrite bool

If True, delete existing before creating.

False

Returns:

Type Description
ZarrTSGroup

create_array

create_array(name, shape, dtype=np.int32, *, overwrite=True, data=None, zarr_config=None, **kwargs)

Create a new array within this group.

Parameters:

Name Type Description Default
name str
required
shape Sequence[int]
required
dtype DTypeLike
int32
overwrite bool
True
zarr_config ZarrConfig | None
None
data ArrayLike | None
None

Returns:

Type Description
ZarrTSArray

create_array_from_base

create_array_from_base(name, shape, data=None, **kwargs)

Create a new array using metadata of an existing base-level array.

Parameters:

Name Type Description Default
name str
required
shape Sequence[int]
required
data ArrayLike | None
None

Returns:

Type Description
ZarrTSArray