pymkm.utils.interpolation¶
Interpolation utilities for non-monotonic LET and specific energy data.
This module defines the Interpolator
, a general-purpose tool
for inverting and interpolating energy–LET relationships. It supports:
Monotonic and non-monotonic data
Log-log interpolation when appropriate
Mapping energy → LET and LET → energy (including one-to-many inversion for non-monotonic curves)
The main use case is microdosimetric table construction, where interpolation of stopping power curves is needed in both directions.
Examples
>>> interp = Interpolator(energy_array, let_array, loglog=True)
>>> let_vals = interp.interpolate(energy=[10, 100])
>>> energy_vals = interp.interpolate(let=[5.2])
- class pymkm.utils.interpolation.Interpolator(energy: ndarray, values: ndarray, loglog: bool = False)[source]¶
Bases:
object
General-purpose interpolator for LET or specific energy curves.
Supports non-monotonic data by segmenting the input and optionally applies log-log interpolation when both axes are positive.
- interpolate(*, energy=None, let=None)[source]¶
Interpolate LET or energy values depending on the input.
- This is a unified interface for:
Energy → LET interpolation (using energy input)
LET → Energy interpolation (using let input)
- Parameters:
energy (float or array-like, optional) – Energy value(s) at which to interpolate LET.
let (float or array-like, optional) – LET value(s) at which to interpolate energy.
- Returns:
If energy is provided, returns an array of LET values.
If let is provided, returns a dict mapping each LET value to an array of energy values.
- Return type:
np.ndarray or dict[float, np.ndarray]
- Raises:
ValueError – If both energy and let are provided, or if neither is provided.