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

For a complete and runnable example, including the creation and preparation of input data, please see the scripts 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 Distribution

pyterp-1.1.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distributions

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

pyterp-1.1.0-cp310-cp310-win_amd64.whl (123.8 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterp-1.1.0-cp310-cp310-win32.whl (108.1 kB view details)

Uploaded CPython 3.10Windows x86

pyterp-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file pyterp-1.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pyterp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 17583322e57fbcfc92e88c915b25697b5ebf8799484cf601d5ea03392847dcec
MD5 14b4a76c85fcd82d6fe1a00c315d9e9b
BLAKE2b-256 ba6aba263494fb21e0aab326a6a9120b12a4661bec595d77ea42468497151536

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.1.0.tar.gz:

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-1.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyterp-1.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 123.8 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 pyterp-1.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8dc77eb47a0c3d757c5d368ce1eea550a0edfb9a402773665d28c4900f15ccba
MD5 190a5d285ead746f7d8578f2a35e9f2d
BLAKE2b-256 caa2844c61b1266741d75b46c5aa595fe740baf4e787b7f4c07d9f1965403b59

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.1.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-1.1.0-cp310-cp310-win32.whl.

File metadata

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

File hashes

Hashes for pyterp-1.1.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 abc82ce17bb0e41550d736af94ec338317d7b74c50e59b6ba5b8b06baa56492f
MD5 0e3ffffce9d6f9ae6f3d580fb1ed66c3
BLAKE2b-256 8039433f1f6f732acc40c052bac8aa21b46c01f12eaf9b39dd8669f8a11fe866

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.1.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-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyterp-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 81ef2e27d67fd7eb02429aec12e4990f9e4ea2d019b82669746040f528ac62e1
MD5 bf98033d9dc24773f6c050b5a2ca690f
BLAKE2b-256 47daff96178d7322e5290ac551dd179d052c9154509c6592dedb2abbe4dfc2bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.1.0-cp310-cp310-manylinux_2_28_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