Convenience sub-module
zarr.convenience ¶
Convenience helpers.
Deprecated
This sub-module is deprecated. All functions here are defined in the top level zarr namespace instead.
consolidate_metadata ¶
consolidate_metadata(
store: StoreLike,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
) -> Group
Consolidate the metadata of all nodes in a hierarchy.
Upon completion, the metadata of the root node in the Zarr hierarchy will be
updated to include all the metadata of child nodes. For Stores that do
not use consolidated metadata, this operation raises a TypeError
.
Parameters:
-
store
(StoreLike
) –The store-like object whose metadata you wish to consolidate.
-
path
(str
, default:None
) –A path to a group in the store to consolidate at. Only children below that group will be consolidated.
By default, the root node is used so all the metadata in the store is consolidated.
-
zarr_format
((2, 3, None)
, default:2
) –The zarr format of the hierarchy. By default the zarr format is inferred.
Returns:
-
group
(Group
) –The group, with the
consolidated_metadata
field set to include the metadata of each child node. If the Store doesn't support consolidated metadata, this function raises aTypeError
. SeeStore.supports_consolidated_metadata
.
Source code in zarr/api/synchronous.py
copy ¶
copy_all ¶
copy_store ¶
load ¶
load(
store: StoreLike,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
zarr_version: ZarrFormat | None = None,
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]
Load data from an array or group into memory.
Parameters:
-
store
(StoreLike
) –Store or path to directory in file system or name of zip file.
-
path
(str or None
, default:None
) –The path within the store from which to load.
Returns:
-
out
–If the path contains an array, out will be a numpy array. If the path contains a group, out will be a dict-like object where keys are array names and values are numpy arrays.
See Also
save, savez
Notes
If loading data from a group of arrays, data will not be immediately loaded into memory. Rather, arrays will be loaded into memory as they are requested.
Source code in zarr/api/synchronous.py
open ¶
open(
store: StoreLike | None = None,
*,
mode: AccessModeLiteral | None = None,
zarr_version: ZarrFormat | None = None,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> Array | Group
Open a group or array using file-mode-like semantics.
Parameters:
-
store
(StoreLike or None
, default:None
) –Store or path to directory in file system or name of zip file.
-
mode
(('r', 'r+', 'a', 'w', 'w-')
, default:'r'
) –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). If the store is read-only, the default is 'r'; otherwise, it is 'a'.
-
zarr_format
((2, 3, None)
, default:2
) –The zarr format to use when saving.
-
path
(str or None
, default:None
) –The path within the store to open.
-
storage_options
(dict
, default:None
) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs
(Any
, default:{}
) –Additional parameters are passed through to
zarr.creation.open_array
oropen_group
.
Returns:
Source code in zarr/api/synchronous.py
open_consolidated ¶
Alias for open_group
with use_consolidated=True
.
Source code in zarr/api/synchronous.py
save ¶
save(
store: StoreLike,
*args: NDArrayLike,
zarr_version: ZarrFormat | None = None,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
**kwargs: Any,
) -> None
Save an array or group of arrays to the local file system.
Parameters:
-
store
(StoreLike
) –Store or path to directory in file system or name of zip file.
-
*args
(ndarray
, default:()
) –NumPy arrays with data to save.
-
zarr_format
((2, 3, None)
, default:2
) –The zarr format to use when saving.
-
path
(str or None
, default:None
) –The path within the group where the arrays will be saved.
-
**kwargs
(Any
, default:{}
) –NumPy arrays with data to save.
Source code in zarr/api/synchronous.py
save_array ¶
save_array(
store: StoreLike,
arr: NDArrayLike,
*,
zarr_version: ZarrFormat | None = None,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> None
Save a NumPy array to the local file system.
Follows a similar API to the NumPy save() function.
Parameters:
-
store
(StoreLike
) –Store or path to directory in file system or name of zip file.
-
arr
(ndarray
) –NumPy array with data to save.
-
zarr_format
((2, 3, None)
, default:2
) –The zarr format to use when saving. The default is
None
, which will use the default Zarr format defined in the global configuration object. -
path
(str or None
, default:None
) –The path within the store where the array will be saved.
-
storage_options
(dict
, default:None
) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs
(Any
, default:{}
) –Passed through to
create
, e.g., compressor.
Source code in zarr/api/synchronous.py
save_group ¶
save_group(
store: StoreLike,
*args: NDArrayLike,
zarr_version: ZarrFormat | None = None,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: NDArrayLike,
) -> None
Save several NumPy arrays to the local file system.
Follows a similar API to the NumPy savez()/savez_compressed() functions.
Parameters:
-
store
(StoreLike
) –Store or path to directory in file system or name of zip file.
-
*args
(ndarray
, default:()
) –NumPy arrays with data to save.
-
zarr_format
((2, 3, None)
, default:2
) –The zarr format to use when saving.
-
path
(str or None
, default:None
) –Path within the store where the group will be saved.
-
storage_options
(dict
, default:None
) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs
(NDArrayLike
, default:{}
) –NumPy arrays with data to save.
Source code in zarr/api/synchronous.py
tree ¶
Provide a rich display of the hierarchy.
Deprecated
zarr.tree()
is deprecated since v3.0.0 and will be removed in a future release.
Use group.tree()
instead.
Parameters:
-
grp
(Group
) –Zarr or h5py group.
-
expand
(bool
, default:None
) –Only relevant for HTML representation. If True, tree will be fully expanded.
-
level
(int
, default:None
) –Maximum depth to descend into hierarchy.
Returns:
-
TreeRepr
–A pretty-printable object displaying the hierarchy.