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.0.0.tar.gz (29.2 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.0.0-cp310-cp310-win_amd64.whl (119.6 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterp-1.0.0-cp310-cp310-win32.whl (104.3 kB view details)

Uploaded CPython 3.10Windows x86

pyterp-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pyterp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 62b00966ed763583579b0f073b245a0d3f35439dc68ae583e35a9ab45f5960df
MD5 0c29f94e3ab01a645e3493f370701873
BLAKE2b-256 f97fb2afbe8857e0003a50ecd6bd048520a8fa724dd00c4fb23d53bd1aaadb9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.0.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.0.0-cp310-cp310-win_amd64.whl.

File metadata

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

File hashes

Hashes for pyterp-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e97522194c56f6e1684f130aaa7f47211e32c2a326b87cd5b73378fb130ab9aa
MD5 20985922a021cb21520f42c76b42385f
BLAKE2b-256 7059a54b84b2263e713de0ece0b308f7e86b4cc49c3cfb5504ce693bb8b2bca9

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for pyterp-1.0.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 ea68c9423d1ddbe8f7c72ca1b07e0b26f5c07e6f9962b7108533a43888432930
MD5 e8f7f80df672d4c2fbbfcd4c386370ff
BLAKE2b-256 e6f10ab5347860f67568b70e274f2374616e3752ca0b2acd28eacfbbfc22d788

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyterp-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00f67c6e9d6fbbcd025b35c1f233edf30889ec42a2cd7c1bbb70161f48f6cbdb
MD5 4688c7313513cec1718332440fdf4d23
BLAKE2b-256 9a486339e360ac5f5d5163b3b62ee090f5fc58554a5eef825c615c0a6e523c32

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyterp-1.0.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