Expand description
Reading the Xue Zarr profile.
docs/zarr-profile.md is normative. A store is one Zarr v3 group with one
sharded uint8 array per variable (uint16 for a widened variable of a
series store): on profile 1 it holds one bundle, its
attributes.xue the bundle metadata verbatim; on profile 2 (a shared
store) it holds every bundle of one resolution tier, each one’s metadata
verbatim under attributes.xue_bundles[<bundle id>]. This module is the format’s read side in Rust: the two
metadata documents, the shard index, the arithmetic that maps a frame and a
tile to a byte span, the geographic cell a point probes, and the codebook
that turns a stored code into a physical value.
It is deliberately IO-free — it takes &str / &[u8] and returns values —
so the same code serves the native worker and, through wasm-bindgen, the
browser. The container decoder in crate::decode shares its metadata
validation: parse_bundle_metadata calls the container’s own
parse_metadata, so a group the container would refuse is refused here too.
The chunk payload itself is decoded by crate::decode_chunk, the same
Zstandard + PREVIOUS residual path the .xue reader uses.
Structs§
- Array
Document - A variable array’s document: how the array is cut, and the bundle it says it belongs to.
- Array
Layout - How one variable’s array is cut (
docs/zarr-profile.md, “Array metadata”).time_chunk,tile_heightandtile_widthare the inner chunk;shard_framesis the outer chunk’s time extent, a positive multiple of the time chunk. - Array
Reader - A variable array being read: its layout, the shard indices handed over so far and the decoded tiles of one time chunk.
- Bundle
Metadata - The bundle metadata a store’s group carries in
attributes.xue, reduced to what a reader needs: the grid, the materialized time axis and the variables with their codebooks. - Lambert
Grid - A grid on a map projection: the first cell’s centre and the steps, in
projected metres,
dynegative because rows run north to south. - Probe
Cell - The cell a point probes: the grid index and the cell’s own coordinates.
- Regular
Grid - A regular latitude/longitude grid. With
gaussian, the rows are really a Gaussian grid’s: the regular fields stay the equidistant approximation a renderer samples with, and the true latitudes are what a point read reports. - Shard
Index Entry - One inner chunk’s byte span within its shard.
- Tile
Cell - A cell’s place in the inner chunk grid: the tile it falls in, and its offset within one frame of that tile’s decoded chunk.
- Variable
Metadata - One variable in the group’s metadata.
- Zarr
Group - A parsed group document, reduced to one bundle: the metadata, its compact re-serialization, the profile version and, on a shared store, the id the bundle was selected by.
Enums§
- Data
Type - The code width a variable array declares in
data_type. Every map, column and network array isuint8; a series store’s widened variable isuint16, little-endian on disk. - Grid
- The bundle’s grid, in the container’s row-major, north-to-south, west-to-east order.
- Index
Location - Where a shard’s index sits within the object.
- Quantization
- A codebook: how a stored code maps back to a physical value
(
docs/bundle.md, “Codebooks”). Its code keys are integers up to 65535; which of them fit is the width of the array or container that holds them. - Store
Kind - The profile’s four branches (
docs/zarr-profile.md): a bundle’s grid store, a radar’s polar store, a river’s network store and a run’s column store.
Constants§
- DELTA_
CODEC - The array-to-array delta codec’s name in an inner codec chain.
- PROFILE_
SHARED - The
xue_profileof a shared store: every bundle of one resolution tier in one group, each bundle’s metadata underattributes.xue_bundles[id]. - PROFILE_
SINGLE - The
xue_profileof a store holding one bundle, its metadata inattributes.xue.
Functions§
- axis_
times - The ISO 8601 instants of the selected frames.
- check_
codebook - Hold a codebook to the array whose codes it reads: the array’s fill value
is the codebook’s
nodataCode, and every code key fits the array’s data type. A reader dequantizing an array with metadata held elsewhere (the group’s) checks that block against the array with this. - chunk_
predictor - The predictor an inner chunk of this array decodes with.
- crc32c
- The CRC-32C (Castagnoli) checksum the
crc32ccodec puts over a shard index — a different polynomial from the container’s CRC-32/IEEE. - decode_
frame_ chunk decode_inner_chunkfor a map frame: the bytes of auint8array’s chunk, refused on auint16one.- decode_
inner_ chunk - One inner chunk’s payload decoded to codes at the full inner shape,
time_chunk × tile_height × tile_width, padding included: the container’s chunk path, with the Zstandard frame’s content checksum required. Codes come out asu16whatever the array’s width, so a series reader reads both widths through one path. - decode_
value - Code → physical value, or
Nonefor a missing/overflow code (web/src/render/palettes.ts::decodeValue, and the schema v3 block beside it). - format_
iso_ millis - Format milliseconds since the Unix epoch as
YYYY-MM-DDTHH:MM:SS.sssZ, the spellingDate#toISOStringproduces. - frame_
indices - Frame indices to read: all of them, or the one nearest the requested valid
time.
run_timesettles where offset 0 sits; without it the axis starts at the epoch, as the shell’s probe does. - frames_
in_ time_ chunk - How many of a time chunk’s frames lie on the axis: fewer than the chunk shape on the last one, none past it.
- grid_
cell - A cell addressed by its indices, with its centre;
Noneoutside the grid. The inverse ofprobe_cell: probing the centre returns the same cell. - group_
bundle_ ids - The bundle ids a store’s group holds: every key of
xue_bundleson a shared store,Noneon a single-bundle store, whose group does not name its bundle. They come in the group’s order only whereserde_jsonkeeps insertion order (theencoderfeature turns that on); otherwise sorted. - group_
metadata_ json - The group document read no further than its envelope: the profile, and
the selected bundle’s metadata block as compact JSON, selected as
parse_group_metadata_forselects it and refused without a bundle named on a shared store. The block itself is not validated here. This is for a reader that holds the block to the metadata rules with a validator of its own, as the shell does; every other caller wantsparse_group_metadata_for. - parse_
array_ document parse_array_metadata, with the bundle the array names.- parse_
array_ metadata - The array’s
zarr.json, held to the profile:uint8(oruint16, a series store’s widened variable), three dimensions, a regular chunk grid, exactly onesharding_indexedcodec, an inner chain of[bytes, zstd]or[xue.delta{axis: 0}, bytes, zstd], index codecs[bytes, crc32c]little-endian, and an outer chunk of whole time chunks of whole tiles. Where the array carries its variable’s codebook (attributes.xue.variable.quantization) it is held tocheck_codebook; auint16array must carry one. - parse_
bundle_ metadata - Parse and validate a bundle metadata JSON document. Validation is the
container decoder’s own (
crate::decode::metadata), so the two readers agree on what is a valid document; the geo and codebook fields the API needs are read off the same object afterwards. - parse_
group_ metadata - The root
zarr.jsonof a single-bundle (profile 1) store (docs/zarr-profile.md, “Attributes”). A shared store holds several bundles and is refused here: open it withparse_group_metadata_for. - parse_
group_ metadata_ for - One bundle’s view of a store’s root
zarr.json, whichever profile wrote it: on a shared (profile 2) store,attributes.xue_bundles[bundle]; on a single-bundle (profile 1) store,attributes.xue, withbundleignored, since that group holds one bundle and does not name it. A reader opens a store by(path, bundle id)and the manifest entry gives it both. - parse_
iso - Parse an ISO 8601 instant to milliseconds since the Unix epoch, without a
date library: the same arithmetic
Date.parsedoes for the forms the pipeline emits. - parse_
shard_ index - The
(offset, nbytes)pairs of one shard, CRC-32C verified.Nonemarks an inner chunk the shard never held — the all-ones sentinel — which reads as the fill value.bytesis exactly the index. - place_
tile - Copy frame
frame_in_chunkof one decoded inner chunk into a plane ofheight × widthcodes, trimming the padding past the grid’s edge.chunkisNonefor a chunk the shard never held, which is the fill value throughout.chunkisdecode_frame_chunk’s; auint16array has no map frame and is refused. - probe_
cell - The cell a point reads, or
Nonewhen it is off the grid (a regional model’s rectangle, a projected footprint, a satellite disk). On a regular grid the rules are the shell probe’s and the fragment shader’s (web/src/features/probe/probe.ts::probeCell). - run_
directory - A run directory under the data root. Accepts the STAC Item id form with a
4-digit round (
mrms.2026092509.1455→mrms.2026092509/1455), the run directory itself (mrms.2026092509/1455), or a plain run id (gfs.2026092506).Noneis a spelling no run directory may take. - series_
from_ chunks - One cell’s code on every frame of the axis, in axis order.
chunksholds the payload of the cell’s tile (tile_cell) in each time chunk, in order,Nonefor a chunk the shard never held, which reads as the fill value. Each chunk is decoded and let go: a series touches every one once. Codes come out asu16for either width. - shard_
index_ length - The byte length of a shard’s index: one pair per inner chunk plus the checksum.
- shard_
of - Which shard a time chunk lives in, and the position of its first tile in that shard’s index (row-major over the inner chunk grid).
- shard_
path - The object holding shard
sof a variable’s array: the default chunk key encoding, with the two grid dimensions at chunk 0 because a shard spans the whole grid. - store_
kind - Which branch of the profile a store’s group document declares.
- tile_
cell - Where a grid cell sits in its tile’s chunks.
- tile_of
- The tile a cell falls in.
- tile_
origin - The row and column a tile starts at.
- tile_
shape - A tile’s clipped shape: what of it lies inside the grid.