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 points has nvariate dimensions it is interpreted as a scalar field and the codomain dimension is set to 1. Otherwise points must have nvariate + 1 dimensions, where the last axis contains the codomain values.

tnumpy array, optional

Parameter values corresponding to points with shape points.shape[:nvariate] + (nvariate,). If None, parameter values are generated automatically from the shape of points.

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)

Multivariate splines

Multivariate splines