scipy 1.8.0 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
cspline1d(signal, lamb=0.0)

Find the cubic spline coefficients for a 1-D signal assuming mirror-symmetric boundary conditions. To obtain the signal back from the spline representation mirror-symmetric-convolve these coefficients with a length 3 FIR window [1.0, 4.0, 1.0]/ 6.0 .

Parameters

signal : ndarray

A rank-1 array representing samples of a signal.

lamb : float, optional

Smoothing coefficient, default is 0.0.

Returns

c : ndarray

Cubic spline coefficients.

Compute cubic spline coefficients for rank-1 array.

See Also

cspline1d_eval

Evaluate a cubic spline at the new set of points.

Examples

We can filter a signal to reduce and smooth out high-frequency noise with a cubic spline:

>>> import matplotlib.pyplot as plt
... from scipy.signal import cspline1d, cspline1d_eval
... rng = np.random.default_rng()
... sig = np.repeat([0., 1., 0.], 100)
... sig += rng.standard_normal(len(sig))*0.05 # add noise
... time = np.linspace(0, len(sig))
... filtered = cspline1d_eval(cspline1d(sig), time)
... plt.plot(sig, label="signal")
... plt.plot(time, filtered, label="filtered")
... plt.legend()
... plt.show()
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.signal._bsplines.cspline1d scipy.signal._bsplines.cspline1d_eval

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/signal/_bsplines.py#430
type: <class 'function'>
Commit: