Skip to main content

Module zarr

Module zarr 

Source
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§

ArrayDocument
A variable array’s document: how the array is cut, and the bundle it says it belongs to.
ArrayLayout
How one variable’s array is cut (docs/zarr-profile.md, “Array metadata”). time_chunk, tile_height and tile_width are the inner chunk; shard_frames is the outer chunk’s time extent, a positive multiple of the time chunk.
ArrayReader
A variable array being read: its layout, the shard indices handed over so far and the decoded tiles of one time chunk.
BundleMetadata
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.
LambertGrid
A grid on a map projection: the first cell’s centre and the steps, in projected metres, dy negative because rows run north to south.
ProbeCell
The cell a point probes: the grid index and the cell’s own coordinates.
RegularGrid
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.
ShardIndexEntry
One inner chunk’s byte span within its shard.
TileCell
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.
VariableMetadata
One variable in the group’s metadata.
ZarrGroup
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§

DataType
The code width a variable array declares in data_type. Every map, column and network array is uint8; a series store’s widened variable is uint16, little-endian on disk.
Grid
The bundle’s grid, in the container’s row-major, north-to-south, west-to-east order.
IndexLocation
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.
StoreKind
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_profile of a shared store: every bundle of one resolution tier in one group, each bundle’s metadata under attributes.xue_bundles[id].
PROFILE_SINGLE
The xue_profile of a store holding one bundle, its metadata in attributes.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 crc32c codec puts over a shard index — a different polynomial from the container’s CRC-32/IEEE.
decode_frame_chunk
decode_inner_chunk for a map frame: the bytes of a uint8 array’s chunk, refused on a uint16 one.
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 as u16 whatever the array’s width, so a series reader reads both widths through one path.
decode_value
Code → physical value, or None for 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 spelling Date#toISOString produces.
frame_indices
Frame indices to read: all of them, or the one nearest the requested valid time. run_time settles 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; None outside the grid. The inverse of probe_cell: probing the centre returns the same cell.
group_bundle_ids
The bundle ids a store’s group holds: every key of xue_bundles on a shared store, None on a single-bundle store, whose group does not name its bundle. They come in the group’s order only where serde_json keeps insertion order (the encoder feature 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_for selects 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 wants parse_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 (or uint16, a series store’s widened variable), three dimensions, a regular chunk grid, exactly one sharding_indexed codec, 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 to check_codebook; a uint16 array 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.json of a single-bundle (profile 1) store (docs/zarr-profile.md, “Attributes”). A shared store holds several bundles and is refused here: open it with parse_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, with bundle ignored, 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.parse does for the forms the pipeline emits.
parse_shard_index
The (offset, nbytes) pairs of one shard, CRC-32C verified. None marks an inner chunk the shard never held — the all-ones sentinel — which reads as the fill value. bytes is exactly the index.
place_tile
Copy frame frame_in_chunk of one decoded inner chunk into a plane of height × width codes, trimming the padding past the grid’s edge. chunk is None for a chunk the shard never held, which is the fill value throughout. chunk is decode_frame_chunk’s; a uint16 array has no map frame and is refused.
probe_cell
The cell a point reads, or None when 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). None is a spelling no run directory may take.
series_from_chunks
One cell’s code on every frame of the axis, in axis order. chunks holds the payload of the cell’s tile (tile_cell) in each time chunk, in order, None for 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 as u16 for 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 s of 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.