River flow in a showcase case
In the viewer: the network case /showcase/guadalupe-2025 and the grid cases /showcase/valencia-2024-efas and /showcase/valencia-2024-efaswb.
A flood is told by its rivers: how much water each reach carried, hour by
hour, against what it usually carries, and what the gauges on it measured.
A showcase case may carry that beside its weather field, in a river/
directory of its own named by the case’s river block
(showcase/README.md). There are two kinds. A
network case has a hydrological model’s output on a river network —
one value per reach per frame, the National Water Model on the Guadalupe
in July 2025 — and publishes the reaches as GeoParquet and each track as a
network store. A grid case has its
model’s discharge as the case’s own gridded field (EFAS on the Valencia
DANA of October 2024, built by the ordinary case pipeline), and its
river/ directory carries only what the field does not: the gauges'
observed series, their reported peaks and the mapped flood extents. Xue
models nothing itself; it carries what the model, the gauge operators and
the mapping service published. This document is the normative description
of that directory, version 1.
1. Delivery
Everything is a static file inside the case’s directory,
showcase/<id>/river/, built once (python -m xuebuild.river build showcase/river-cases/<id>.json) and never rewritten.
index.jsonis the directory’s entry point (§2). The catalog row’sriverblock names it and carries itsbyteLengthandcrc32(zlib CRC-32 of its bytes, eight lowercase hex digits), so it is requested asriver/index.json?v=<crc32>.- Every other path is in the index, relative to it: no leading
/, no.., no.component. Request each as<path>?v=<crc32>with the CRC the index carries; a store’s CRC is that of its groupzarr.json(zarr-profile.md, “Attributes”) and is the?v=of every object in the store. - A network case holds
reaches.parquet(the GeoParquet), one<track id>.zarrper track,gauges.jsonlandindex.json; a grid casegauges.jsonl, anextent/directory of GeoJSON files andindex.json.
2. index.json
versionis1; a reader refuses any other.kindisnetworkorgrid. No key outside those this section names may appear.geometry(network only, required there): the GeoParquet (zarr-profile.md, “Network store”): itspath(a.parquetfile),byteLengthandcrc32, its row countfeatureCountand its row group lengthrowGroupRows. Every store of the case names the same file with the same four numbers.tracks(network only, required there, non-empty): one network store each, in the order the viewer offers them.idis a unique slug (lowercase letters, digits,_,-,.) and the store is<id>.zarrby convention;kindisanalysis(the model’s best estimate of what happened, one window) orforecast(one cycle); itsrunTimeequals the store’s ownrunTime— the cycle of a forecast, the first frame of an analysis. A forecast’s frames start where its product does (the NWM short range at +1 h).storeis{path, byteLength, crc32}: the store’s path (a.zarrdirectory), the sum of its objects' lengths and the CRC-32 of its group document.gauges(optional, default empty): observation points, each with a uniqueid(the operator’s own), aname,lonandlat(WGS84 degrees), thesourceoperator, theunitof its values (m3/s), and:feature(network only, required there): the GeoParquet row of the reach the gauge sits on, which is also the store’s feature index. A grid gauge has none: the viewer samples the case’s own field.sample(grid only, optional):[lon, lat]of the model cell the gauge was snapped to, where the viewer samples the field instead of at the gauge itself; a gauge on a narrow river can fall a cell off it.series(required):{path, offset, length}, the byte span of the gauge’s line ingauges.jsonl(§3).pathis alwaysgauges.jsonl.outflow(optional): the same span for a second line, the outflow of a gauge on a dam (the Forata reservoir): its line’sidis the gauge’s followed by.outflow.peaks(optional): reported peak values, each{time?, value, unit?, note?}: the time as ISO 8601 UTC ending inZwhere the report gives one, the value, the unit where it is not the gauge’s (a stage inmorft), and a short note saying what the value is and who reported it (USGS, estimated;peak inflow (CHJ SAIH)).
extent(optional, default empty): mapped flood extents, each{path, byteLength, crc32, at, credit}: a GeoJSON FeatureCollection of polygons in WGS84 (a.geojsonfile), the time of the imagery it was mapped from (at), and the credit line its producer requires.credits: the attribution lines the case must show, as given by the data’s publishers.disclaimer(optional): one line the viewer shows beside the river data.- A grid index with neither gauges nor extents says nothing and is refused.
3. gauges.jsonl
One file per case, one gauge series per line, each line one JSON object in the compact serialisation of the point products (no spaces, ASCII, keys as below):
time: strictly increasing ISO 8601 UTC times ending inZ;value: one number ornull(no reading) per time, in the gauge’sunit.stageandstageUnit(together or not at all): the water level, one number ornullper time. The times are the union of the discharge and stage readings, so a time with only one of them hasnullin the other.- A gauge’s
seriesspan in the index is its line’s JSON object exactly, without the newline (the synop contract,synop.md): issueRange: bytes=<offset>-<offset + length − 1>againstgauges.jsonl?v=<crc32 of the index>— the file is immutable with the directory — and parse the bytes on their own. The lines are in the index’s gauge order.
The series are what the operators published, unedited: the USGS’s
instantaneous values with their provisional and estimated spans (the
Guadalupe at Hunt stopped reporting stage at its peak and the USGS
estimated the discharge after it), or a series digitised from an
operator’s report where no download exists (the CHJ’s SAIH hydrographs of
October 2024, about 1 % of full scale). A case’s README and the peaks
notes say which.
4. Reading
- Fetch the catalog row’s
river.indexunder itscrc32, and validate it (§2). A viewer that does not know the block plays the case without river data. - A network case: fetch
reaches.parquet— or, for one area, its footer and the row groups whosebboxstatistics meet the view — and open the chosen track’s store (zarr-profile.md, “Network store”). A frame is one range of the shard; colour each reach by its ratio tobaseflow, or, when the row’s block namescolor(one of the case’s variables), by its value through that bundle’s palette and codebook, as the field draws it. - A gauge: one range of
gauges.jsonl. On a network case its modelled series is the store’s columnfeature; on a grid case, the case’s field sampled atsample(or atlon/lat). - An extent: fetch its GeoJSON and draw it from
aton, with its credit.
5. Writing
python -m xuebuild.river build showcase/river-cases/<id>.json reads the
work directory a definition names (its case.json lists the frames, the
gauges with their series files and the extents) and writes the case’s
river/ directory whole, the index last, then reads the index back
through the validator (xuebuild/river/schema.py::read_index), which
checks every file it names against what is beside it. The definition:
work and output are relative to the working directory (--work and
--output override them); a network case names its model and its
tracks — an analysis track takes the whole analysis window, a forecast
track the frames of one cycle — and either kind picks its gauges by id and
its extents by path from the work directory. credits defaults to the
work directory’s. Writing GeoParquet needs pyarrow.
Part of the Xue specification, licensed under CC BY 4.0.