Skip to main content

A package for performing optimized k-NN IDW interpolation using C++.

Project description

PyTerp

A 3D interpolator for Python designed for maximum speed on large datasets. It accelerates the IDW algorithm with a parallelized C++ core (OpenMP) and optimized k-NN searches (nanoflann).

Theoretical Summary

The interpolation is performed in a two-step process that combines the k-NN and IDW algorithms.

  1. Neighbor Selection (k-NN): For each point where a value is to be estimated, the k-Nearest Neighbors algorithm first finds the k closest known source points in space. The efficiency of this search is ensured by an optimized data structure (k-d tree).

  2. Value Calculation (IDW): Next, the Inverse Distance Weighting method calculates the final value as a weighted average of the k found neighbors. The weight of each neighbor is inversely proportional to its distance (weight = 1/distanceᵖ, where p is a power parameter), causing closer points to have a much greater influence on the result.

Prerequisites

Before you begin, ensure you have the following software installed:

  • Python 3.10+
  • Git
  • A C++ compiler: This package contains C++ code that needs to be compiled during installation.
    • Windows: Install Visual Studio Build Tools (select the "Desktop development with C++" workload).
    • Linux (Debian/Ubuntu): Install build-essential with: sudo apt-get install build-essential.

Installation

PyPI

Install the package:

pip install pyterp

GitHub

1. Clone the repository:

git clone https://github.com/jgmotta98/PyTerp.git
cd PyTerp

2. Create and activate a virtual environment:

# Create the environment
python -m venv .venv

# Activate the environment
# On Windows (cmd.exe):
.venv\Scripts\activate
# On macOS/Linux (bash/zsh):
source .venv/bin/activate

3. Install the requirements:

pip install -r requirements.txt

4. Install the package:

pip install .

Usage Example

import numpy as np
import pyterp as pt

# Assuming 'source_points', 'source_values', and 'target_points'
# are properly prepared NumPy arrays.
interpolated_values = pt.interpolate(
    source_points=source_points,
    source_values=source_values,
    target_points=target_points,
    k_neighbors=10,
    power=2
)

print("Interpolated values:", interpolated_values)

For a complete and runnable example, including the creation and preparation of input data, please see the script in the examples folder.

Acknowledgements

This project uses nanoflann, a high-performance C++ library for the k-Nearest Neighbors algorithm. The efficiency of nanoflann's k-d tree implementation is fundamental to this interpolator's performance.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyterp-0.0.0-cp312-cp312-win_amd64.whl (84.0 kB view details)

Uploaded CPython 3.12Windows x86-64

pyterp-0.0.0-cp312-cp312-win32.whl (75.1 kB view details)

Uploaded CPython 3.12Windows x86

pyterp-0.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyterp-0.0.0-cp311-cp311-win_amd64.whl (83.6 kB view details)

Uploaded CPython 3.11Windows x86-64

pyterp-0.0.0-cp311-cp311-win32.whl (74.8 kB view details)

Uploaded CPython 3.11Windows x86

pyterp-0.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyterp-0.0.0-cp310-cp310-win_amd64.whl (82.4 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterp-0.0.0-cp310-cp310-win32.whl (73.8 kB view details)

Uploaded CPython 3.10Windows x86

pyterp-0.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file pyterp-0.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 84.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 003e895f7efe9f1302f711307b9bb6edf2cdc6470b59f42b62f724d5c601f85e
MD5 0bae06706f4c826970edb77ec8ac6466
BLAKE2b-256 3d3ccddc604e242526607ac1ef8c7e1824bb4784b8615a6deeae7cc2d12040c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp312-cp312-win_amd64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp312-cp312-win32.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp312-cp312-win32.whl
  • Upload date:
  • Size: 75.1 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 6f90a8dff375b29d5ce30dbfb715428f7d0b9caa3b75015ce96fa3432db86c24
MD5 6a021b570bbd898db12d26b0c41dfd0c
BLAKE2b-256 69e0d9e37e92a217d10d761839fc717a7a121837adc76be820e9b0477bc50d06

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp312-cp312-win32.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyterp-0.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88513762c539fccfdc45d2b4484796bc5b64d7e4d0fa76c43e4badcd881a1fcc
MD5 1d48e79b19ac950e8f5ee6d8417efa9d
BLAKE2b-256 8d584ef35d552d6b0e070866c1b583f6c28b3f4316eccaaebf04566f53979373

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 83.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6d526c379662d707059c9990314de46dafb39c56d3348d1ae867b9492ba782f7
MD5 d22374b3fadc27e1430beba7368db1c6
BLAKE2b-256 3f7361a76bba76acecea902eea6d449754fab6b04db0c31932b2b3a6bd14d12e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp311-cp311-win_amd64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp311-cp311-win32.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp311-cp311-win32.whl
  • Upload date:
  • Size: 74.8 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 e70286a30dad92a62c1df0987b598074ea35abe88c52ca5a195f1de1808d0abc
MD5 f6d328817e12b75a1bd6f995d54ddab4
BLAKE2b-256 9f22d88af844398476bd38feff6d3d0a1ee88330bd4bd6cc07934a3f4e8dd542

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp311-cp311-win32.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyterp-0.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00590035c1d634c016f6ef49491fb90a9c7595132f6d8373403e68a7ee2cd8f3
MD5 b2d9958a5f0c71fcd248aa77e45b9df8
BLAKE2b-256 54da7ffbbd0459c9d451d7dd59089cea1c61dc2a43492a6695a09e2248769a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 82.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 06c32fa9a0b802b4956f844717374b8022496638f9205d6bf2056b7437f05977
MD5 7b742c0ebfe2b48e58e444c71fd4e196
BLAKE2b-256 fddd49404e6548dada8243a6b5de62bda16f87ed121593476d7553359081ce91

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp310-cp310-win_amd64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: pyterp-0.0.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 73.8 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyterp-0.0.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 d18c4360e454d91698287f1c26ae28309fe1c7fcca8b720f32b1406d6b3b136f
MD5 5e76c923689bd38d85cd40a4b474540d
BLAKE2b-256 37527357d46e4cf2f474f498b40a390bb2675e3adfe613e4dea8f82932e62271

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp310-cp310-win32.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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

File details

Details for the file pyterp-0.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyterp-0.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b127435ce4cee5fe17ff828d36d798b34aed51349755f6bef42c4037bd32325c
MD5 14c5b497744deb78d1afab5d1606c429
BLAKE2b-256 999857c8dbd2c4cc95c909556838368f6f1c7eaa6bab9b0f4664f7b2520d89ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-0.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on jgmotta98/PyTerp

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