Input/output (ome_zarr.io)

Reading logic for ome-zarr.

Primary entry point is the parse_url() method.

class ome_zarr.io.ZarrLocation(path: StoreLike, mode: str = 'r', fmt: Format = FormatV05)[source]

IO primitive for reading and writing Zarr data. Uses a store for all data access.

No assumptions about the existence of the given path string are made. Attempts are made to load various metadata files and cache them internally.

basename() str[source]

Return the last element of the underlying location.

>>> ZarrLocation("/tmp/foo").basename()
'foo'
>>> ZarrLocation("https://example.com/bar").basename()
'bar'
>>> ZarrLocation("https://example.com/baz/").basename()
'baz'
create(path: str) ZarrLocation[source]

Create a new Zarr location for the given path.

exists() bool[source]

Return true if either zgroup or zarray metadata exists.

load(subpath: str = '') Array[source]

Use dask.array.from_zarr to load the subpath.

property root_attrs: dict[str, Any]

Return the contents of the zattrs file.

property store: FsspecStore

Return the initialized store for this location

property version: str

Return the version of the OME-NGFF spec used for this location.

ome_zarr.io.parse_url(path: Path | str, mode: str = 'r', fmt: Format = FormatV05) ZarrLocation | None[source]

Convert a path string or URL to a ZarrLocation subclass.

Parameters:
  • path – Path to parse.

  • mode – Mode to open in.

  • fmt – Version of the OME-NGFF spec to open path with.

Returns:

ZarrLocation. If mode is ‘r’, and the path does not exist returns None. If there is an error opening the path, also returns None.

>>> parse_url('does-not-exist')