splinebox.multivariate.MultivariateSpline.
fit#
- MultivariateSpline.fit(points, t=None)#
Fit the multivariate spline to a set of points by least squares.
- Parameters:
- pointsnumpy array
Data to fit. If
pointshasnvariatedimensions it is interpreted as a scalar field and the codomain dimension is set to 1. Otherwisepointsmust havenvariate + 1dimensions, where the last axis contains the codomain values.- tnumpy array, optional
Parameter values corresponding to
pointswith shapepoints.shape[:nvariate] + (nvariate,). IfNone, parameter values are generated automatically from the shape ofpoints.
Examples
Fit a vector field:
>>> import numpy as np >>> import splinebox >>> spline = splinebox.multivariate.MultivariateSpline( ... M=(4, 4), ... basis_functions=splinebox.B3(), ... closed=(False, False), ... ) >>> points = np.random.rand(10, 10, 2) >>> spline.fit(points)
Fit a scalar field:
>>> spline2 = splinebox.multivariate.MultivariateSpline( ... M=(4, 4), ... basis_functions=splinebox.B3(), ... closed=(False, False), ... ) >>> scalar = np.random.rand(10, 10) >>> spline2.fit(scalar)