Utils

Branching

Utilities for sampling lateral-root branching locations.

deeprootgen.utils.branching.sample_branch_sites(parent_xyz: ndarray, interbranch_distance: float, rng: Generator, floor_threshold: float = 0.4, ceiling_threshold: float = 0.9, max_branches: int | None = None, log_sd: float = 0.2) → list[float][source]

Sample lateral-root insertion positions along a parent root.

Parameters

parent_xyznp.ndarray

Ordered 3D coordinates of the parent root, including its basal origin and apex, in centimetres.

interbranch_distancefloat

Mean distance between successive lateral-root insertion positions, in centimetres.

rngnp.random.Generator

Random number generator.

floor_thresholdfloat

Fraction of parent-root length where branching begins.

ceiling_thresholdfloat

Fraction of parent-root length where branching ends.

max_branchesint or None

Maximum number of lateral branches. None means no explicit upper limit.

log_sdfloat

Log-scale standard deviation of interbranch spacing.

Returns

list[float]

Insertion positions measured in centimetres along the parent root’s cumulative arc length.