spectrochempy.interpolate
- interpolate(dataset, dim=None, dims=None, coord=None, method='linear', fill_value=np.nan, assume_sorted=False, inplace=False)[source]
Interpolate dataset onto new coordinates.
- Parameters:
dataset (NDDataset) – Dataset to interpolate.
dim (str or int, optional) – Single dimension name or index.
dims (list of str or int, optional) – List of dimensions to interpolate. Higher priority than dim.
coord (Coord, np.ndarray, NDDataset, or dict, optional) – Target coordinates. If dict, maps dim -> coord. For single dim: can be Coord, ndarray, or NDDataset. For multiple dims: dict {dim: coord} or sequential application.
method (str, optional, default=’linear’) – Interpolation method: ‘linear’ or ‘pchip’.
fill_value (any, optional, default=np.nan) – Value for points outside the original range.
assume_sorted (bool, optional, default=False) – If True, skip monotonicity checks.
inplace (bool, optional, default=False) – If True, modify the dataset in place.
- Returns:
NDDataset – Dataset with interpolated data and updated coordinates.
- Raises:
TypeError – If coordinate is not numeric.
ValueError – If coordinates are not strictly monotonic.
Notes
Labels are NOT interpolated and are reset after interpolation.
For multiple coordinates per dimension, all are interpolated consistently.
Secondary coordinates are interpolated numerically. If they represent analytical transformations of the primary coordinate (e.g., wavelength = 1/wavenumber), the result may be approximate - consider recomputing them analytically after interpolation.
Unit conversion is performed if needed before interpolation.
Sequential interpolation is applied for multiple dimensions (not true N-D).