Note
Click here to download the full example code
Simple example of PyHank usageΒΆ
In this example (as in the Example of single-shot transform) we will check the band limit of a jinc function: \(f(r) = \frac{J_1(r)}{r}\). The (0 order) Hankel transform of this should be the top hat function.
Here we create a HankelTransform object and use its
qdht() method.
In this simple case, the simpler, single shot functions used in
Example of single-shot transform may be simpler
to use. It should be noted, however, that they are not well suited for
multiple transforms on the same grid and the approach taken here is
recommended.
First import the HankelTransform class and other packages
from pyhank import HankelTransform
import scipy.special
import matplotlib.pyplot as plt
Create a HankelTransform object which holds the grid for \(r\) and
\(k_r\) points and calculate the jinc function.
Note that although the calculation fails at \(r = 0\), transformer.r does
not include \(r=0\).
transformer = HankelTransform(order=0, max_radius=100, n_points=1024)
f = scipy.special.jv(1, transformer.r) / transformer.r
plt.figure()
plt.plot(transformer.r, f)
plt.xlabel('Radius /m')

Now take the Hankel transform using HankelTransform.qdht()
ht = transformer.qdht(f)
plt.figure()
plt.plot(transformer.kr, ht)
plt.xlim([0, 5])
plt.xlabel('Radial wavevector /m$^{-1}$')

As expected, this is a top-hat function bandlimited to \(k<1\), except for numerical error.
Total running time of the script: ( 0 minutes 0.692 seconds)