Skip to content

Store

glofas_ewds.store

Places and their rivers, kept on disk: what the facts and the UI read.

Pure Python and JSON: no network, no NetCDF.

The EWDS needs an account and a queue of minutes, and a public page cannot wait minutes. So everything that answers a question reads a store: a folder with one JSON file per place, filled beforehand (glofas-ewds init, glofas-ewds update) and read as it is. Every piece of data in it carries where it came from and when it was fetched, so an answer can say how old it is.

A :class:Place holds a town, the river cell found for it (:func:~glofas_ewds.rivers.nearest_river), the official thresholds of that cell, the daily history and the last forecast runs, newest last.

Run dataclass

One forecast run of a node: (member, lead time), the control run first.

Place dataclass

A place, its river and what was downloaded for it.

node property

node: Node | None

The point to give every reader for this river; None without a river.

add_run

add_run(run: Run) -> None

Keep run, replacing one of the same day; drop the oldest past :data:MAX_RUNS.

Store

The places of a data folder, one JSON file each under places/.

ids

ids() -> list[str]

The ids of the places in the store, sorted.

load

load(place_id: str) -> Place

The place place_id; :class:~glofas_ewds.errors.GlofasEwdsError if unknown.

places

places() -> list[Place]

Every place of the store.

save

save(place: Place) -> Path

Write place; never half a file (.part, then rename).

nearest

nearest(longitude: float, latitude: float) -> tuple[Place, float] | None

The stored place nearest a point, and its distance in km; None if empty.

stamp

stamp(time: datetime) -> str

A time as the store writes it: 2026-11-28T15:04Z, always UTC.

slug

slug(name: str) -> str

A file-safe id from a name: Campi Bisenzio gives campi-bisenzio.

to_json

to_json(place: Place) -> dict[str, Any]

A place as plain JSON types.

from_json

from_json(data: dict[str, Any]) -> Place

A place from what :func:to_json wrote.