Hankel

raw JSON →
1.2.2 verified Fri May 01 auth: no python

Hankel Transformations using the method of Ogata 2005. Current version 1.2.2, requires Python >=3.6. Maintenance mode with occasional bugfixes.

pip install hankel
error AttributeError: module 'hankel' has no attribute 'HankelTransform'
cause Wrong import path, e.g., `import hankel` and then `hankel.HankelTransform` instead of direct import.
fix
Use from hankel import HankelTransform.
error ValueError: h must be positive
cause Provided non-positive `h` parameter.
fix
Ensure h > 0, e.g., 0.05.
deprecated The `algebraic_decay` parameter in `__init__` is deprecated since v1.0.
fix Use `algorithm='direct' or 'ogata'` instead.
gotcha Default `N` (number of integration points) may be too small for accurate transforms; always check convergence.
fix Increase `N` (e.g., 200-500) and compare results.
breaking In v1.0, the `h` parameter spacing was changed from logarithmic to semi-logarithmic scaling; results differ from v0.3.x.
fix Adjust `h` value and recompute, or pin to v0.3.x.

Compute Hankel transform of f(x)=exp(-x^2) at points k=1,2.

from hankel import HankelTransform
import numpy as np

ht = HankelTransform(nu=0, N=200, h=0.05)
result = ht.transform(lambda x: np.exp(-x**2), np.array([1.0, 2.0]))
print(result)