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
- For dimensions > 3, it utilizes
LinearRegularGridInterpolator: Optimized for 1D arraysBiLinearRegularGridInterpolator: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interpylate-1.0.2.tar.gz.
File metadata
- Download URL: interpylate-1.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8851cc084daf21cc9ad20308e0ec6b37bd787ff44362b799c3ef338d0940ef1b
|
|
| MD5 |
1c0fb98b7bfdcd6e50c41370d398eb82
|
|
| BLAKE2b-256 |
4f706c9f73e23f79bc0e15a1f9504457d25bd47a1222617e97bf701a54cdcd10
|
File details
Details for the file interpylate-1.0.2-py3-none-any.whl.
File metadata
- Download URL: interpylate-1.0.2-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d12909a75f37d5ae8c57b3ffa5c3a5993fba662e2d73d93e4eecfe3e34121945
|
|
| MD5 |
0e72d5fbbbe2d813b3adab814da00f49
|
|
| BLAKE2b-256 |
5df85ba3fd6b84c7a651e93688c7e9514b374a0c4b4cfef84d944a033d8e836f
|