MultiVariateSpline
MultiVariateSpline fits weighted least-squares tensor-product B-splines to
scattered or gridded data in one or more dimensions.
This standalone package contains the complete experimental implementation, including automatic knot placement, weighted fitting, sparse fitting, derivatives, gridded input, pairwise and grid evaluation, and an optional coefficient-smoothing penalty. The smaller implementation proposed for SciPy is being reviewed separately in scipy/scipy#25472.
Installation
python -m pip install MultiVariateSpline
Install the current GitHub development version directly with:
python -m pip install \
"git+https://github.com/nikolasvalsamidis97/LSQMultivariateSpline.git"
For local development, run this from the repository root:
python -m pip install -e ".[test]"
NumPy and SciPy are installed automatically as package dependencies.
Fit In One Call
The constructor validates the data, creates the tensor-product basis, solves for the coefficients, and returns an evaluable spline:
import numpy as np
from multivariatespline import LSQMultivariateSpline
rng = np.random.default_rng(0)
x0 = rng.uniform(0.0, 1.0, 500)
x1 = rng.uniform(-1.0, 1.0, 500)
x = np.column_stack((x0, x1))
y = np.sin(2.0 * np.pi * x0) + 0.5 * x1
spline = LSQMultivariateSpline(
x,
y,
t=[6, 6],
k=(3, 3),
sparse=True,
)
Each integer in t is the requested number of polynomial pieces in that
dimension. Explicit interior-knot arrays can be passed instead.
The previous import path remains supported:
from lsq_multivariate_spline import LSQMultivariateSpline
Evaluate The Fit
Evaluate scattered or pairwise coordinates:
points = np.array([[0.25, -0.5], [0.75, 0.5]])
values = spline(points)
x0_eval = np.array([0.25, 0.75])
x1_eval = np.array([-0.5, 0.5])
pairwise_values = spline(x0_eval, x1_eval, grid=False)
Evaluate every combination of coordinate values for a surface or volume:
surface = spline(x0_eval, x1_eval, grid=True)
Fit Gridded Data
When observations already form a complete tensor grid, use from_grid:
r = np.linspace(-1.0, 1.0, 30)
w = np.linspace(0.0, 2.0, 40)
rr, ww = np.meshgrid(r, w, indexing="ij")
psf = rr**2 - ww**2
spline = LSQMultivariateSpline.from_grid(
(r, w),
psf,
t=[8, 8],
k=3,
sparse=True,
)
Development Status
This is an alpha research package. Validate knot choices and residuals for each scientific use case, especially in sparsely sampled regions. Unsupported basis functions raise an error by default.
Metadata
Release files for multivariatespline 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multivariatespline-0.1.1.tar.gz | 19.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multivariatespline-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.1 kB
Release files / multivariatespline-0.1.1.tar.gz
| Download URL | multivariatespline-0.1.1.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c940d3385a7ba8e71d8cf42fcd12ada5b9c4e3767deda78ee15615493d877d0a
|
|
BLAKE2b-256 checksum How to use checksums |
41bc08b0b354aa1f3dd10b5a331f6479ae9ff7ce7127fa9f8f9b4a0c9e59e2f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / multivariatespline-0.1.1-py3-none-any.whl
| Download URL | multivariatespline-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51054b280feae13aa8272605f73f4e4304c4b2efab0600cc9aca9d19c5a95d3e
|
|
BLAKE2b-256 checksum How to use checksums |
11e0bc11fd6dc8856e021832abba64da02a25331ecf8be011e569d9576374690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|