Dimensionality¶
How a store declares its number of spatial dimensions, D, where D
appears on disk, and what the validator checks.
Terms¶
- Dimensionality (
D) The number of axes vertices are positioned and chunked in: the length of
zarr_vectors.axesin the root attributes (RootMetadata.sid_ndimin Python).Dis fixed for the store and shared by every level.- Axis
One entry of the root
zarr_vectors.axes: aname, atype(such as"space"or"time") and an optionalunit.
Introduction¶
Every spatial rule is written for D axes. Most stores are 3-D; 2-D
stores and stores with a time axis use the same layout and code.
Technical reference¶
Declaring D¶
create_store takes D from ndim, or from the length of axes,
bounds or chunk_shape; the default is 3. The type writers take it
from chunk_shape and the positions. Inputs that disagree raise
MetadataError, for example
Inconsistent dimensionality: ndim=3, chunk_shape=2.
Without axes, the axes are named x, y, z, w in order, each
with "type": "space" and no unit; for D > 4, axes is required
(MetadataError otherwise). Axis order is the column order of the
positions and the order of every per-axis list.
The type writers have no axes argument. Set names and units with
create_store(axes=...), as below, or with
zv.Schema(axes=(zv.Axis("x", "micrometer"), ...)).
Where D appears¶
D is not stored as its own key. It is implied by:
Item |
Size |
|---|---|
|
|
|
|
|
|
Per-chunk arrays ( |
rank |
Positions in a |
rows of |
|
|
Dense object-index |
|
Chunk and cell addressing¶
A vertex at position p is in spatial chunk
chunk[i] = floor(p[i] / chunk_shape[i]) for i in 0 .. D-1
stored in cell chunk - origin. The origin,
floor(bounds_min / chunk_shape), is the array’s chunk_grid_origin
attribute (absent means zero), so negative coordinates still give a
0-indexed array. Bins follow the same rule; see
Bin shape.
Example: a time axis¶
import numpy as np
import zarr
from zarr_vectors.core.store import create_store
from zarr_vectors.types.points import write_points
rng = np.random.default_rng(0)
positions = rng.uniform(0, 20, (1000, 4)).astype(np.float32) # x, y, z, t
chunk_shape = (10.0, 10.0, 10.0, 10.0)
create_store(
"timeseries.zarrvectors",
axes=[{"name": n, "type": "space", "unit": "micrometer"} for n in "xyz"]
+ [{"name": "t", "type": "time", "unit": "second"}],
chunk_shape=chunk_shape,
bounds=([0.0] * 4, [20.0] * 4),
)
write_points("timeseries.zarrvectors", positions, chunk_shape=chunk_shape)
print(zarr.open_array("timeseries.zarrvectors/0/vertices").shape)
(2, 2, 2, 2)
Validation¶
Level |
Check |
|---|---|
1 ( |
Every per-chunk array in a level has the rank of |
2 ( |
|
3 ( |
Every decoded vertex fragment has |
See Validation.