API reference
Arrays
Zarr.zcreate Function
zcreate(T, dims...;kwargs)Creates a new empty zarr array with element type T and array dimensions dims. The following keyword arguments are accepted:
path=""directory name to store a persistent array. If left empty, an in-memory array will be createdname=""name of the zarr array, defaults to the directory namezarr_format=Zarr.ZarrFormat{2}(Val{2}()) Zarr format version (2 or 3)storagetypedetermines the storage to use, current options areDirectoryStoreorDictStorechunks=dimssize of the individual array chunks, must be a tuple of lengthlength(dims)fill_value=nothingvalue to represent missing valuesfill_as_missing=falseset totrueshall fillvalue s be converted tomissingsfilters=filters to be appliedcompressor=BloscCompressor()compressor type and propertiesattrs=Dict()a dict containing key-value pairs with metadata attributes associated to the arraywriteable=truedetermines if the array is opened in read-only or write modeindent_json=falsedetermines if indents are added to format the json files.zarrayand.zattrs. This makes them more readable, but increases file size.dimension_separator='.'sets how chunks are encoded. The Zarr v2 default is '.' such that the first 3D chunk would be0.0.0. The Zarr v3 default is/.
Create a new subarray of the group g
sourceZarr.zzeros Function
zzeros(T, dims...; kwargs... )Creates a zarr array and initializes all values with zero. Accepts the same keyword arguments as zcreate
Group hierarchy
Zarr.zgroup Function
zgroup(s::AbstractStore; attrs=Dict())Create a new zgroup in the store s
Zarr.zopen Function
zopen(s::AbstractStore, mode="r"; consolidated = false, path = "", lru = 0)Opens a zarr Array or Group at Store s. If consolidated is set to "true", Zarr will search for a consolidated metadata field as created by the python zarr consolidate_metadata function. This can substantially speed up metadata parsing of large zarr groups. Setting lru to a value > 0 means that chunks that have been accessed before will be cached and consecutive reads will happen from the cache. Here, lru denotes the number of chunks that remain in memory. The expected zarr version can be supplied through zarr_format and defaults to :auto which tries to detect if the zarr version is v2 or v3.
Zarr.zopen_noerr Method
zopen_noerr(AbstractStore, mode = "r"; consolidated = false)Works like zopen with the single difference that no error is thrown when the path or store does not point to a valid zarr array or group, but nothing is returned instead.
Compressors
Zarr.Compressor Type
abstract type CompressorThe abstract supertype for all Zarr compressors.
Interface
All subtypes of Compressor SHALL implement the following methods:
zcompress(a, c::Compressor): compress the arrayausing the compressorc.zuncompress(a, c::Compressor, T): uncompress the arrayausing the compressorcand return an array of typeT.JSON.lower(c::Compressor): return a JSON representation of the compressorc, which follows the Zarr specification for that compressor.getCompressor(::Type{<:Compressor}, d::Dict): return a compressor object from a given dictionarydwhich contains the compressor's parameters according to the Zarr spec.
Subtypes of Compressor MAY also implement the following methods:
zcompress!(compressed, data, c::Compressor): compress the arraydatausing the compressorcand store the result in the arraycompressed.zuncompress!(data, compressed, c::Compressor): uncompress the arraycompressedusing the compressorcand store the result in the arraydata.
Finally, an entry MUST be added to the compressortypes dictionary for each compressor type. This must also follow the Zarr specification's name for that compressor. The name of the compressor is the key, and the value is the compressor type (e.g. BloscCompressor or NoCompressor).
For example, the Blosc compressor is named "blosc" in the Zarr spec, so the entry for BloscCompressor must be added to compressortypes as compressortypes["blosc"] = BloscCompressor.
Zarr.NoCompressor Type
NoCompressor()Creates an object that can be passed to ZArray constructors without compression.
sourceZarr.BloscCompressor Method
BloscCompressor(;blocksize=0, clevel=5, cname="lz4", shuffle=1)Returns a BloscCompressor struct that can serve as a Zarr array compressor. Keyword arguments are:
clevel=5the compression level, number between 0 (no compression) and 9 (max compression)cname="lz4"compressor name, can be one of"blosclz","lz4", and"lz4hc"shuffle=1Either NOSHUFFLE (0), SHUFFLE (1), BITSHUFFLE (2) or AUTOSHUFFLE (-1). If AUTOSHUFFLE, bit-shuffle will be used for buffers with itemsize 1, and byte-shuffle will be used otherwise. The default is SHUFFLE.
Zarr.ZlibCompressor Type
ZlibCompressor(clevel=-1)Returns a ZlibCompressor struct that can serve as a Zarr array compressor. Keyword arguments are:
clevel=-1the compression level, number between -1 (Default), 0 (no compression) and 9 (max compression)default is -1 compromise between speed and compression (currently equivalent to level 6).
Zarr.ZstdCompressor Type
ZstdCompressor(;level=0, checksum=false)Returns a ZstdCompressor struct that can serve as a Zarr array compressor. Keyword arguments are:
level=0: the compression level, regular levels are 1 to 22, 0 is a special value for default, there are also even faster negative levels.checksum=false: flag to enable saving checksums.