sec_interp.core.utils.sampling module

Sampling utilities (pure math).

sec_interp.core.utils.sampling.interpolate_elevation(topo_data: list[tuple[float, float]], distance: float) → float

Interpolate elevation at a given distance along the topography profile.

Uses linear interpolation between the two nearest sampled points.

Parameters:
  • topo_data – List of (distance, elevation) tuples.

  • distance – Horizontal distance along the section.

Returns:

The interpolated elevation value (Z) at that distance.

sec_interp.core.utils.sampling.smooth_profile_by_distance(data: list[tuple[float, float]], window_m: float, passes: int = 1) → list[tuple[float, float]]

Smooth a profile with a centered moving average over a distance window.

Averages the elevation of every point within window_m / 2 of each station. The first and last elevations are preserved so the ends do not drift. Returns the input unchanged when there is nothing to smooth or the window is non-positive.

Parameters:
  • data – List of (distance, elevation) tuples, sorted by distance.

  • window_m – Window width in distance units (map units, e.g. metres).

  • passes – Number of smoothing passes (>= 1).

Returns:

A new list of (distance, elevation) tuples of the same length.