Downslope distance between two networks#

A mapped stream network and a simulated one rarely coincide. This page defines how far apart they are, measured along the paths the water takes, and the criterion built on that distance, the method of Abhervé et al. [2023]. It answers one question. Given a model that makes a network of streams and a map that draws another, how long is the walk downslope from one to the other, in each direction, and at which value of the calibrated ratio do the two walks balance?

How a model makes streams in plain words is on How the model makes streams. The keys of a calibration on a network are in [calibration.outputs].

Note

Scope. The page covers the distances, the criterion, what it identifies, and how the mapped network is drawn on the mesh. The simulated network itself, from the release flux to the flowing cells, is on Where the water table reaches the surface. The search that moves a parameter until the criterion reaches zero is described only where it shapes the criterion.

Notation of this page

Every cell \(n\) has a center \(x_n\) and an area \(a_n\). A distance is a length in meters along cell-to-cell links, center to center. Sets of cells are written with capital letters.

Symbol

Meaning

Unit

Set by

\(B\)

saturated thickness, \(B(h) = \min\bigl(\max(h - z_\mathrm{bot}, 0), H\bigr)\)

m

state, not a field

\(\bar B\)

saturated thickness averaged by area over the catchment (d_sat_m)

m

derived

\(K\)

horizontal hydraulic conductivity, the same along \(x\) and \(y\)

m/s

flow.param.K.field.value

\(T\)

transmissivity, \(T = K\,B\)

m²/s

derived

\(\bar N\)

recharge averaged over the catchment and a period of time (R_mean_m_s on the stream-network page)

m/s

derived

\(n, m\)

cell indices; \(\mathcal{N}(n)\) is the set of cells that share a face with \(n\)

the grid, The mesh

\(a_n\)

plan area of cell \(n\)

m²

the grid

\(\epsilon\)

rise per step of the priority flood inside a filled depression

m

1 mm, a constant of the code

\(r(n)\)

receiver of cell \(n\), the one cell it drains to; \(-1\) when it has none

derived

\(\mathcal{N}_D(n)\)

neighbours a cell may drain to: the cells sharing a node on a quad mesh, a face on any other

neighbours for the criterion

\(C_n\)

drain conductance of cell \(n\)

m²/s

flow.bc.<name>.value of drainage, or derived from \(K\)

\(b_d\)

thickness of the drain bed in the derived conductance

m

solver.drain_bed_thickness_m

\(z^d_n\)

drain elevation of cell \(n\)

m

derived

\(q^\mathrm{rel}_n\)

water the aquifer releases to the surface in cell \(n\) (release_flux)

m³/s

derived

\(\tau_\mathrm{s}\)

share of the mean basin recharge, over its own area, a cell must release to count as a source

seepage_threshold

\(\Sigma\)

the sources: cells that release more than their threshold

derived

\(\mathcal{S}\)

the simulated network: the downstream closure of \(\Sigma\)

derived

\(D\)

the descent of the model top

built with every MODFLOW grid

\(D_{so}\)

mean downslope distance from the simulated network to the mapped one (D_so). Large: the model has too much stream.

m

derived

\(D_{os}\)

mean downslope distance from the mapped network to the simulated one (D_os). Large: the model has too little stream.

m

derived

\(J_{signed}\)

\(D_{so} - D_{os}\), the residual a root search drives to zero (J_signed)

m

derived

\(J\)

\(\lvert D_{so} - D_{os}\rvert\), the cost of the distance_gap metric (J)

m

calibration.objective_blocks.metric

\(D_{optim}\)

\((D_{so} + D_{os}) / 2\), a diagnostic (D_optim)

m

derived

\(h_{obs}\)

cell size where the mapped network lies, the median distance between neighbouring cell centres over the mapped cells (h_obs)

m

derived

\(r_{optim}\)

\(D_{optim} / h_{obs}\), the validity indicator (r_optim)

derived

\(V\)

the length \(D_{optim}\) must stay under for the result to be valid (validity_length_m)

m

validity_length, position_accuracy

\(L_{cap}\)

longest descent to the outlet inside the catchment; the value a cell whose descent never meets its target takes (L_cap)

m

derived

\(\alpha_o\)

share of the mapped network in its own downslope closure, inside the catchment (alpha_obs_closure_catchment). A low value means the map and the model top disagree.

warning level: alpha_warning_threshold

\(K/\bar N\)

conductivity over mean recharge (k_over_r)

derived

\(T/\bar N\)

\(K\,\bar B / \bar N\), transmissivity over recharge (t_over_r_m)

m

derived

\(\mathcal{O}\)

the mapped network, drawn on the cells

drawn_by

\(d_T(n)\)

downslope distance from cell \(n\) to the set \(T\)

m

derived

\(\ell(n)\)

distance from the centre of \(n\) to the centre of its receiver

m

derived

\(A_d(n)\)

area drained through cell \(n\), the cell included

m²

derived

\(o\)

outlet cell that closes the catchment

derived from the pour point

\(\Omega_o\)

the catchment scored: the cells whose descent reaches \(o\)

derived

\(\mathcal{E}\)

water bodies: lake cells and other cells whose surface water is an input

derived

\(\mu(n)\)

weight of a cell in a mean: 1, or its area

1 or m²

weighting

\(f_{so}, f_{os}\)

share of a support whose descent never meets its target (frac_unreachable_so, frac_unreachable_os)

reported per trial, bounds nothing

\(\sigma_o\)

positional accuracy of the mapped network

m

position_accuracy

\(r_s\)

largest distance between a stream head and the cell it lands on

m

heads.radius

\(A_{d,\min}\)

drained area a cell needs before a head may land on it

km²

heads.min_drained_area

The graph the distances follow#

A distance follows a flow path, and a flow path exists only where the depressions are resolved. The code floods the model top on the mesh with the priority flood of Routing on the mesh: the descent D, (41), seeded on the border of the active domain, and reads the receivers \(r(n)\) of (43) on the flooded copy. The edge length \(\ell(n)\) is the distance from the center of \(n\) to the center of \(r(n)\).

The flood is seeded on the whole border, where water leaves the model, not on the outlet alone: sealing one outlet would fill a valley of the buffer up to a col of the divide. The criterion does not read the descent \(D\) the build stores (The graph of the stream criterion). The map is never burned into the surface: an observation never enters the routing surface or the model top.

1. The downslope distance to a set#

For a target set \(T\), the distance from a cell to \(T\) is the length of its descent down to the first cell of \(T\):

(54)#\[\begin{split}d_T(n) = \begin{cases} 0 & n \in T, \\ \ell(n) + d_T\bigl(r(n)\bigr) & n \notin T,\ r(n) \text{ exists}, \\ +\infty & n \notin T,\ r(n) \text{ does not exist.} \end{cases}\end{split}\]

With one receiver per cell, exactly one descending path leaves a cell, so there is no shortest path to search for. The distance is not a Euclidean nearest distance: a source fifty meters from a stream but across a divide is far away downslope. And it is not symmetric: \(d_{\mathcal{O}}\) on the simulated cells and \(d_{\mathcal{S}}\) on the mapped cells differ, which is what lets one cost weigh an excess of simulated stream against a missing one. An empty target gives \(+\infty\) everywhere and does not raise: an empty simulated network is the legitimate end of a search interval.

Two copies of an 8 by 8 grid with receiver arrows. Squares mark the mapped network along the valley, dots the simulated network, which stops halfway up and adds two hillside cells. Numbers give the distance of each cell to the other network.

Fig. 65 Two networks on an 8 by 8 grid of 10 m cells, with the receivers of the flooded top. Left: from each simulated cell down to the map, the two hillside cells walk 42 m. Right: from each mapped cell down to the simulated network, the three upper cells walk 10, 20 and 30 m. The two means differ, and so do the cells that carry them. Every number is a call of downslope_distance_to_mask.#

In the code: downslope_distance_to_mask.

2. The outlet, the catchment and the saturation length#

The outlet \(o\) closes the catchment, usually at the gauging station. With \(A_d(n) = a_n + \sum_{m : r(m) = n} A_d(m)\) the area drained through \(n\), the outlet is the most drained cell within two neighbor rings of the cell nearest to the pour point the catchment was delineated from (two cells is the SnapPourPoints distance of the paper, read on the mesh). Without a pour point, the most drained cell of the delineated polygon closes the catchment, and without the polygon the largest basin of the mesh does, with a warning.

The catchment scored, and the longest descent in it, are read on the same graph:

(55)#\[\Omega_o = \{\, n : d_{\{o\}}(n) < \infty \,\}, \qquad L_{cap} = \max_{n \in \Omega_o} d_{\{o\}}(n) .\]

The delineated polygon builds the domain and places the outlet; it is not the support. Their symmetric difference over the area of the polygon, the outline the mesh followed when it followed one, is published as catchment_mismatch. The same gap to the basin of D the build kept, the cells the budget zone sums, is published as basin_mismatch. A wrong outlet closes the basin of D on the same wrong branch, so only the first one shows it. Above max_catchment_mismatch, 5 per cent by default, the search is refused before its first solve. On the Nançon the gap is 0.2 per cent on the default grid of 27 004 cells, 4.2, 3.0, 2.1 and 4.2 per cent on grids of 45, 60, 80 and 120 cells a side, and 0.2 per cent on a Voronoi mesh of 100 m that follows the smoothed outline. It passes 5 per cent on the grid of 30 cells a side (9.4), on a Voronoi mesh of 400 m (6.6) and on a Voronoi mesh of 200 m (11.2), where the outlet closes on another branch. \(L_{cap}\) is static: it is the value an unreachable cell takes in the means (5. The two mean distances).

In the code: resolve_outlet.

3. The two networks on the cells#

The simulated network \(\mathcal{S}\) is the downstream closure of the sources \(\Sigma\), the cells whose release flux exceeds a share of their own recharge, (50). The release flux is the union of (49), the same union for the criterion and for the stored field. A steady phase reads one state of the run.

The mapped network \(\mathcal{O}\) is a set of lines, drawn on the cells by one of three rules chosen by drawn_by. It is first cut to the delineated catchment (clip_to_catchment), with the shape data.hydrography clips what it loads to, so a file and that section draw the same map, and so does a figure redrawn from the run.

Heads keeps only where the map says a stream starts, and lets the receiver graph draw the rest: the path a ditch gave a mapped line is something a model on a DEM cannot reproduce, and drawn cell by cell it would count as error.

  1. The lines are merged between junctions and free ends. A free end on the outline the map was cut along was made by the cut: the stream goes on beyond it, so it is no head. It is counted as n_cut_ends.

  2. A free end is a head when the largest drained area within the radius \(r_s\) of it does not exceed the same quantity at the other end of its reach. The drained area decides, never the direction the line was drawn in.

  3. A head lands on the nearest active cell within \(r_s\) that drains at least \(A_{d,\min}\), or is lost.

  4. From each landing cell, the trace follows the receivers until the descent ends or meets a traced cell.

  5. The foot of each dam of a lake with a declared spillway is a forced head: the stream under a reservoir has no free end. Only the MODFLOW 6 build stores the dam feet.

The traced map is connected to the outlet by construction.

A toy valley with three mapped lines running beside the talweg. Two upstream free ends are kept as heads with their snap radius; the downstream free end is rejected. The drawn map follows the talweg from the two landing cells to the outlet.

Fig. 67 The heads rule on a toy valley of 25 m cells, from one call of trace_from_heads. The two upstream free ends drain less than the confluence and are kept; the downstream end drains more and is not a head. The drawn map follows the descent of the model, not the line.#

Crossing, the default, draws the map as the data gives it. It keeps a cell when a mapped line crosses the segment joining the centers of two cells that share an edge: on a structured grid, the cell medians, which is what the WhiteboxTools tool VectorLinesToRaster of the paper tests. The map is one cell wide, like the simulated network. A reach that crosses no segment marks the cell holding its midpoint instead, and the count is published per trial as n_observed_features_fallback. This is the rule for a map that is not a tree: canals, braids, polders, karst.

Touch keeps every cell a line touches, corners included. Each diagonal step of the map then gains the two cells that share the corner, so a model that reproduces the map exactly is pulled towards a smaller K. It is kept to replay a session recorded before 2026-09.

In the code: trace_from_heads.

4. The supports and the targets#

The means are taken over the catchment, without the water bodies \(\mathcal{E}\):

(56)#\[\Omega_o^\ast = \Omega_o \setminus \mathcal{E}, \qquad \mathcal{S}^\ast = \mathcal{S} \cap \Omega_o^\ast, \qquad \mathcal{O}^\ast = \mathcal{O} \cap \Omega_o^\ast .\]
  • \(\mathcal{S}\) is closed downslope, \(\mathcal{O}\) is taken as drawn: closing the map would build observation out of the DEM.

  • The target of \(D_{so}\) is \(T_{so} = \mathcal{O} \cup \mathcal{E} \cup \{o\}\). The outlet is added because mapped lines may stop short of it.

  • The target of \(D_{os}\) is \(T_{os} = \mathcal{S}\).

  • Water bodies stay in the graph and leave both supports: a lake cell in a support would add one zero per cell and move the root with the size of the lake.

The supports split the cells into three classes, published per trial: n_valid (\(\mathcal{S}^\ast \cap \mathcal{O}\), simulated where the map has a stream), n_excess (\(\mathcal{S}^\ast \setminus \mathcal{O}\), simulated where it has none) and n_missing (\(\mathcal{O}^\ast \setminus \mathcal{S}\), mapped where the model makes none).

The graph is not cut to \(\Omega_o\), the supports are: on a buffered domain many cells drain out of the basin and never meet the map.

5. The two mean distances#

Write \(\hat d_T(n)\) for the distance in which an unreachable cell takes the value \(L_{cap}\). An unreachable cell is never dropped and never counted as infinite: \(+\infty\) would make the mean infinite, and dropping it would move the support with the parameter. With \(\mu(n)\) the weight of a cell,

(57)#\[D_{so} = \frac{\sum_{n \in \mathcal{S}^\ast} \mu(n)\, \hat d_{T_{so}}(n)}{\sum_{n \in \mathcal{S}^\ast} \mu(n)}, \qquad D_{os} = \frac{\sum_{n \in \mathcal{O}^\ast} \mu(n)\, \hat d_{T_{os}}(n)}{\sum_{n \in \mathcal{O}^\ast} \mu(n)} .\]

With \(\mu = 1\), each cell has one vote, as in the paper; with \(\mu = a_n\) the mean is weighted by area, which matters on a mesh refined along the streams. Both pairs are reported at every trial, and weighting selects the one the criterion reads.

\(D_{so}\) large means a simulated network spilling far from the mapped one, an excess. \(D_{os}\) large means a simulated network that never grew to the mapped one, a deficit. At a balanced point most distances are zero, so the means are carried by a few cells: they are tail statistics.

The unreachable shares \(f_{so}\) and \(f_{os}\) are reported on both sides, and neither refuses a trial. \(f_{so}\) is zero by construction: the target of \(D_{so}\) holds the outlet, and every cell of the catchment reaches the outlet. The target of \(f_{os}\) is the simulated network the calibration moves: at a high conductivity it retracts into the talwegs, and mapped cells legitimately have nothing left to descend into. frac_outlet_terminated is the share of the simulated support whose descent meets the target only at the sealed outlet. It says how much of \(D_{so}\) rests on that one cell, and a network in excess legitimately gives a large share, so it bounds nothing.

In the code: mean_downslope_distance.

6. The criterion#

The criterion is equations 1 to 4 of Abhervé et al. [2023]:

(58)#\[\begin{split}\begin{aligned} J_{signed} &= D_{so} - D_{os}, & J &= \lvert J_{signed} \rvert, \\ D_{optim} &= \tfrac{1}{2}\,(D_{so} + D_{os}), & r_{optim} &= D_{optim} / h_{obs} . \end{aligned}\end{split}\]

When the simulated network is empty, \(D_{so}\) has no support, and the residual is set to \(J_{signed} = -L_{cap}\): the negative value a root search needs at the end of its interval where nothing seeps.

The cost is \(J\), and its zero is a crossing. The two curves \(D_{so}\) and \(D_{os}\), drawn against the calibrated parameter, cross, and the crossing is the answer. \(D_{optim}\) is large at both ends of a sweep, so it has an interior minimum, and minimizing it is a tempting substitute. It is a different estimator: nothing places its minimum at the crossing.

Two curves against the calibrated ratio on a log axis. The distance from the simulated to the mapped network falls as the ratio grows, the distance from the mapped to the simulated network rises, and they cross where J is zero. The dotted mean of the two has its minimum further right.

Fig. 69 \(D_{so}\) and \(D_{os}\) against \(K/\bar N\) on a toy catchment of 60 by 60 cells of 20 m. No solver runs: a cell is a source when the recharge it drains exceeds what a 30 m saturated thickness carries down its slope, \(\bar N A_d > K B s\,w\), and the map holds the cells draining more than 0.03 km². Every distance is a call of the code. The curves are steps, because the masks are discrete. The minimum of \(D_{optim}\) (dotted) is not at the crossing.#

The two estimators are needed and are not interchangeable. Inside one model structure, \(J\) finds the parameter, and \(D_{optim}\) cannot separate two points that both balance. Between structures already balanced at \(J = 0\), only \(D_{optim}\) separates them. The code names them apart in metric: distance_gap is the cost \(J\) and carries the signed residual; distance_mean is \(D_{optim}\), a diagnostic. With two maps, each bound is this same pair evaluated once, and the cost is the sum of the weighted gaps. A run with a permanent map beside the full one, in one state, scores the state against the permanent map; the full map is scored at the same state as a validation and never enters the cost.

In the code: seepage_distance_cost.

7. When a result is valid#

The length scale. \(h_{obs}\) is the median distance between the centers of cells that share an edge, over the mapped cells of \(\Omega_o\): the cell size on a regular grid, the size of the fine cells on a mesh refined along the streams. It is static, since the map does not move with \(K\).

The bound. The paper reads \(r_{optim} \leq 2\): two cells, one of which budgets for the error of the map. The code writes it as a length:

(59)#\[D_{optim} \leq V, \qquad V = 2\,\max(h_{obs},\ \sigma_o) .\]

With no declared accuracy, \(V = 2 h_{obs}\), the bound of the paper. A declared accuracy \(\sigma_o\) above \(h_{obs}\) widens \(V\) and leaves \(r_{optim}\) comparable with the paper. A declared validity_length replaces the computation. The bound is read on the trial the search returns, and qualifies the value without replacing it: a violation logs a warning, or is refused after the session is saved when on_invalid is "error". Each trial publishes r_optim and r_optim_valid.

The map against the surface. Wherever the mapped lines do not sit in the talwegs of the model top, the distances measure a disagreement between two datasets rather than hydrogeology. The code publishes the share of the downstream closure of the map that the map itself holds, inside the catchment:

(60)#\[\alpha_o = \frac{\lvert \mathcal{O} \cap \Omega_o \rvert}{\lvert \mathrm{closure}(\mathcal{O}) \cap \Omega_o \rvert},\]

as alpha_obs_closure_catchment. A value below alpha_warning_threshold logs a warning, once per process.

What the criterion identifies#

Take a steady water-table aquifer with drains at the surface whose conductance is derived from \(K\), (44). Per unit area, the balance of a cell is

(61)#\[\nabla \cdot \bigl( K\, B\, \nabla h \bigr) + N = \frac{K}{b_d}\,\bigl(h - z^d\bigr)_+ ,\]

with \(B\) the saturated thickness ((24)) and \(z^d\) the drain elevation, the cell top by default. Dividing by \(K\) gives

\[\nabla \cdot \bigl( B\, \nabla h \bigr) + \frac{N}{K} = \frac{1}{b_d}\,\bigl(h - z^d\bigr)_+ ,\]

which depends on \(N/K\) and on the geometry alone. When \(K\) is scaled by one factor everywhere and \(N\) keeps its shape, the head field, and so the seepage mask, the release flux and the criterion, depend only on \(K/\bar N\). What the criterion calibrates is that ratio, not \(K\). A \(K\) read from it inherits the recharge series entirely: report \(K/\bar N\) and name the recharge beside it.

When the search moves the homogeneous conductivity alone, the report publishes the ratio with what it rests on: k_over_r (\(K/\bar N\)), k_optim_m_s, R_mean_m_s (\(\bar N\)), d_sat_m (the saturated thickness averaged over the catchment, \(\bar B\)), and t_over_r_m (\(T/\bar N = K \bar B / \bar N\), a length). For any other search they are not published.

This is why a search that moves \(K\) is refused when a conductance does not follow \(K\) (see the limits).

Assumptions#

  • Water leaves a cell by one receiver (single flow direction).

  • The model top, flooded on the mesh graph, is the surface water follows.

  • Distances are lengths along links between cell centers, not straight lines.

  • The mapped network is independent of the DEM. It is never burned into the surface.

  • The release flux is the whole of what leaves the aquifer for the surface.

  • For the reading of \(K/\bar N\): the state is steady, the drain conductance follows \(K\), and \(K\) is scaled by one factor while \(N\) keeps its shape.

  • The threshold \(\tau_\mathrm{s}\) and the mean recharge \(\bar N\) are frozen over a search.

Limits#

What the code refuses:

  • a search whose scored catchment differs from the delineated outline by more than its bound, before the first solve: an outlet on another branch, or a mesh too coarse for the catchment;

  • a mapped network that lands on no active cell, or on no cell of the catchment. The message names the CRS as the first suspect;

  • a heads rule that draws no stream: no free end on an active cell, every free end draining more than the other end of its reach, or every head lost;

  • a release record in the budget that no declared package reads, which would report its water as dry land;

  • a search that moves a conductivity while a drain has a fixed conductance, or while SFR or LAK is active: those conductances do not follow \(K\), so (61) does not hold. A search driving another parameter gets a warning instead;

  • a bisection on more than one parameter, or on a parameter without a logarithmic transform.

What the code does not represent:

  • Monotonicity. The criterion does not prove that \(J_{signed}\) varies one way with the parameter. It checks it on a sweep.

  • \(r_{optim}\) is not a quality indicator. It measures agreement with the map, and it moves with the grid: refining a mesh lowers \(h_{obs}\) and raises \(r_{optim}\) at constant agreement. Two verdicts are comparable when their validity lengths are.

  • Tail statistics. Reading \(r_{optim} \leq 2\) as “the typical gap is under two cells” is wrong when the median distance is zero.

  • The surface is not repaired. dem_correc_type conditions the DEM before the catchment is delineated (fill, the tool of the paper, or breach [Lindsay, 2016], or capped_breach). A DEM declared state = "conditioned" on its source is treated as provided: HydroModPy skips the conditioning and still computes the D8 directions and the accumulation. The criterion always floods the model top on the mesh; a breached raster reaches it only through the domain and the outlet.

  • The recharge of the steady stage. The protocol averages it over the window the run loads, three years in example 04, where the paper reads a normal of sixty years, 1960 to 2019. It is a declared departure, and \(K\) is only readable with the \(\bar N\) and the window printed beside it. Write a long steady_window when the forcing covers one. A window across 31 July 2015 reads a break of the SIM2 product: the summer drainage over example 04 no longer falls under 0.3 mm/day after it (The daily soil reservoir).

  • The visible flow. In one state the simulated network is the closure of the sources, whatever it carries. A visible flow exists in a transient run only, in the two-bound mode and in the persistence figures, which apply calibration.outputs.<name>.model.extent.visible_flow (How the model makes streams), so such a figure and a one-state score do not read the same network.

  • The two-bound mode is outside the protocol. The protocol scores its network output at its steady stage, and an extent table is refused on a steady search. Its transient stage scores the hydrograph alone. A two-bound search is written by hand.

  • Intermittent reaches. A complete map mixes the reaches that flow all year with those that flow part of it. A one-state output scores it against one state, so an intermittent reach counts as if it flowed in that state. Only calibration.outputs.<name>.map.permanent and the two-bound mode separate the two, and only when the source says which reach is permanent. The code does not know when an intermittent reach flows.

  • The resolution of the DEM. The model top and the descent \(D\) come from the DEM, so the simulated network cannot sit closer to a talweg than the DEM places it. A mesh finer than the DEM does not place it better. Under the heads rule the map is drawn on the same descent and shares that error. Under crossing or touch it is drawn where the lines are, so a talweg the DEM shifts leaves a distance that no parameter closes.

  • Tracing error and snapping. The cost reads the mapped lines as exact. calibration.outputs.<name>.map.position_accuracy enters the validity length only. Under the heads rule a head lands up to calibration.outputs.<name>.map.heads.radius from its point, on a cell that drains at least calibration.outputs.<name>.map.heads.min_drained_area. A head that lands in the next talweg, or is lost, changes the drawn map, and no part of that uncertainty is carried into the score.

  • Domain of validity. The method was built for unconfined aquifers in a temperate humid climate, with gentle gradients and a strong groundwater-stream connection. Outside that, the criterion still computes, and it means less.

Measured#

A twin with six heads. A comb basin of 5600 cells of 20 m makes a network one cell wide at \(K/\bar N = 600\), and that network, written as a map of six lines, is the truth. The protocol finds \(K\) again to 0.45 per cent on MODFLOW-NWT, MODFLOW 6 and a Voronoi mesh, with \(J = 0\), inside a band of 3 per cent that the width of the zero plateau and the stop of the search set. A map drawn at another \(K\) gives that \(K\). A wrong map moves the answer, and the last two rows below are what a balanced \(J\) does not show:

The map

\(K\) off by

\(D_{optim}\)

\(r_{optim}\) valid

The truth

0.45 %

0 m

yes

One head missing

6.5 %

2.2 m

yes

All valley heads three cells low

8.6 %

0.3 m

yes

All valley heads five cells south, three valleys shorter and two longer

2.4 %

6.0 m

yes

200 m off, five of six heads lost

a factor of 9.6

0 m

yes

The bound of two cells passes every row, so it does not check a map. Read \(D_{optim}\) against zero on a twin, and n_heads_lost on any run: a lost head logs a warning, because the reach under it leaves the map and \(K\) reads higher. A map that wanders a cell off its talwegs below its heads gives the same \(K\) to the last bit under the heads rule, and \(K\) 11.6 per cent low under the crossing rule.

On the Nançon. The default grid of 27 004 cells, protocol 1.3, recharge over 2000 to 2002, with the 29 heads the cut map holds, none lost (31 under D4), is below. One root over four decades of \(K\) in each case.

Case

\(K\) (m/s)

Sy

NSE

\(J\) (m)

\(D_{optim}\) (m)

Mapped cells

\(K\) where \(\lvert J \rvert\) is under one cell

Heads, D8

1.01e-4

0.0253

0.9580

-1.46

105.0

471

7.82e-5 to 1.09e-4

Crossing, D8

1.06e-4

0.0253

0.9576

2.63

112.2

496

7.65e-5 to 1.26e-4

Heads, D4

8.82e-5

0.0253

0.9588

2.89

98.0

659

8.11e-5 to 1.13e-4

The two rules agree on \(K\). The 5.5 per cent between them is about the size of the tie under heads, where trials from 1.01e-4 to 1.06e-4 m/s read the same \(J\). Heads misses 99 cells and adds 167 where crossing misses 195 and adds 232, and its root is no sharper: \(\lvert J \rvert\) stays under a tenth of a cell over about 6 per cent of \(K\) under both rules.

D4 moves \(K\) by 12.4 per cent, far more than the tie. Its root sits just above a step of the curve, where \(J\) falls by 62 m over 0.2 per cent of \(K\), and \(D_{optim}\) is not comparable, because the walk differs. It draws 40 per cent more cells, and its catchment leaves the outline by 1.1 per cent against 0.2. On a twin whose valleys run along the grid diagonal it leaves the outline by 17 per cent, which the bound refuses, and with the bound lifted it lands 4.5 per cent off against 2.4 per cent for D8. On valleys along the grid axes the two are equal.

The hydrograph does not decide. NSE moves by 1.2e-3 over these three values of \(K\), and Sy stays within the 5 per cent the search stops on.

The visible flow. In the two-bound mode, \(K\) depends on the flow a reach must carry to count as a stream. On the Nançon with the BD Topage maps, the mean of the two roots is 1.73e-5, 1.29e-5 and 7.80e-6 m/s at 0.5, 1 and 2 L/s, a factor of 2.2. Most of it comes from the root on the complete map, 4.97e-6, 2.95e-6 and 1.32e-6 m/s, because \(\lvert J \rvert\) stays under one cell over half a decade of \(K\) or more there. The root on the permanent map moves less, 6.01e-5, 5.61e-5 and 4.61e-5 m/s, but its \(D_{optim}\) is over 260 m, past the bound of 150 m. The two roots lie 1.1 to 1.5 decades apart, so their mean meets neither map. Quote each root with its visible flow.

K and Sy on two maps. A twin whose two maps come from a run at a known \(K\) and Sy finds \(K\) to a few per cent. It does not find Sy. Over a factor of 16 in Sy, \(\lvert J \rvert\) stays under one cell on both maps at the true \(K\), and two of three search methods return a Sy near 80 per cent high. Where the two maps are nearly the same, \(K\) lands 32 per cent high and Sy 70 per cent low at a cost of zero. On the Nançon only the permanent root follows Sy, with a slope of 0.61 in log-log. The two roots meet at \(K\) = 9.1e-6 m/s and Sy = 0.0040, which is below the usual range. There NSE falls from 0.96 to 0.77 and the NSE on log discharge from 0.98 to 0.43. So the route is allowed, and it is not recommended. A minimiser on one parameter is refused, because the same trials give 1e-7 m/s, the search bound, where the root search gives 1.29e-5.

The step of D4. The 12.4 per cent of D4 comes from one cell. It lies on a hillslope at 170 m, and it dries between \(K\) = 8.697e-5 and 8.715e-5 m/s. With it go 37 cells of stream under D4 and 27 under D8, all absent from the map. Under D4 this takes \(J_{signed}\) from +65 to +3.0 m, within 3 m of zero, and the root falls just above it. D8 loses the same cell at the same \(K\), and \(J_{signed}\) stays positive, from 83 to 34 m. A solver closure a hundred times tighter gives the same \(J\), so the step belongs to the model and not to the solver. Under D4, \(K\) is set by that one cell, and its narrow band is apparent precision.

Comparing structures. Two structures compare only at an equal balance, so a plain bisection closes the root of \(J\) at each one and gives its \(D_{optim}\). On the Nançon, thicknesses of 10 to 90 m give \(D_{optim}\) of 142, 168, 107, 112 and 123 m, each in 24 solves at a width of 8, except 10 m, whose root lies above the search bound of \(K\) and costs 27. Between 17.3 and 90 m, \(K \cdot \bar B\) stays within 13 per cent, as the ratio \(T/\bar N\) predicts. One step of \(J\) moves \(D_{optim}\) by 30 m at 17.3 m, so a smaller gap between two structures says nothing. Scoring \(D_{optim}\) without the balance finds 105 m at \(J\) = +24 m, with a network 21 per cent longer than the map.

Triangles. The twin has no triangle column. With XT3D and Newton, MODFLOW 6 keeps cycling by 2 to 5 cm on one border triangle, whatever the under-relaxation. Without Newton it closes, and the side triangles then seep beside the talweg. The network is wider than one cell, so no map of lines can equal it. The Voronoi column, whose cells follow the talwegs, passes.

Parameters of this page#

metric = ‹"rmse" | "nse" | "kge" | "mae" | "nse_log" | "nse_delta" | "nse_seasonal" | "reservoir" | "distance_gap" | "distance_mean" | "bfi_error"›Metric that scores this block against its observations. required experimental
Path
calibration.objective_blocks.metric
Values
  • "rmse" : Root-mean-square error, in the observed unit; penalizes large misfits most.
  • "nse" : Nash-Sutcliffe efficiency against the observed mean; the standard choice for a level or discharge series.
  • "kge" : Kling-Gupta efficiency, 2009 form (bias as the ratio of sums, variability as the ratio of standard deviations); separates correlation, variability and bias when NSE alone is ambiguous.
  • "mae" : Mean absolute error, in the observed unit; less sensitive to outliers than RMSE.
  • "nse_log" : NSE on log-transformed series; weights low flows as heavily as peaks, good for recessions.
  • "nse_delta" : NSE on the increments of the series rather than its level; a level is an integral and can hide flux errors that compensate, which only its increments show.
  • "nse_seasonal" : NSE against the seasonal cycle rather than the overall mean; asks whether the model beats climatology.
  • "reservoir" : Half nse_seasonal plus half nse_delta, built for an impounded level: a plain NSE there is beaten by the seasonal cycle, and the increments are what carry the flux errors.
  • "distance_gap" : Balances the simulated stream network against the mapped one; zero marks the crossing.
  • "distance_mean" : Mean spatial offset between simulated and mapped streams; a diagnostic, not a substitute for distance_gap.
  • "bfi_error" : Distance between the simulated and observed baseflow indices (Wallingford, daily discharge only); asks whether the stream is fed by its aquifer in the right share. Blind to volume and timing, so it goes beside a fit, never alone.
Accepted
"rmse" | "nse" | "kge" | "mae" | "nse_log" | "nse_delta" | "nse_seasonal" | "reservoir" | "distance_gap" | "distance_mean" | "bfi_error"
variable = "head"Simulated variable to extract (e.g. 'head', 'outlet_discharge'). required experimental example value
Path
calibration.outputs.<name>.variable
Accepted
string
Example
"head"
# complete = ‹"data.hydrography" or path›The complete map, every mapped reach: a vector file, read only from here, or 'data.hydrography', the network the hydrography data family loaded (a local file or an osm / bdtopage / euhydro download), clipped to the delineated catchment. varies by site experimental
Path
calibration.outputs.<name>.map.complete
Values
  • "data.hydrography"
Accepted
"data.hydrography" or path
Varies by site
yes: in a project of many sites, bind it to a column with sites.bind or set it in a per-site overlay; a literal value is refused
Was
calibration.outputs.stream_geometry_path, calibration.outputs.observed_network
# permanent = ‹"data.hydrography" or path›The permanent map, the reaches that flow all year, which the complete map contains: a vector file, read as it is and never filtered by attribute, or 'data.hydrography', the permanent reaches the hydrography data family wrote beside its network. experimental
Path
calibration.outputs.<name>.map.permanent
More

A source that does not say which reaches flow all year gives none. The complete map scored is the union of the two, and the share of this map outside the complete one is published.

Values
  • "data.hydrography"
Accepted
"data.hydrography" or path
Was
calibration.outputs.minimal_stream_geometry_path, calibration.outputs.minimal_observed_network
# drawn_by = "crossing"How the map is drawn on the mesh cells. experimental
Path
calibration.outputs.<name>.map.drawn_by
More

'crossing', the default, draws the map as the data gives it: it keeps the cell holding each point where a line crosses the segment joining two edge-sharing cell centres. On a structured grid it reproduces WhiteboxTools VectorLinesToRaster, the paper's tool, and draws the map one cell wide like the simulated network, so a model that matches the map scores J = 0. 'touch' keeps every cell the line touches, corners included, and replays a session made before 2026-09; it thickens every diagonal step of the map and departs from the paper. 'heads' keeps only the free ends of the map whose largest drained area within 'heads.radius' does not exceed that of the other end of their reach, lands each on a nearby cell and draws the rest down the criterion's own descent: the field ditches and rectified reaches below a head stop counting as model error, and the drawn map reaches the outlet. 'heads' does not suit a map that is not a tree: canals, braids, polders, karst.

Values
  • "heads"
  • "crossing"
  • "touch"
Accepted
"heads" | "crossing" | "touch"
Was
calibration.outputs.observed_rasterization
# clip_to_catchment = trueCut the map to the delineated catchment before drawing it, with the shape the hydrography data family clips what it loads to, so a file and 'data.hydrography' draw the same map from the same data. experimental
Path
calibration.outputs.<name>.map.clip_to_catchment
More

Under 'heads' an end the cut made is no stream head. false reads a file whole and takes every free end as a candidate head.

Accepted
true | false
Was
calibration.outputs.clip_map_to_catchment
# position_accuracy = ‹number or "<n> m"›Positional accuracy of the map. m experimental
Path
calibration.outputs.<name>.map.position_accuracy
More

It enters the automatic validity length only, so it is refused beside a 'verdict.validity_length' written as a length: the cell size h there is max(h_obs, this), because a map is not placed better when the mesh is refined. r_optim stays D_optim / h_obs, the paper's Eq. 3. Unset is the literal reading of the paper.

Accepted
number or "<n> m" (a bare number is read in the canonical unit)
Unit
m
Was
calibration.outputs.observed_position_accuracy
# seepage_threshold = 0.0001A cell releasing less than this fraction of the mean basin recharge, taken over its own area, is not a seepage face. - >= 0 experimental
Path
calibration.outputs.<name>.model.seepage_threshold
More

Zero reproduces the purely geometric criterion of the paper. Frozen over the whole search: a threshold moving with the trial would cost the criterion its monotonicity.

Accepted
number
Valid range
>= 0 (refused outside)
Unit
-
Was
calibration.outputs.tau_specific_ratio
# weighting = "cell"Average one cell one vote (the paper) or weighted by cell area. experimental
Path
calibration.outputs.<name>.model.weighting
More

Both values are always reported; use 'area' on a mesh refined along the streams, where cell density is highest exactly where distances are smallest.

Values
  • "cell" : Every cell counts once in the average, as in the paper.
  • "area" : Every cell counts in proportion to its area.
Accepted
"cell" | "area"
Was
calibration.outputs.weighting
# neighbours = "D8"The graph the descent walks. experimental
Path
calibration.outputs.<name>.model.neighbours
More

'D8' descends over shared nodes, the eight neighbours of a quad mesh, and is the paper: its distances are traced by WhiteboxTools on a D8 pointer, and the delineation that produced the catchment uses one too. 'D4' descends over shared edges only and departs from the paper. It is not a second-decimal choice: on a synthetic valley whose talweg runs along the grid diagonal, the most accumulated cell collects 100 per cent of the domain over shared nodes and 6.6 per cent over shared edges. On a mesh whose faces are not all quadrilaterals no cell has a diagonal and the descent walks shared edges either way; on a Voronoi mesh the two graphs are the same one.

Values
  • "D8"
  • "D4"
Accepted
"D8" | "D4"
Was
calibration.outputs.diagonal_neighbors
# radius = 100.0The largest distance, a length (a bare number is in metres), between a mapped stream head and the centre of the cell it lands on. m experimental
Path
calibration.outputs.<name>.map.heads.radius
More

A head with no landing cell that close is lost, draws nothing and is counted in n_heads_lost.

Accepted
number or "<n> m" (a bare number is read in the canonical unit)
Unit
m
Was
calibration.outputs.heads_snap_radius
# min_drained_area = 0.02The drained area a cell needs before a head may land on it, so a head next to its valley lands in the valley and not on the ridge cell beside it. km2 >= 0 experimental
Path
calibration.outputs.<name>.map.heads.min_drained_area
Accepted
number
Valid range
>= 0 (refused outside)
Unit
km2
Was
calibration.outputs.heads_min_drained_area_km2
[calibration.outputs.<name>.verdict]
# validity_length = "auto"Validity bound of Eq. 4, a length: the calibration is valid when D_optim <= this. m experimental
Path
calibration.outputs.<name>.verdict.validity_length
More

'auto' is 2 h, the paper's two cells, where h is h_obs, the cell size on the mapped network, raised to 'map.position_accuracy' if that is declared. A length such as '150 m' is used as it is. The bound qualifies the result and never penalises the cost.

Values
  • "auto"
Accepted
"auto" or number or "<n> m" (a bare number is read in the canonical unit)
Unit
m
Was
calibration.outputs.validity_length
# on_invalid = "warn"What a violation of Eq. 4 does: D_optim above 'validity_length'. experimental
Path
calibration.outputs.<name>.verdict.on_invalid
More

The bound is read once, on the trial the search returns, as the paper reads it at the optimum, and on each bound in the cost of the two-bound mode; every trial still records 'r_optim', 'r_optim_valid' and 'validity_length_m'. 'warn' logs it and returns the value, because a calibration is asked for a number. 'error' raises after the session is saved, so a staged calibration freezes nothing and runs no phase that depends on this one.

Values
  • "warn"
  • "error"
Accepted
"warn" | "error"
Was
calibration.outputs.on_roptim_violation
# max_catchment_mismatch = 0.05Largest gap allowed between the scored catchment and the delineated one, as a share of the delineated area: 'catchment_mismatch', the area of their symmetric difference over the area of the outline the mesh followed. >= 0 experimental
Path
calibration.outputs.<name>.verdict.max_catchment_mismatch
More

It depends on the geometry alone, so it is read once, before the first solve, and a gap above it refuses the search. A large gap means an outlet on another branch, or a mesh too coarse for the catchment. false never refuses, and the gap is still published on every trial. A synthetic domain has no delineated catchment and is never refused.

Values
  • false no explanation
Accepted
number or false
Valid range
>= 0 (refused outside)
# alpha_warning_threshold = 0.9Below this value of 'alpha_obs_closure_catchment' the run warns that its distances carry a top-versus-map disagreement on top of the hydrogeology. alpha is the share of the downstream closure of the mapped network the network itself covers, measured on the MODEL TOP and on the catchment. ]0, 1] expert experimental
Path
calibration.outputs.<name>.verdict.alpha_warning_threshold
More

It changes nothing that is computed: the criterion is scored the same way above and below it.

Accepted
number
Valid range
]0, 1] (refused outside)
Was
calibration.outputs.alpha_warning_threshold
# method_options = {}Options of the method, named as that method names them: points_per_dim for 'grid', sampler for 'optuna', sweep_points for 'bisection'. experimental
Path
calibration.method_options
More

They belong to one method, so a calibration that gives them writes method beside them. A key the method does not take is refused when the file loads.

Accepted
table { key = any value }
Was
calibration.optimizer_kwargs
# dem_correc_type = "fill"How the DEM is conditioned before the catchment is delineated.
Path
geographic.dem_correc_type
More

'fill' (default) only raises cells: each closed depression is raised to its spill level, then a small gradient on the flats lets every cell drain. 'breach' mostly lowers cells: it carves a path through the barrier that closes a depression, after raising single-cell pits to their lowest neighbour, with no limit on length or depth and no fill afterwards (least-cost breaching, Lindsay 2016); it changes far fewer cells than 'fill' and can dig deep. 'capped_breach' lowers and raises: it breaches only within the limits of [geographic.capped_breach] (a maximum cumulative lowering and a maximum length, in metres), then fills every depression the limits refused (the hybrid of Lindsay 2016). The depth limit is a sum over the cells of a path, so it does not give the same landscape at every grid resolution. 'fill' is the default because it is the tool of the paper behind the network criterion (FillDepressions, Abherve et al. 2023), and the criterion itself fills the model top on the mesh by a priority flood: one conditioning rule from the DEM to the score. A DEM declared state = "conditioned" on its [[data.dem.sources]] entry is already conditioned, so this key is ignored and the run records 'provided'.

Values
  • "breach"
  • "fill"
  • "capped_breach"
Accepted
"breach" | "fill" | "capped_breach"
[solver]
# drain_bed_thickness_m = 1.0Metres. m > 0 expert
Path
solver.drain_bed_thickness_m
More

Thickness of the drain BED in the fallback conductance C = K * cell_area / bed_thickness, used when no drainage conductance is declared. A drain bed is the clogging layer at the bottom of a watercourse, decimetres to a metre; it is NOT the aquifer, and the layer thickness this used to borrow (tens of metres) has no physical relation to it. The value matters because it sets how much head the drain itself imposes to pass the recharge: dh = R * bed_thickness / K, independent of the cell size. For R = 439 mm/yr, 30 m gives 4.17 m of head at K = 1e-7 m/s and makes the drain the limiting resistance over two decades of a [1e-7, 1e-3] search; 1 m gives 13.9 cm and 0.1 m gives 1.4 cm. In this method the drain is a seepage face, so it must never limit: K and the recharge decide where water surfaces, not the boundary condition. Proportionality to K is preserved either way, so the K/R invariance the network criterion rests on is untouched. The value 1.0 is a convention with no measured source: no measurement and no document gives it, and it is kept as it is so that no earlier result moves. It stays in [solver], whatever the layer of the other drain keys. Write your own value when you have a measure.

Accepted
number
Valid range
> 0 (refused outside)
Unit
m
Example
1.0, 0.5, 0.1

Lines generated from the models, as in the reference. Open one for its card.

The keys of a calibration on a network are in [calibration.outputs].

Checked by#

The tests that import the code of this page. The box is generated: a new test appears here on the next build.

In the code#

What

Where

The flood on the mesh graph

hydromodpy/catchment/drainage/filling.py

The receivers and the distance to a set

hydromodpy/catchment/drainage/distance.py

The outlet, the catchment, \(h_{obs}\), \(V\), the supports

hydromodpy/catchment/stream_network/geometry.py

The heads rule

hydromodpy/catchment/stream_network/heads.py

The crossing rule

hydromodpy/mesh/cells/crossed_by_lines.py

The means and the criterion

hydromodpy/catchment/stream_network/cost.py

The two estimators

hydromodpy/calibration/criteria/hydrographic_network_distance.py

The root search

hydromodpy/calibration/optim/adapters/bisection_adapter.py

See also#