Expand description
Reading the Zarr profile’s network store.
docs/zarr-profile.md, “Network store”, is normative. A network store
holds one track of a river model — an analysis window or one forecast
cycle — as one uint8 array streamflow of shape [time, feature],
where feature f is row f of the GeoParquet beside the store, with an
inner chunk of six frames of one GeoParquet row group. Beside it sit the
reach ids, the frame times and each reach’s baseflow.
Like crate::zarr, this module is IO-free: it takes the documents and
the shard’s bytes (whole, or one fetched range of it with that range’s
offset) and returns codes and values. The shard, its index and the inner
chunk path are the grid store’s own; only the dimensions, the chunking and
the attributes are this branch’s. Every count that sizes an allocation is
validated first, and every offset is checked against the bytes given.
Structs§
- Network
Geometry - The GeoParquet the store’s features are the rows of.
- Network
Group - A network store’s group document: its
xue_networkblock, validated. - Network
Layout - How the
streamflowarray is cut, held to the group:[frameCount, featureCount]in inner chunks of[6, rowGroupRows], one shard of the whole array rounded up to whole inner chunks.
Constants§
- BASEFLOW_
PATH - FEATURE_
ID_ PATH - The side arrays’ one chunk each, relative to the store root.
- NETWORK_
ARRAY - The data array’s name, and the one variable’s
id. - NETWORK_
SHARD_ PATH - The data array’s one shard object, relative to the store root.
- NETWORK_
TIME_ CHUNK - Frames per inner chunk, as in a grid store.
- NETWORK_
VERSION - The
xue_networkblock’s version this reader implements. - TIME_
PATH
Functions§
- consolidated_
network_ array - The
streamflowdocument a group carries inline in its consolidated metadata, as JSON, orNonewhere it carries none and the document is the store’s ownstreamflow/zarr.json. A reader holds it to the group withparse_network_arraylike the standalone one. Serialized here rather than by the caller so its numbers keep the spelling the group gives them: the array repeats the group’s variable, and1.0re-written as1would no longer be the same document. - decode_
network_ chunk - Decode one inner chunk to its
6 × rowGroupRowscodes, frame-major, the delta replayed along the frame axis. A never-written chunk is all fill. - decode_
network_ frame - One frame’s codes, one per reach in GeoParquet row order.
- decode_
network_ series - One reach’s codes over the whole axis: one inner chunk per time chunk.
- decode_
time_ chunk - Every frame of one time chunk that lies on the axis,
frames × featureCountcodes, frame-major, padding trimmed: every row group of the chunk decoded once. - dequantize
- Codes → m³/s through the variable’s codebook;
NaNfor no value. Code 0 is no flow, and the overflow code reads as a flow above the codebook’s maximum. - frame_
range - The byte span
[start, end)of the shard holding every written chunk of one frame’s time chunk — one range per frame — orNonewhen none of them was written. - index_
span - The index’s span within a shard of
shard_lengthbytes,[start, end). - parse_
network_ array - Parse and validate
streamflow/zarr.jsonagainst its group. - parse_
network_ group - Parse a store root’s
zarr.jsonas a network store: a Zarr v3 group whose attributes carryxue_networkand neither of the other branches’ blocks, at a version this reader implements. - parse_
network_ index - Parse the index bytes alone (a suffix range, or the shard’s head), CRC-32C verified. Spans are checked against the bytes when chunks are read.
- parse_
side_ array - A side array’s
zarr.json: one dimension oflength, one chunk, thebytescodec little-endian, the named dtype and dimension. - read_
baseflow baseflow/c/0: each reach’s usual flow before the event, m³/s;NaNwhere unknown.- read_
feature_ ids feature_id/c/0: each reach’s identifier in its source, in row order.- read_
frame_ times time/c/0: each frame’s valid time in Unix seconds, which must be the time the group’s block gives it.- read_
network_ index - Read the shard index out of the whole shard, CRC-32C verified, every written chunk lying inside the shard and outside the index.
- series_
ranges - The chunk spans one reach’s series reads: one per time chunk,
Nonefor a chunk the shard never held.