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.2.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.2.0-cp310-cp310-win_amd64.whl (131.6 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterp-1.2.0-cp310-cp310-win32.whl (110.6 kB view details)

Uploaded CPython 3.10Windows x86

pyterp-1.2.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.2.0.tar.gz.

File metadata

  • Download URL: pyterp-1.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 22c19d5a7aa57c8ef2dcec139846a248606068d0fe9603f38e042840aadf153c
MD5 3eb64c850c424881d4ffbc75c70b91a5
BLAKE2b-256 83043c7d26ddbbba564ca53b778466c719dbdca01dc24175b56853fd71c64220

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyterp-1.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 131.6 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.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 29b2ebc0afbcddb7f2956e095c380fda86700a4a684e3dd0b392f35dd147f9c2
MD5 f9aca0f095d917f74ba1d8b4ff767714
BLAKE2b-256 3faca44682d8528d4fb623f1aa6d77963822458dfc2a44eaea64f12fe80b162b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyterp-1.2.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 110.6 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.2.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 e717e17ab680a3cfd6ad2629a519bbd9b527c8bbec717a348116899cc691e2c9
MD5 c4833d66431eda5d88fe6ea6c679ea4a
BLAKE2b-256 fb9a30754bfebe8847a752fb8aaf0e24124fa97ab14164567cf0e3c3f7a9b3a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyterp-1.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0095604ae8d9e5b5e5fc6f7a80faf2d2f331225386377ecdf1dcef03d248e048
MD5 44dbdef71501135a66e5dae34fa2e4d8
BLAKE2b-256 eb0a0203c78c1a18047ac78c29aefd6f5bf10fa067b9eb9c5faee9ef4a8445df

See more details on using hashes here.

Provenance

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