Natural Neighbor Interpolation in 3D
Reason this release was yanked:
buggy
Project description
Natural Neighbor Interpolation in 3D
This is a Python package for 3D natural neighbor interpolation (Sibson interpolation).
Natural neighbor interpolation is a form of scattered data interpolation, where you have a set of sample values of a function at arbitrary locations in 3D space (let's call the locations keys), and you want to interpolate the function value at other points (let's call them queries).
Specifically, in natural neighbor interpolation, the interpolated value is a weighted average of the function values of the query point's "natural neighbors", which are the vertices of the Voronoi cell that contains the query point. The weights are proportional to the volumes of the sub-Voronoi cells corresponding to each natural neighbor that we would obtain if the query point was inserted into the Voronoi tetrahedralization.
This package uses Cython to wrap my modified version of Ross Hemsley's interpolate3d. The modifications are:
- parallelization via OpenMP
- option to extract the natural neighbor weights (Sibson coordinates) directly (the original version only gives the final interpolated value, but not the weights)
- k-d tree for faster search for the containing simplex of an inserted point
Usage
Simplest is to call natinterp3d.interpolate(queries, keys, values) or natinterp3d.get_weights(queries, keys):
import natinterp3d
import numpy as np
# The positions of the data points where the function values are known
keys = np.array([[x1, y1, z1], [x2, y2, z2], ...])
# The values can also be a 2D array of shape (N, values_dim) with D dimensional vectors as values at each data point
values = np.array([v1, v2, v3, ...])
# The positions where we want to interpolate the function values
queries = np.array([[qx1, qy1, qz1], [qx2, qy2, qz2], ...])
# Returns either [num_queries] or [num_queries, values_dim], the array of interpolated values
interpolated_values = natinterp3d.interpolate(queries, keys, values)
# or get the interpolation weights as a sparse matrix of size [num_queries, num_keys] (scipy.sparse.csr_matrix)
weights = natinterp3d.get_weights(queries, keys)
For more control, e.g., if you want to interpolate queries and/or values on the same key positions, you can use the natinterp3d.Interpolator class as:
import natinterp3d
keys = np.array([[x1, y1, z1], [x2, y2, z2], ...])
interpolator = natinterp3d.Interpolator(keys)
values = np.array([v1, v2, v3, ...]) # or a 2D array of shape (N, values_dim)
queries = np.array([[qx1, qy1, qz1], [qx2, qy2, qz2], ...])
interpolated_values = interpolator.interpolate(queries, values)
# or:
weights = interpolator.get_weights(queries)
Multithreaded computation is automatically enabled. To customize, use the argument parallel=True/False and num_threads in interpolate or get_weights. With num_threads=None (default), the number of threads is automatically determined based on the available CPU cores.
License
GNU GPL v3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file natinterp3d-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: natinterp3d-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 671.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72053d4da2fd65f2e80e1ea23abf8141da0ccda9a44d815d54149a848f90a08c
|
|
| MD5 |
236d9e06487fd911e6d26871f26c666a
|
|
| BLAKE2b-256 |
acdd3f74549fe544654477312ed95ec0e5153013863ac047ec02bc47bdd81563
|
Provenance
The following attestation bundles were made for natinterp3d-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-publish.yml on isarandi/natinterp3d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
natinterp3d-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
72053d4da2fd65f2e80e1ea23abf8141da0ccda9a44d815d54149a848f90a08c - Sigstore transparency entry: 153734362
- Sigstore integration time:
-
Permalink:
isarandi/natinterp3d@0e19ccb6a353a45e9afbc64874c499916e52a023 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/isarandi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0e19ccb6a353a45e9afbc64874c499916e52a023 -
Trigger Event:
release
-
Statement type: