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 (float or str, optional, default=np.nan) – Value used for points outside the original range. This applies to both the
'linear'and'pchip'methods: a finite value fills out-of-range points with that constant, the defaultnp.nanreturns NaN outside the range, and"extrapolate"extrapolates instead.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. A target point carries over the label of an original point only when it exactly matches that point’s coordinate value (so identity, reordering and subsetting keep their labels); genuinely resampled points are left unlabelled (#1098).
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).