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.9.tar.gz (137.9 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.9-cp313-cp313-win_amd64.whl (144.9 kB view details)

Uploaded CPython 3.13Windows x86-64

natinterp3d-1.0.9-cp313-cp313-manylinux_2_28_x86_64.whl (788.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.9-cp312-cp312-win_amd64.whl (145.1 kB view details)

Uploaded CPython 3.12Windows x86-64

natinterp3d-1.0.9-cp312-cp312-manylinux_2_28_x86_64.whl (796.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.9-cp311-cp311-win_amd64.whl (145.2 kB view details)

Uploaded CPython 3.11Windows x86-64

natinterp3d-1.0.9-cp311-cp311-manylinux_2_28_x86_64.whl (783.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

natinterp3d-1.0.9-cp310-cp310-win_amd64.whl (145.0 kB view details)

Uploaded CPython 3.10Windows x86-64

natinterp3d-1.0.9-cp310-cp310-manylinux_2_28_x86_64.whl (775.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

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

File metadata

  • Download URL: natinterp3d-1.0.9.tar.gz
  • Upload date:
  • Size: 137.9 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.9.tar.gz
Algorithm Hash digest
SHA256 52673d883bcf532ed8e7b41bdf0d42ff28b0dc09245920e5955ae1f6e19a4a23
MD5 289371a4f60375307b00a0fa90386277
BLAKE2b-256 29edf61f4f6c7e062c5f26ed5b173f1d94af6c1a7427a4f7bc9d7ddcdb4dd645

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: natinterp3d-1.0.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 144.9 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.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e71fd3530786599905dfa8a94ea9c04a257b9de30de90a716fa5b7d22be838e0
MD5 5f718f71677bb6d9c761502f463f4b6d
BLAKE2b-256 0662d528c392f05fc27be87f432aa3aa02baa081d48bc8faf16e11e0ea314679

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for natinterp3d-1.0.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b6afba53c3b57afd7d2d1a9e21c51d24ac55debe0ddc1dc0e2a44c2a58f72845
MD5 88484139adc14d2c178ebe4a2cb78340
BLAKE2b-256 4ec1043b31487e151fb76fd71abf77c0219aa333a4b44b701f28e40be1ac539f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: natinterp3d-1.0.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 145.1 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.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 85ebf65264b42fd6a37ff9288ffff8b255c6cf1a19868834989075fa89287698
MD5 485aced43d1f6d70f584083cb453b5d8
BLAKE2b-256 b92d1e2d25129f31ce72da29cecde5030c266b4586747e9f576f6ef5c38c4141

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for natinterp3d-1.0.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a31b66a0f45767a1991f373cca749fc68f337bdafdbab89f2c68b5d65e853aec
MD5 865bc9ee78ff4dc1598f665899d88662
BLAKE2b-256 f27803e6f0a4f03c7877ab2e32f8b3b4396cfacee9e09103cf90be830ed70eb5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: natinterp3d-1.0.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 145.2 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.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dc3ccd249be2c1e72fecf02b4277a96d6e5efe2a1e282472a89446145a3424bf
MD5 82bf3c90741329da7261f2a87b7b95ca
BLAKE2b-256 7981c4edc38e811997526f9eb1ea98d11d866d04719eff995172445555012eae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for natinterp3d-1.0.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 55a0538753046b89f57b9a430aa7e3a6d299ab2858f95419a9b2fb1181002f3a
MD5 f033d05d5f33befda739d64b30eb6ad2
BLAKE2b-256 76f6150a7d47736e2307e6698dda02a13685a2bac8bdb0631e60609c7856fd16

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: natinterp3d-1.0.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 145.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.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 da1b9fcf93c2c26b599d689d5afb22bb59c76d6479a4e5f17f6f9490ead45514
MD5 c8c74cfc46e6517e906954bf3dcbfbb8
BLAKE2b-256 a8c16a70e2881fdfbd6ac0aba6a2a47e6ab9e07139afef8a572631d42ef14022

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for natinterp3d-1.0.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a175638d18fb9eeffd0a6d009d3b7ccb42c936ef4da0ee3f86f69aad0d02ff78
MD5 aa4cb9be35534bbc39410f4f828cf82c
BLAKE2b-256 02e4cd2d2317640ebb550d2c0d20adc03d7a844ca9f821d0906b827da67dc573

See more details on using hashes here.

Provenance

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