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.8.tar.gz (136.8 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.8-cp313-cp313-win_amd64.whl (142.8 kB view details)

Uploaded CPython 3.13Windows x86-64

natinterp3d-1.0.8-cp313-cp313-manylinux_2_28_x86_64.whl (751.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12Windows x86-64

natinterp3d-1.0.8-cp312-cp312-manylinux_2_28_x86_64.whl (759.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11Windows x86-64

natinterp3d-1.0.8-cp311-cp311-manylinux_2_28_x86_64.whl (746.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.8-cp310-cp310-win_amd64.whl (143.0 kB view details)

Uploaded CPython 3.10Windows x86-64

natinterp3d-1.0.8-cp310-cp310-manylinux_2_28_x86_64.whl (737.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

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

File metadata

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

File hashes

Hashes for natinterp3d-1.0.8.tar.gz
Algorithm Hash digest
SHA256 4b7a3834ed49e1b440c14d2b345fa448e7fa579ad89f2e9fc6e7785be723ef48
MD5 50bd5720255c9df7da97eade9f108ef7
BLAKE2b-256 77d004abf03c689027b006bbf1ae277fef97bb70d0eac5569edc0215c71fe03c

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8.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.8-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: natinterp3d-1.0.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 142.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for natinterp3d-1.0.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e6d5c584f5922bb8458c87f0d7d5f413bb4c928ece500168b4a9e1210322c60d
MD5 7686a03e22adddcfe3f9fa5c51de590d
BLAKE2b-256 ff157c43d2fd175e34aacfdcec60fbe2ccbca080a300b4ba6ac98507debd19ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cbbad1bd2b014c9994264b9291eda4455c02c55058dd150f698d913e5208abf1
MD5 f305d5fc289a14d459050f7b6314696a
BLAKE2b-256 86180598b9f43a9981901772fb9f7f12c754888e7da474d47a8160ae46333d4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: natinterp3d-1.0.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 143.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for natinterp3d-1.0.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5bfa909c1add401424536d512e166f2bb2c4a1597d35a824934852e1a0f29f0c
MD5 d0f5bef7226d1db9a685d763054b4bda
BLAKE2b-256 2333663a7254e91a736a8d1ad9e0b2d8c12380cafbcbc6cda554a86938e41e21

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8438bab5b20d1e4ac059585addd913e11e1f1f0aeeeff87b6e5a0a0634f340ea
MD5 e513323cf43e957b2fcb2e32edd51cd6
BLAKE2b-256 da95860c8c841255ba76efb9ba26f189c3aaac3a507f611582408e923d0ac1a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: natinterp3d-1.0.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 143.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for natinterp3d-1.0.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 39dd9205d55c98c330322ea573a51b061a0bf2996daa9f13e1132be931947b13
MD5 429bfb1eea17d57e0b38123db42fe542
BLAKE2b-256 64cbf831b46172702b2c263a044154c84bd302e17e5929cad37a8c004d59ebbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0dc0f4da0a2d374933a8810837b303a8b7495da9ac99f3d7cc71cc1508bd575a
MD5 a6968213a9cb4435a36c7185f5458298
BLAKE2b-256 35a1cc12d223a71ed12aa48ae8f4431a1d1c2d6dc3bf2c1f1a4eb4608c297cc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: natinterp3d-1.0.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 143.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for natinterp3d-1.0.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2720bc4cfbfadec2ee6f769475176abeb01c73c18b61ea9a1139aed291cb2d39
MD5 95fee506f3637d7a824f84b2d0ff18c7
BLAKE2b-256 df6ed356c1ea1e5098a1a1989e8abcba1a0dee48e46b9f01c9a531b5bcb4dc18

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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.8-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for natinterp3d-1.0.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e24bbd77afb412dc93332a133a1f6a27a2a3491d86f81825a504bac7c4592bc
MD5 2b9be9829f6772db145779039e2d867a
BLAKE2b-256 6e297498880dd28ac27b9b6a8da856f7944e25ff1e3a28b02fd54380231517a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for natinterp3d-1.0.8-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