Skip to main content

Natural Neighbor Interpolation in 3D

Project description

Natural Neighbor Interpolation in 3D

PyPI - Version

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". The natural neighbors of a query point are those vertices which, if we were to add the query point to the data, would have Voronoi cells sharing a face with the query point's Voronoi cell. The weights are proportional to the volume "stolen" from the neighbor's Voronoi cell upon the query point's insertion.

The Delaunay tetrahedralization is built on Ross Hemsley's interpolate3d (incremental Bowyer-Watson insertion with flip-based convexity repair and Shewchuk's robust geometric predicates).

The interpolation itself is a from-scratch insertion-free algorithm: instead of inserting each query point into the mesh and removing it (as in Hemsley's original), it finds the Bowyer-Watson cavity via read-only BFS on the existing mesh and computes the stolen Voronoi volumes geometrically from circumcenters. This means the mesh is never modified during queries, so a single shared mesh serves all threads.

Other changes from the original:

  • OpenMP parallelization with a single shared mesh (no per-thread mesh copies)
  • Morton-order (Z-order) spatial sorting of query points for cache locality
  • Contiguous packed simplex array for cache-friendly BFS traversal
  • k-d tree for fast initial simplex location
  • Sibson coordinates (weights) returned directly as a sparse matrix

Installation

natinterp3d is available on PyPI:

pip install natinterp3d

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

natinterp3d-1.0.7.tar.gz (136.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

natinterp3d-1.0.7-cp313-cp313-win_amd64.whl (142.9 kB view details)

Uploaded CPython 3.13Windows x86-64

natinterp3d-1.0.7-cp313-cp313-manylinux_2_28_x86_64.whl (741.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.7-cp312-cp312-win_amd64.whl (143.0 kB view details)

Uploaded CPython 3.12Windows x86-64

natinterp3d-1.0.7-cp312-cp312-manylinux_2_28_x86_64.whl (752.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.7-cp311-cp311-win_amd64.whl (143.1 kB view details)

Uploaded CPython 3.11Windows x86-64

natinterp3d-1.0.7-cp311-cp311-manylinux_2_28_x86_64.whl (738.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.7-cp310-cp310-win_amd64.whl (142.9 kB view details)

Uploaded CPython 3.10Windows x86-64

natinterp3d-1.0.7-cp310-cp310-manylinux_2_28_x86_64.whl (730.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file natinterp3d-1.0.7.tar.gz.

File metadata

  • Download URL: natinterp3d-1.0.7.tar.gz
  • Upload date:
  • Size: 136.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for natinterp3d-1.0.7.tar.gz
Algorithm Hash digest
SHA256 0ec64c7ea68b94ff055c3e4f2c159224c6eba3ad8de9612d13612fc61aa68675
MD5 1ca5994f6bf1c8a0d179073ed646bb4b
BLAKE2b-256 b492a628a40b263322a7541785a347a2bb97009f6d7d33fd8ffbd361224bbfc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7.tar.gz:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 892dc6dbc9ac383755087808dcf7c9e4b62a23f74131dc7214f84b9643f85e4e
MD5 79ca04c4a214b2050c522fc1bad7fbba
BLAKE2b-256 e7f478ac44df9066b1044a3687738d9558f6b6fc92138ff2928a3c20b047e6c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp313-cp313-win_amd64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cf504a81dd98c2e1c8a15c19416cbf5f7ab4561a62109eaf2d6490d8d7db6e40
MD5 0e8de2b855ec11ea6039986666bf1dfe
BLAKE2b-256 017ebcf83eeeaf27f887402cbee564ab480a20c5c849e0df956426dffff7b015

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1059bafcc3380f1ba7a9c0a02193ef7eaa4084887b0e417f97d2916b72a906c8
MD5 aebd0063a3b7c57d68434e6e12fc4e0e
BLAKE2b-256 b6cf51eaf45d0aa4e74f965ed5aee64332d15cba4fced6bcc01baec4dfec121e

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp312-cp312-win_amd64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e2ef14b539ff64d73ff8c0d546f26c7ef0c824b46d8698427492df1f97e422b7
MD5 370d5d226ee9ffdc80142b6d8343250c
BLAKE2b-256 2b2dfced625073220a48a4800b927576a0ca1c8218557338e93fa62cad585138

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7536eb640ed4e973c9fd9518a4d470bb9748781d83d49648f11b0b2252236981
MD5 96553d30beabbe41ca50e4e52a4c29b5
BLAKE2b-256 cca223a68ee93ddedbfd40437054dedf7e496853433339e90565c3ef07cc5039

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp311-cp311-win_amd64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4760af587bd410dc090061d93d9f3d3f629d5a00996939bd821ab39f08973e2
MD5 564e9986ddddb0e2b042f636230e5670
BLAKE2b-256 2b17a96c87973baaae8b785d36dac48eaab6decd452c1740882ff86c34ae74a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6dca123456547db4d3e38384213e8ef62f3b1d9d7255af9240455214497272be
MD5 59954460cd8fd9c72e381cc30bb1ee2a
BLAKE2b-256 a891ab0d0ff0faa19585a1dd71e9965fbcf6a5a2bf9097ae1c4afe2a4454df4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp310-cp310-win_amd64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file natinterp3d-1.0.7-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4e147fbc105f154f5c86a32442a2986c13eb5bacfe12627dd36fb8054478803
MD5 18da941a31301be725028583a9ec3091
BLAKE2b-256 ff34fb505337ae7baac27538ada168000b53c8602473e8ae45c17c3657a6c387

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.7-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on isarandi/natinterp3d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page