| Title: | Slice into 'Zarr' Arrays |
|---|---|
| Description: | An implementation of chunked, compressed, N-dimensional arrays for R. Reads and writes 'Zarr' spec V2 (2024) <doi:10.5281/zenodo.11320255> and V3 <https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html>. |
| Authors: | David Blodgett [cre, aut] (ORCID: <https://orcid.org/0000-0001-9489-1710>), Mark Keller [aut] (ORCID: <https://orcid.org/0000-0003-3003-874X>), Artür Manukyan [aut] (ORCID: <https://orcid.org/0000-0002-0441-9517>), zarr-developers [cph] |
| Maintainer: | David Blodgett <dblodgett@usgs.gov> |
| License: | MIT + file LICENSE |
| Version: | 0.2.2 |
| Built: | 2026-09-24 19:34:33 UTC |
| Source: | https://github.com/zarr-developers/pizzarr |
jsonlite::unbox function to "tag" the value as a scalar.Convert a value to a scalar to opt-out of R default vector casting behavior.
This uses the jsonlite::unbox function to "tag" the value as a scalar.
as_scalar(obj)as_scalar(obj)
obj |
The value to convert. |
The value wrapped as a scalar.
Class providing access to user attributes on an array or group.
The Zarr Attributes class.
storeAttributes store, already initialized.
keyThe key under which the attributes will be stored.
read_onlyIf True, attributes cannot be modified.
cacheIf True (default), attributes will be cached locally.
synchronizerOnly necessary if attributes may be modified from multiple threads or processes.
Attributes$new()Create a new Attributes instance.
Attributes$new( store, key = NA, read_only = FALSE, cache = TRUE, synchronizer = NA, zarr_format = NULL )
store(Store)
Attributes store, already initialized.
key(character(1))
Key to use for attributes (.zattrs is default).
read_only(logical(1))
Whether the attributes are read-only.
cache(logical(1))
Whether to cache attributes.
synchronizer(ANY or NA)
Synchronizer object.
zarr_format(integer(1) or NULL)
Zarr format version: 2L for V2 (.zattrs), 3L for V3 (zarr.json).
An Attributes instance.
Attributes$to_list()convert attributes to list
Attributes$to_list()
list().
Attributes$refresh()refresh attributes
Attributes$refresh()
NULL (called for side effects).
Attributes$contains()check if object contains item
Attributes$contains(x)
xObject to test.
logical(1).
Attributes$get_item()get attribute
Attributes$get_item(item)
itemCharacter attribute name.
The attribute value.
Attributes$set_item()set attribute
Attributes$set_item(item, value)
itemCharacter attribute name.
valueValue to add or update.
NULL (called for side effects).
Attributes$del_item()delete attribute
Attributes$del_item(item)
itemCharacter attribute name.
NULL (called for side effects).
Attributes$set_cached_v3_attrs()Set cached attributes from V3 embedded metadata. In V3, attributes are part of zarr.json rather than a separate .zattrs file. This method pre-populates the cache so the normal .zattrs read path is skipped.
Attributes$set_cached_v3_attrs(attrs_list)
attrs_listA named list of attributes from V3 zarr.json.
NULL (modifies cache in place).
Attributes$clone()The objects of this class are cloneable with this method.
Attributes$clone(deep = FALSE)
deepWhether to make a deep clone.
Class representing a Blosc compressor
R6::R6Class inheriting from Codec.
Blosc compressor for Zarr
Codec -> BloscCodec
cname(character(1))
The compression algorithm to use.
clevel(integer(1))
The compression level.
shuffle(logical(1) | integer(1))
The shuffle filter to use.
blocksize(integer(1) | NA)
The block size.
BloscCodec$new()Create a new Blosc compressor.
BloscCodec$new(cname = "lz4", clevel = 5, shuffle = TRUE, blocksize = NA, ...)
cname(character(1))
The compression algorithm to use.
clevel(integer(1))
The compression level.
shuffle(logical(1) | integer(1))
The shuffle filter to use.
blocksize(integer(1) | NA)
The block size.
...Not used.
A new BloscCodec object.
BloscCodec$encode()Compress data.
BloscCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
BloscCodec$decode()Decompress data.
BloscCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
BloscCodec$get_config()Get codec configuration as a list.
BloscCodec$get_config()
A named list.
BloscCodec$clone()The objects of this class are cloneable with this method.
BloscCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Class representing a bz2 compressor
R6::R6Class inheriting from Codec.
Bz2 compressor for Zarr
Codec -> Bz2Codec
levelThe compression level.
Bz2Codec$new()Create a new Bz2 compressor.
Bz2Codec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new Bz2Codec object.
Bz2Codec$encode()Compress data.
Bz2Codec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
Bz2Codec$decode()Decompress data.
Bz2Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
Bz2Codec$get_config()Get codec configuration as a list.
Bz2Codec$get_config()
A named list.
Bz2Codec$clone()The objects of this class are cloneable with this method.
Bz2Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Abstract class representing a compressor.
Abstract compressor for Zarr
Codec$encode()Compress data.
Codec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
Codec$decode()Decompress data.
Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
Codec$get_config()Get codec configuration as a list.
Codec$get_config()
A named list.
Codec$clone()The objects of this class are cloneable with this method.
Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
A data type object (an instance of Dtype class) describes how the bytes in the fixed-size block of memory corresponding to an array item should be interpreted.
The Zarr Dtype class.
dtypeThe original dtype string, like "<f4".
byte_orderThe byte order of the dtype, either "little", "big", or "nr".
basic_typeThe basic type of the dtype, like "f".
num_bytesThe number of bytes of the dtype.
num_itemsThe number of items of the dtype.
is_signedWhether the dtype is signed. Logical/boolean.
is_structuredWhether the dtype is structured. Logical/boolean.
is_objectWhether the dtype is an object. Logical/boolean.
object_codecThe object codec instance.
Dtype$new()Create a new Dtype instance.
Dtype$new(dtype, object_codec = NA)
dtypeThe original dtype string, like "<f4".
object_codecThe object codec instance.
A Dtype instance.
Dtype$get_asrtype()Get the R coercion function name for this dtype.
Dtype$get_asrtype()
Character string (e.g., "as.double").
Dtype$get_rtype()Get the R base type for this dtype.
Dtype$get_rtype()
An R prototype value (e.g., integer(), double(), or bit64::integer64()).
Dtype$get_typed_array_ctr()Get a constructor function for typed arrays of this dtype.
Dtype$get_typed_array_ctr()
A function that takes dim and returns an array.
Dtype$clone()The objects of this class are cloneable with this method.
Dtype$clone(deep = FALSE)
deepWhether to make a deep clone.
https://numpy.org/doc/stable/reference/arrays.dtypes.html
Class representing a gzip compressor.
Gzip encoding uses temporary files because R's memCompress() produces
zlib framing rather than gzip framing. This makes GzipCodec slower than
ZstdCodec for writes. Prefer ZstdCodec when performance matters.
R6::R6Class inheriting from Codec.
Gzip compressor for Zarr
Codec -> GzipCodec
levelThe compression level.
GzipCodec$new()Create a new Gzip compressor.
GzipCodec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new GzipCodec object.
GzipCodec$encode()Compress data.
GzipCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
GzipCodec$decode()Decompress data.
GzipCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
GzipCodec$get_config()Get codec configuration as a list.
GzipCodec$get_config()
A named list.
GzipCodec$clone()The objects of this class are cloneable with this method.
GzipCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Store class that uses HTTP requests.
Read-only. Depends on the crul package.
R6::R6Class inheriting from Store.
This is also the way to read an S3-compatible bucket over plain HTTPS.
Most public object stores — MinIO, Ceph, Open Storage Network pods,
Cloudflare R2, and Google Cloud Storage — expose their objects at a URL,
so an s3://bucket/key address with endpoint https://host becomes:
https://host/bucket/key
Unlike S3Store and GcsStore, HttpStore works on both distribution
tiers: it falls back to the R-native crul code path when the zarrs
backend is not compiled in, and uses parallel chunk decode when it is.
It needs no credentials and no environment configuration.
When the store publishes consolidated metadata (a .zmetadata key),
listdir() reports its members; without it, HTTP stores cannot be listed
and you must address arrays by name.
Store -> HttpStore
HttpStore$new()Create a HttpStore object
HttpStore$new(url, options = NA, headers = NA)
url(character(1))
URL of the store.
options(list() or NA)
Options passed to crul.
headers(list() or NA)
Headers passed to crul.
A new HttpStore object.
HttpStore$get_item()Get an item from the store.
HttpStore$get_item(item)
itemThe item key.
The item data in a vector of type raw.
HttpStore$contains_item()Determine whether the store contains an item.
HttpStore$contains_item(item)
itemThe item key.
A boolean value.
HttpStore$listdir()Fetches .zmetadata from the store evaluates its names
HttpStore$listdir(path = NA)
pathcharacter path to list within, or NA for the store root.
Character vector of unique keys that do not start with a ..
HttpStore$get_cache_time_seconds()Get cache time of http requests.
HttpStore$get_cache_time_seconds()
numeric(1).
HttpStore$set_cache_time_seconds()Set cache time of http requests.
HttpStore$set_cache_time_seconds(seconds)
secondsNumber of seconds until cache is invalid – 0 for no cache.
NULL (called for side effects).
HttpStore$get_store_identifier()Print a human-readable summary of the store.
Return the store URL for zarrs dispatch.
HttpStore$get_store_identifier()
A character string.
HttpStore$print()HttpStore$print(...)
...Ignored.
self (invisibly).
HttpStore$clone()The objects of this class are cloneable with this method.
HttpStore$clone(deep = FALSE)
deepWhether to make a deep clone.
S3Store for s3:// URLs via the zarrs backend.
vignette("remote-stores") for worked examples.
Other Store classes:
DirectoryStore,
GcsStore,
MemoryStore,
S3Store,
Store
## Not run: # USGS gridMET on an Open Storage Network pod, addressed over HTTPS. store <- HttpStore$new("https://usgs.osn.mghpcc.org/mdmf/gdp/gridMET.zarr") g <- zarr_open(store) store$listdir() ## End(Not run)## Not run: # USGS gridMET on an Open Storage Network pod, addressed over HTTPS. store <- HttpStore$new("https://usgs.osn.mghpcc.org/mdmf/gdp/gridMET.zarr") g <- zarr_open(store) store$listdir() ## End(Not run)
Convenience function for the internal Int class constructor.
int(index, zero_based = FALSE)int(index, zero_based = FALSE)
index |
The integer index. |
zero_based |
The index of the dimension. By default, FALSE for R-like behavior. |
A Int instance with the specified parameters.
Check if an error is a KeyError.
is_key_error(e)is_key_error(e)
e |
The error to check. |
TRUE if the error is a KeyError, FALSE otherwise.
Check if a value is a scalar (i.e., a one-element vector that was converted with as_scalar).
is_scalar(s)is_scalar(s)
s |
The value to check. |
TRUE if the value is a scalar, FALSE otherwise.
Check if a value is a Slice instance.
is_slice(s)is_slice(s)
s |
The value to check. |
TRUE if the value is a Slice instance, FALSE otherwise.
Class representing a lzma compressor
R6::R6Class inheriting from Codec.
Lzma compressor for Zarr
Codec -> LzmaCodec
levelThe compression level.
formatThe compression format.
LzmaCodec$new()Create a new lzma compressor.
LzmaCodec$new(level = 9, format = 1, ...)
levelThe compression level, between 1 and 22.
format(integer(1))
Only 1 is supported.
...Not used.
A new LzmaCodec object.
LzmaCodec$encode()Compress data.
LzmaCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
LzmaCodec$decode()Decompress data.
LzmaCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
LzmaCodec$get_config()Get codec configuration as a list.
LzmaCodec$get_config()
A named list.
LzmaCodec$clone()The objects of this class are cloneable with this method.
LzmaCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Represents a multi-dimensional array that can be accessed and subsetted via list of Slice instances.
The Zarr NestedArray class.
shapeThe shape of the array.
dtypeThe Zarr dtype of the array, as a string like ">f8".
dtype_objThe Zarr dtype of the array, as a Dtype instance.
dataThe array contents as a base R array.
NestedArray$new()Create a new NestedArray instance.
NestedArray$new(data, shape = NA, dtype = NA, order = NA)
dataThe data to initialize the array with. Either NULL, base R array, base R vector (numeric/logical), scalar, or raw vector.
shapeThe shape of the array.
dtypeThe Zarr dtype of the array, as a string like ">f8".
orderThe order of the array, either "C" or "F". Only used
when data is a raw vector. Optional.
A NestedArray instance.
NestedArray$get()Subset the array.
NestedArray$get(selection)
selectionA list of slices.
A new NestedArray (potentially a subset) representing the selection.
NestedArray$set()Set a subset of the array.
NestedArray$set(selection, value)
selectionA list of slices.
valueA NestedArray or a base R array.
NULL (called for side effects, modifies self$data in place).
NestedArray$flatten()Flatten the array contents.
NestedArray$flatten(order = NA)
orderEither "C", "F", or NA.
The data as a flat vector.
NestedArray$flatten_to_raw()Flatten the array contents and convert to a raw vector.
NestedArray$flatten_to_raw(order = NA)
orderEither "C", "F", or NA.
The data as a flat raw() vector (or plain vector for object dtypes).
NestedArray$as.array()Convert NestedArray to a base R array.
NestedArray$as.array()
array().
NestedArray$clone()The objects of this class are cloneable with this method.
NestedArray$clone(deep = FALSE)
deepWhether to make a deep clone.
Returns the feature flags compiled into the zarrs backend, or
character(0) with a message when the backend is absent.
pizzarr_compiled_features()pizzarr_compiled_features()
Character vector of feature names (e.g. "filesystem",
"gzip").
Controls parallelism and HTTP behaviour for the zarrs backend. Called with no arguments, returns the current settings as a named list. Called with arguments, sets the specified options and applies them to the Rust backend immediately.
pizzarr_config( nthreads = NULL, concurrent_target = NULL, http_batch_range_requests = NULL )pizzarr_config( nthreads = NULL, concurrent_target = NULL, http_batch_range_requests = NULL )
nthreads |
Integer or NULL. Number of threads for the rayon thread
pool. NULL uses all CPUs (the default). The pool can only be initialised
once per R session; later changes require a restart. Use the
|
concurrent_target |
Integer or NULL. Codec concurrency level — how many codec operations zarrs runs in parallel within a single read/write call. NULL uses the zarrs default (CPU count). Can be changed at any time. |
http_batch_range_requests |
Logical or NULL. Whether HTTP stores use
multipart range requests (default TRUE). Set to FALSE for servers with
incomplete multipart range support. Takes effect on the next
|
When called with no arguments, a named list of current settings. When called with arguments, the previous values (invisibly).
pizzarr.http_store_cache_time_seconds how long to cache web requests
pizzarr.nthreads number of threads for parallel codec operations (NULL = all CPUs). Set-once: takes effect only before the first zarrs operation. Use env var PIZZARR_NTHREADS for reliable session-level control.
pizzarr.concurrent_target codec concurrency level — how many codec operations zarrs runs in parallel within a single read/write call (NULL = zarrs default, typically CPU count). Can be changed at any time.
pizzarr.http_batch_range_requests whether HTTP stores use multipart range requests (TRUE by default). Set to FALSE for servers with incomplete multipart range support. Takes effect on next store open.
pizzarr_option_defaultspizzarr_option_defaults
pizzarr demo data
pizzarr_sample( dataset = NULL, outdir = file.path(tools::R_user_dir("pizzarr"), "pizzarr_sample") )pizzarr_sample( dataset = NULL, outdir = file.path(tools::R_user_dir("pizzarr"), "pizzarr_sample") )
dataset |
character defining which demo dataset is desired, If NULL, all are returned |
outdir |
character directory path to store sample zarr stores |
For directory stores, unzips the store to a temporary directory and returns the resulting path.
path to ready to use zarr store
sample_dir <- tools::R_user_dir("pizzarr") clean <- !dir.exists(sample_dir) zarr_samples <- pizzarr_sample(outdir = sample_dir) #printing without system path for example gsub(sample_dir, "...", zarr_samples, fixed = TRUE) # clean up if you don't want to keep them for next time if(clean) unlink(sample_dir, recursive = TRUE)sample_dir <- tools::R_user_dir("pizzarr") clean <- !dir.exists(sample_dir) zarr_samples <- pizzarr_sample(outdir = sample_dir) #printing without system path for example gsub(sample_dir, "...", zarr_samples, fixed = TRUE) # clean up if you don't want to keep them for next time if(clean) unlink(sample_dir, recursive = TRUE)
Prints the command to install pizzarr from r-universe with the compiled zarrs backend, or reports that zarrs is already available.
pizzarr_upgrade()pizzarr_upgrade()
Convenience function for the internal Slice R6 class constructor.
slice(start, stop = NA, step = NA, zero_based = FALSE)slice(start, stop = NA, step = NA, zero_based = FALSE)
start |
The start index. |
stop |
The stop index. |
step |
The step size. Negative values reverse the direction of the
slice, matching Python/NumPy semantics (e.g., |
zero_based |
The index of the dimension. By default, FALSE for R-like behavior. |
A Slice instance with the specified parameters.
g <- zarr_volcano() v <- g$get_item("volcano") # Reverse the first 5 columns of row 1 (zero-based: 5:0:-1) v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(5, 0, -1))) # Full reverse of row 1 (zero-based: -1::-1) v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(-1, NA, -1)))g <- zarr_volcano() v <- g$get_item("volcano") # Reverse the first 5 columns of row 1 (zero-based: 5:0:-1) v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(5, 0, -1))) # Full reverse of row 1 (zero-based: -1::-1) v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(-1, NA, -1)))
Class representing a VLenUtf8 compressor
R6::R6Class inheriting from Codec.
Variable-length UTF-8 codec for Zarr
Codec -> VLenUtf8Codec
VLenUtf8Codec$encode()Compress data.
VLenUtf8Codec$encode(buf, zarr_arr)
buf(character())
The un-compressed data (character vector).
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
VLenUtf8Codec$decode()Decompress data.
VLenUtf8Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
VLenUtf8Codec$get_config()Get codec configuration as a list.
VLenUtf8Codec$get_config()
A named list.
VLenUtf8Codec$clone()The objects of this class are cloneable with this method.
VLenUtf8Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
ZlibCodec,
ZstdCodec
Create an empty array
zarr_create( shape, chunks = TRUE, dtype = NA, compressor = NA, fill_value = NA, order = NA, store = NA, synchronizer = NA, overwrite = FALSE, path = NA, chunk_store = NA, filters = NA, cache_metadata = TRUE, cache_attrs = TRUE, read_only = FALSE, object_codec = NA, dimension_separator = NA, write_empty_chunks = TRUE, zarr_format = 2L, dimension_names = NULL )zarr_create( shape, chunks = TRUE, dtype = NA, compressor = NA, fill_value = NA, order = NA, store = NA, synchronizer = NA, overwrite = FALSE, path = NA, chunk_store = NA, filters = NA, cache_metadata = TRUE, cache_attrs = TRUE, read_only = FALSE, object_codec = NA, dimension_separator = NA, write_empty_chunks = TRUE, zarr_format = 2L, dimension_names = NULL )
shape |
: int or tuple of ints Array shape. |
chunks |
: int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
store |
: Store A mapping that supports string keys and bytes-like values. |
synchronizer |
: object, optional Array synchronizer. |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
cache_metadata |
: bool, optional If True, array configuration metadata will be cached for the lifetime of the object. If False, array metadata will be reloaded prior to all data access and modification operations (may incur overhead depending on storage and data access pattern). |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
read_only |
: bool, optional True if array should be protected against modification. |
object_codec |
: Codec, optional A codec to encode object arrays, only needed if dtype=object. |
dimension_separator |
: |
write_empty_chunks |
: bool, optional If True (default), all chunks will be stored regardless of their contents. If False, each chunk is compared to the array's fill value prior to storing. If a chunk is uniformly equal to the fill value, then that chunk is not be stored, and the store entry for that chunk's key is deleted. This setting enables sparser storage, as only chunks with non-fill-value data are stored, at the expense of overhead associated with checking the data of each chunk. |
zarr_format |
: int, optional
Zarr format version. Use |
dimension_names |
: character vector, optional
Named dimensions for V3 arrays. Length must equal |
ZarrArray
Create an array initialized with data.
zarr_create_array(data, ...)zarr_create_array(data, ...)
data |
A base R array() or pizzarr NestedArray instance. |
... |
The params of zarr_create() |
ZarrArray
Create an array filled with NAs.
zarr_create_empty(shape, ...)zarr_create_empty(shape, ...)
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
ZarrArray
Create a group.
zarr_create_group( store = NA, overwrite = FALSE, chunk_store = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, zarr_format = 2L )zarr_create_group( store = NA, overwrite = FALSE, chunk_store = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, zarr_format = 2L )
store |
: Store A mapping that supports string keys and bytes-like values. |
overwrite |
: bool, optional
If True, erase all data in |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
synchronizer |
: object, optional Array synchronizer. |
path |
: string, bytes, optional Path under which array is stored. |
zarr_format |
: int, optional
Zarr format version. Use |
ZarrGroup
Create an array filled with zeros.
zarr_create_zeros(shape, ...)zarr_create_zeros(shape, ...)
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
ZarrArray
Convenience function to open a group or array using file-mode-like semantics.
zarr_open(store = NA, mode = NA, path = NA, ...)zarr_open(store = NA, mode = NA, path = NA, ...)
store |
A Store object, or a character string that is coerced to one:
an |
mode |
: |
path |
: string, bytes, optional Path under which array is stored. |
... |
Additional arguments to pass to zarr_open_array or zarr_open_group. |
ZarrArray or ZarrGroup
Open an array using file-mode-like semantics.
zarr_open_array( store = NA, storage_options = NA, mode = NA, shape = NA, chunks = TRUE, dtype = NA, compressor = NA, fill_value = NA, order = NA, synchronizer = NA, overwrite = FALSE, path = NA, chunk_store = NA, filters = NA, cache_metadata = TRUE, cache_attrs = TRUE, object_codec = NA, dimension_separator = NA, write_empty_chunks = TRUE, zarr_format = 2L )zarr_open_array( store = NA, storage_options = NA, mode = NA, shape = NA, chunks = TRUE, dtype = NA, compressor = NA, fill_value = NA, order = NA, synchronizer = NA, overwrite = FALSE, path = NA, chunk_store = NA, filters = NA, cache_metadata = TRUE, cache_attrs = TRUE, object_codec = NA, dimension_separator = NA, write_empty_chunks = TRUE, zarr_format = 2L )
store |
: Store A mapping that supports string keys and bytes-like values. |
storage_options |
Accepted for compatibility with the zarr-python
signature but currently ignored. pizzarr configures remote stores
with environment variables rather than a per-call options list; see
S3Store and |
mode |
: |
shape |
: int or tuple of ints Array shape. |
chunks |
: bool, int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
synchronizer |
: object, optional Array synchronizer. |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
cache_metadata |
: bool, optional If True, array configuration metadata will be cached for the lifetime of the object. If False, array metadata will be reloaded prior to all data access and modification operations (may incur overhead depending on storage and data access pattern). |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
object_codec |
: Codec, optional A codec to encode object arrays, only needed if dtype=object. |
dimension_separator |
: |
write_empty_chunks |
: bool, optional If True (default), all chunks will be stored regardless of their contents. If False, each chunk is compared to the array's fill value prior to storing. If a chunk is uniformly equal to the fill value, then that chunk is not be stored, and the store entry for that chunk's key is deleted. This setting enables sparser storage, as only chunks with non-fill-value data are stored, at the expense of overhead associated with checking the data of each chunk. |
zarr_format |
: int, optional
Zarr format version. Use |
ZarrArray
Open a group using file-mode-like semantics.
zarr_open_group( store = NA, mode = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, chunk_store = NA, storage_options = NA, zarr_format = 2L )zarr_open_group( store = NA, mode = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, chunk_store = NA, storage_options = NA, zarr_format = 2L )
store |
A Store object, or a character string that is coerced to one:
an |
mode |
: |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
synchronizer |
: object, optional Array synchronizer. |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
storage_options |
Accepted for compatibility with the zarr-python
signature but currently ignored. pizzarr configures remote stores
with environment variables rather than a per-call options list; see
S3Store and |
zarr_format |
: int, optional
Zarr format version. Use |
ZarrGroup
Convenience function to save a ZarrArray to the local file system.
zarr_save_array(store, arr, ...)zarr_save_array(store, arr, ...)
store |
: Store A mapping that supports string keys and bytes-like values. |
arr |
: ZarrArray The array with data to save. |
... |
Additional arguments to pass to zarr_create_array(). |
Writes the volcano matrix into a temporary
DirectoryStore as a Zarr array named "volcano" and returns the
opened group.
zarr_volcano()zarr_volcano()
A ZarrGroup containing a single array called "volcano".
g <- zarr_volcano() v <- g$get_item("volcano") image(v$get_item("...")$data, main = "Maunga Whau Volcano")g <- zarr_volcano() v <- g$get_item("volcano") image(v$get_item("...")$data, main = "Maunga Whau Volcano")
Returns TRUE if the store was in the cache and was removed,
FALSE if it was not cached.
zarrs_close_store(store_url)zarrs_close_store(store_url)
store_url |
Filesystem path or URL of the store to close. |
Called once at .onLoad to populate .pizzarr_env$zarrs_available.
The feature list is determined at compile time via cfg! checks.
Also installs a no-op panic hook on first call.
zarrs_compiled_features()zarrs_compiled_features()
Returns the same metadata list as zarrs_open_array_metadata.
zarrs_create_array( store_url, array_path, shape, chunks, dtype, codec_preset, fill_value, attributes_json, zarr_format )zarrs_create_array( store_url, array_path, shape, chunks, dtype, codec_preset, fill_value, attributes_json, zarr_format )
store_url |
Filesystem path to the store root. |
array_path |
Path to the array within the store. |
shape |
Integer vector of array dimensions. |
chunks |
Integer vector of chunk dimensions. |
dtype |
V3-style data type name (e.g., "float64", "int32"). |
codec_preset |
Compression preset: "none", "gzip", "blosc", or "zstd". |
fill_value |
Scalar fill value (numeric, integer, logical, or NA). |
attributes_json |
JSON string of array attributes. |
zarr_format |
Integer: 2 for V2, 3 for V3. |
Open (or reuse) the store at store_url and fetch key verbatim.
Returns a raw vector, or NULL when the key is absent. This is the
key-level read that cloud stores otherwise lack: S3Store and
GcsStore delegate all I/O to object_store, so consolidated
metadata (.zmetadata) is unreachable from R without it.
zarrs_get_key(store_url, key)zarrs_get_key(store_url, key)
store_url |
Filesystem path or URL to the store root. |
key |
Key within the store (e.g. |
Bytes are returned unparsed. Callers decode as needed — metadata keys are UTF-8 JSON, chunk keys are compressed binary.
store_url - Filesystem path or URL to the store root.
key - Key within the store (e.g. ".zmetadata" or "lat/.zattrs").
Returns an R error if key is not a valid store key, if the store
cannot be opened, or if a storage I/O error occurs.
Returns a named list with data (numeric, integer, or logical vector)
and shape (integer vector). Ranges are 0-based, exclusive stop.
zarrs_get_subset(store_url, array_path, ranges, concurrent_target)zarrs_get_subset(store_url, array_path, ranges, concurrent_target)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
ranges |
R list of length-2 integer vectors |
concurrent_target |
Optional codec concurrency override. |
Open (or reuse) the store at store_url, then probe for V3 and V2
metadata keys at path.
zarrs_node_exists(store_url, path)zarrs_node_exists(store_url, path)
store_url |
Filesystem path or URL to the store root. |
path |
Path within the store (e.g. |
store_url - Filesystem path or URL to the store root.
path - Path within the store (e.g. "group1/array1" or "" for root).
Returns an R error if the store cannot be opened or a storage I/O error occurs while probing keys.
Returns a named list with shape, chunks, dtype, r_type,
fill_value_json, zarr_format, and order.
zarrs_open_array_metadata(store_url, array_path)zarrs_open_array_metadata(store_url, array_path)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
Returns a named list with codec_concurrent_target,
store_cache_entries, and compiled_features.
zarrs_runtime_info()zarrs_runtime_info()
Controls the number of concurrent codec operations zarrs uses within a single array operation.
zarrs_set_codec_concurrent_target(n)zarrs_set_codec_concurrent_target(n)
n |
Positive integer. |
Controls multipart range request behaviour for HTTP stores created after this call. Existing cached stores are not affected.
zarrs_set_http_batch_range_requests(enable)zarrs_set_http_batch_range_requests(enable)
enable |
Logical scalar. |
Initialises the rayon global thread pool with n threads. The pool
can only be initialised once per process; returns TRUE on success,
FALSE if the pool was already initialised.
zarrs_set_nthreads(n)zarrs_set_nthreads(n)
n |
Positive integer. |
Returns true on success. Ranges are 0-based, exclusive stop.
Data must be a flat vector in C-order (row-major).
zarrs_set_subset(store_url, array_path, ranges, data, concurrent_target)zarrs_set_subset(store_url, array_path, ranges, data, concurrent_target)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
ranges |
R list of length-2 integer vectors |
data |
R vector (numeric, integer, or logical). |
concurrent_target |
Optional codec concurrency override. |
Convenience function for the internal Int class constructor with zero-based indexing
zb_int(index)zb_int(index)
index |
integer index |
Convenience function for the internal Slice R6 class constructor with zero-based indexing and exclusive stop index.
zb_slice(start, stop = NA, step = NA)zb_slice(start, stop = NA, step = NA)
start |
The start index. |
stop |
The stop index. |
step |
The step size. Negative values reverse the direction of the
slice, matching Python/NumPy semantics (e.g., |
A Slice instance with the specified parameters.
# Equivalent to Python's arr[5:0:-1] zb_slice(5, 0, -1) # Equivalent to Python's arr[-1::-1] (full reverse) zb_slice(-1, NA, -1)# Equivalent to Python's arr[5:0:-1] zb_slice(5, 0, -1) # Equivalent to Python's arr[-1::-1] (full reverse) zb_slice(-1, NA, -1)
Class representing a zlib compressor
R6::R6Class inheriting from Codec.
Zlib compressor for Zarr
Codec -> ZlibCodec
levelThe compression level.
ZlibCodec$new()Create a new Zlib compressor.
ZlibCodec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new ZlibCodec object.
ZlibCodec$encode()Compress data.
ZlibCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
ZlibCodec$decode()Decompress data.
ZlibCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
ZlibCodec$get_config()Get codec configuration as a list.
ZlibCodec$get_config()
A named list.
ZlibCodec$clone()The objects of this class are cloneable with this method.
ZlibCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZstdCodec