Skip to main content

A package for N-linear regular grid interpolation

Project description

interpylate

interpylate is a Python library for N-linear regular grid interpolation. It provides a flexible and efficient method to interpolate N-dimensional arrays using a N-linear approach, making it particularly useful for image interpolation and its higher-dimensional equivalents.

Installation

pip install interpylate

Dependencies

  • numpy: Core dependency for array operations

Architecture

The library is structured with a unified interface and specialized implementations:

  • NLinearRegularGridInterpolator: A unified interface that automatically selects the appropriate dimension-specific implementation based on the input dimension
    • For dimensions > 3, it utilizes NLinearRegularGridInterpolatorLarge
  • LinearRegularGridInterpolator: Optimized for 1D arrays
  • BiLinearRegularGridInterpolator: Optimized for 2D arrays (images)
  • TriLinearRegularGridInterpolator: Optimized for 3D arrays (volumes)
  • NLinearRegularGridInterpolatorLarge: Less optimized general implementation for any dimensions

This design provides both optimization for common cases and flexibility for higher dimensions.

Usage

from interpylate import NLinearRegularGridInterpolator

# Create an instance of the interpolator
# This will automatically select the appropriate implementation based on dimension
interpolator = NLinearRegularGridInterpolator(dim=3)

# Evaluate the interpolation at specified coordinates
interpolated_values = interpolator.evaluate(NDarray, continuous_inds)

# Compute the gradient of the interpolated array
gradient = interpolator.grad(NDarray, continuous_inds, evaluate_too=False)

# Compute the hessian of the interpolated array
hessian = interpolator.hess(NDarray, continuous_inds, grad_too=False, evaluate_too=False)

Main Features

  • Dimension-agnostic API: Work with arrays of any dimension using a consistent interface
  • Performance-optimized implementations: Specialized algorithms for 1D, 2D, and 3D cases
  • Gradient computation: Calculate first-order derivatives of interpolated arrays
  • Hessian computation: Compute second-order derivatives for advanced analysis
  • Regular grid support: Designed specifically for regular grid structures

Examples

The interpylate GitHub repository includes several example scripts demonstrating the library's capabilities:

  • 1D Interpolation: Basic interpolation for one-dimensional arrays
  • 2D Interpolation: Image interpolation techniques
  • 3D Interpolation: Volume data interpolation methods
  • Speed Contest: Performance comparison between interpylate's TriLinearRegularGridInterpolator and scipy.interpolate.RegularGridInterpolator

Documentation

The full API documentation is available in the docs/ directory of the project or via the online documentation portal.

Contributing

At the moment, I am not actively reviewing contributions. However, if you encounter issues or have suggestions, feel free to open an issue.

License

This project is licensed under the CeCILL License.

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

interpylate-1.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

interpylate-1.0.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file interpylate-1.0.1.tar.gz.

File metadata

  • Download URL: interpylate-1.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for interpylate-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a89143cb31d515cced5662dcf8042093545ecf4b7c61094b56c65f1fd92da8a3
MD5 bc926a20cae2a4a7e518e6d6de1f5cfd
BLAKE2b-256 9d5bd9c2e387139f934c68f3ada73979b8fac41e60f0dd2d26dcbbaba56a1afd

See more details on using hashes here.

File details

Details for the file interpylate-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: interpylate-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for interpylate-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0e084563dbff030dc22c1945fea5383221ba84cfdff253509d7d4a69c31581b
MD5 dc19db51b2bff738c37f547eef470fe8
BLAKE2b-256 99d8a241c07c6f89f2cc41f1e6477474ee9eadd68232ebe40230fa310717694d

See more details on using hashes here.

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