Skip to main content

Module network

Module network 

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

NetworkGeometry
The GeoParquet the store’s features are the rows of.
NetworkGroup
A network store’s group document: its xue_network block, validated.
NetworkLayout
How the streamflow array 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_network block’s version this reader implements.
TIME_PATH

Functions§

consolidated_network_array
The streamflow document a group carries inline in its consolidated metadata, as JSON, or None where it carries none and the document is the store’s own streamflow/zarr.json. A reader holds it to the group with parse_network_array like 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, and 1.0 re-written as 1 would no longer be the same document.
decode_network_chunk
Decode one inner chunk to its 6 × rowGroupRows codes, 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 × featureCount codes, frame-major, padding trimmed: every row group of the chunk decoded once.
dequantize
Codes → m³/s through the variable’s codebook; NaN for 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 — or None when none of them was written.
index_span
The index’s span within a shard of shard_length bytes, [start, end).
parse_network_array
Parse and validate streamflow/zarr.json against its group.
parse_network_group
Parse a store root’s zarr.json as a network store: a Zarr v3 group whose attributes carry xue_network and 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 of length, one chunk, the bytes codec little-endian, the named dtype and dimension.
read_baseflow
baseflow/c/0: each reach’s usual flow before the event, m³/s; NaN where 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, None for a chunk the shard never held.