Configs
Every option for routing and for preparing gridded runoff is held by a frozen Configs object. Build one from keyword
arguments or read one from a JSON file with Configs.from_json, then pass it to Router or to
GridRunoff.from_configs. Router.route validates it with validate_routing and GridRunoff.from_configs
validates it with validate_runoff. Neither validation stands in for the other.
import river_route as rr
configs = rr.Configs.from_json('config.json')
rr.Router(configs).route()
Configs
dataclass
Accepts and validates every option of a routing run and of preparing its runoff.
from_json(path)
classmethod
Build Configs from a JSON file
to_dict()
Every option by name, with discharge_files left empty when they were named from discharge_dir.
to_json(path)
Write every option to a JSON file
validate_routing()
Validate the options for routing: the options the chosen procedure requires are set and consistent, input paths exist, and outputs are in existing directories. Called by Router.route. Returns immediately once the Configs has passed it. The contents of the input files are not read; call deep_validate for that.
Raises:
| Type | Description |
|---|---|
(ValueError, FileNotFoundError, NotADirectoryError)
|
if any option is missing or invalid |
validate_runoff()
Validate the options for preparing gridded runoff: grid_weights_file is set and every input path exists. Called by the grid runoff classes. Returns immediately once the Configs has passed it, which does not validate it for routing. The contents of the input files are not read; call deep_validate for that.
Raises:
| Type | Description |
|---|---|
(ValueError, FileNotFoundError)
|
if any option is missing or invalid |
deep_validate()
Validate the contents of the network file, the grid weight table, and the initial channel state, whichever are set, and their consistency with each other: the network file columns, types, and value ranges and that it is topologically sorted, that the grid weight table matches the network file and its proportions sum to 1 per river, and that the initial channel state has one row per river, or with use_subreaches one per sub-reach. The forcing files are not read.
Nothing calls this for you. It reads every input file, which is the same work routing is about to do, so
run it once on inputs you have not checked before rather than on every route. validate_routing and
validate_runoff check the options and the paths only.
Raises:
| Type | Description |
|---|---|
ValueError
|
if any file or combination of files is invalid |