scippneutron.smoothing.smooth_relative#
- scippneutron.smoothing.smooth_relative(data, *, scale, kernel='gaussian', tail=1e-12, max_grid_points=1000000)[source]#
Smooth sampled data with a kernel of relative width.
The kernel describes a distribution of relative displacements
Z, with displaced coordinates given byx' = x * (1 + scale * Z). At the boundaries, the kernel is renormalized over the available finite input domain.Input that is not geometrically spaced is interpolated to a geometric grid, smoothed, and interpolated back to the original coordinates.
- Parameters:
data (
DataArray) – One-dimensional data to smooth. Must have a positive, strictly increasing dimension coordinate.scale (
float|Variable) – Finite, non-negative, dimensionless scale factor for the relative-displacement distribution. May be a real number or a scalar, dimensionless variable. Set to zero to return a copy of the input without smoothing.kernel (
smoothing._Kernel(types.str | scippneutron.smoothing._Distribution[str, _Distribution]), default:'gaussian') – Kernel distribution. The canonical names are'gaussian','boxcar', and'triangular'. They represent a standard normal distribution, a uniform distribution on [-1, 1], and a symmetric triangular distribution on [-1, 1], respectively. Other aliases are accepted. Alternatively, provide a fully specified distribution withcdf,ppf, andsupportmethods.tail (
float, default:1e-12) – Total probability omitted when truncating a kernel with unbounded support or support reaching the nonpositive coordinate domain. Must be strictly between zero and one.max_grid_points (
int, default:1000000) – Intermediate geometric grids no larger than this are always allowed. Larger grids may be rejected to guard against excessive resampling.
- Returns:
DataArray– Smoothed data. Coordinates and units are preserved. Points where no kernel mass falls inside the input domain are NaN; this can occur at the boundaries for one-sided kernels.- Raises:
ValueError – If the inputs have invalid values, if a data array has masks, if a string does not identify a supported kernel, or if the required intermediate grid exceeds
max_grid_points.scipp.DimensionError – If the input is not one-dimensional or
scaleis not scalar.scipp.CoordError – If a data array has no dimension coordinate or has a bin-edge coordinate.
scipp.DTypeError – If
datais binned.scipp.UnitError – If
scaleis a variable with a non-dimensionless unit.scipp.VariancesError – If the signal or
scalehas variances.TypeError – If
datais not a data array,scaleis neither a real number nor a variable,kernelis not a distribution-like object, ormax_grid_pointsis not an integer.
- Warns:
UserWarning – If the data contains NaNs or infinities, since smoothing may fall back to a slower method.