Discrete Sibson (Natural Neighbor) Interpolation
Natural neighbor interpolation is a method for interpolating scattered data (i.e. you know the values of a function at scattered locations). It is often superior to linear barycentric interpolation, which is a commonly used method of interpolation provided by Scipy’s griddata function.
There are several implementations of 2D natural neighbor interpolation in Python. We needed a fast 3D implementation that could run without a GPU, so we wrote an implementation of Discrete Sibson Interpolation (a version of natural neighbor interpolation that is fast but introduces slight errors as compared to “geometric” natural neighbor interpolation).
See https://doi.org/10.1109/TVCG.2006.27 for details.
Dependencies
Python 2.7 or 3.4+
Numpy (has been tested with 1.13+)
Demonstration
Natural neighbor interpolation can be more accurate than linear barycentric interpolation (Scipy’s default) for smoothly varying functions.
Also, the final result looks better.
Note that the natural neighbor values usually are extrapolated; they were cut off in the demo to fairly compare with Scipy’s linear barycentric method, which does not extrapolate.
Usage
This module exposes a single function, griddata.
The API for naturalneighbor.griddata is similar to
scipy.interpolate.griddata. Unlike Scipy, the third argument is not a
dense mgrid, but instead is just the ranges that would have been passed to mgrid. This is because the discrete Sibson approach requires the interpolated points to lie on an evenly spaced grid.
import scipy.interpolate
import numpy as np
import naturalneighbor
num_points = 10
num_dimensions = 3
points = np.random.rand(num_points, num_dimensions)
values = np.random.rand(num_points)
grids = tuple(np.mgrid[0:100:1, 0:50:100j, 0:100:2])
scipy_interpolated_values = scipy.interpolate.griddata(points, values, grids)
grid_ranges = [[0, 100, 1], [0, 50, 100j], [0, 100, 2]]
nn_interpolated_values = naturalneighbor.griddata(points, values, grid_ranges)
Future Work
Provide options for extrapolation handling
Support floats and complex numbers (only support doubles at the moment)
Support 2D (only support 3D)
Add documentation with discussion on limitations of discrete sibson’s method
Uncomment cpplint from tox.ini and cleanup C++ code
Generalize the threading model (currently it uses 8 threads—one for each quadrant)
Metadata
Release files for naturalneighbor 0.2.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 | Provenance | |
|---|---|---|---|---|
| naturalneighbor-0.2.1.tar.gz | 10.5 kB | Without provenance | Details |
Release files / naturalneighbor-0.2.1.tar.gz
| Download URL | naturalneighbor-0.2.1.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
647b5922c3787887c04be7748f8112a1720b1323c8e86b4c6665ce7eee89aee7
|
|
BLAKE2b-256 checksum How to use checksums |
5a8898d3ee9631c333662366c405d23d49c0feaf51a8bfd4ae222534befd0759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
|
Security for naturalneighbor 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.