pylabrobot.utils.interpolation.interpolate_1d#
- pylabrobot.utils.interpolation.interpolate_1d(x: float, data: Dict[float, float], *, bounds_handling: Literal['error', 'clip', 'extrapolate'] = 'error', method: Literal['linear'] = 'linear') float#
Perform one-dimensional interpolation or extrapolation over calibration data.
This function estimates a continuous value between (or beyond) known calibration points using one-dimensional interpolation. Currently, only linear interpolation is implemented; additional methods such as cubic or spline interpolation will be supported in the future.
- Parameters:
x (float) – The input value to interpolate.
data (Dict[float, float]) – A dictionary mapping known x-values to corresponding y-values. The keys must form a monotonically increasing sequence.
bounds_handling (Literal['error', 'clip', 'extrapolate']) – Defines how to handle x-values outside the calibration range: - “error”: Raise ValueError (strict physical bounds; default) - “clip”: Return the nearest boundary value - “extrapolate”: Extend linearly using the first or last segment slope
method (Literal['linear']) – Interpolation method to use: - “linear”: Piecewise linear interpolation (default) - “cubic”: Cubic interpolation (not yet implemented) - “spline”: Spline interpolation (not yet implemented)
- Returns:
The interpolated or extrapolated y-value.
- Raises:
ValueError – If the calibration data is empty or x is out of range and bounds_handling=”error”.
- Return type: