Hankel transform class

class pyhank.hankel.HankelTransform(order: int, max_radius: float = None, n_points: int = None, radial_grid: numpy.ndarray = None, k_grid: numpy.ndarray = None)

The main class for performing Hankel Transforms

For the QDHT to work, the function must be sampled a specific points, which this class generates and stores in HankelTransform.r. Any transform on this grid will be sampled at points HankelTransform.v (frequency space) or equivalently HankelTransform.kr (angular frequency or wavenumber space).

The constructor has one required argument (order). The remaining four arguments offer three different ways of specifying the radial (and therefore implicitly the frequency) points:

  1. Supply both a maximum radius r_max and number of transform points n_points
  2. Supply the original (often equally spaced) radial_grid on which you have currently have sample points. This approach allows easy conversion from the original grid using HankelTransform.to_transform_r(). t = HankelTransform(order, radial_grid=r) is effectively equivalent to t = HankelTransform(order, n_points=r.size, r_max=np.max(r)) except for the fact the the original radial grid is stored in the HankelTransform object for use in to_transform_r() and to_original_r().
  3. Supply the original (often equally spaced) \(k\)-space grid on which you have currently have sample points. This is most use if you intend to do inverse transforms. It allows easy conversion to and from the original grid using to_original_k() and to_transform_k(). As in option 2, HankelTransform.n_points is determined by k_grid.size. HankelTransform.r_max is determined in a more complex way from np.max(k_grid).
Parameters:
  • order (int) – Transform order \(p\)
  • max_radius (float) – (Optional) Radial extent of transform \(r_\textrm{max}\)
  • n_points (int) – (Optional) Number of sample points \(N\)
  • radial_grid (numpy.ndarray) – (Optional) The radial grid that will be used to sample input functions it is used to set N and \(r_\textrm{max}\) by n_points = radial_grid.size and r_max = np.max(radial_grid)
  • k_grid (numpy.ndarray) – (Optional) Number of sample points \(N\)
Variables:
  • alpha – The first \(N\) Roots of the \(p\) th order Bessel function.
  • alpha_n1 – (N+1)th root \(\alpha_{N1}\)
  • r – Radial co-ordinate vector
  • v – frequency co-ordinate vector
  • kr – Radial wave number co-ordinate vector
  • v_max – Limiting frequency \(v_\textrm{max} = \alpha_{N1}/(2 \pi R)\)
  • S – RV product \(2\pi r_\textrm{max} v_max\)
  • T – Transform matrix
  • JR – Radius transform vector \(J_R = J_{p+1}(\alpha) / r_\textrm{max}\)
  • JV – Frequency transform vector \(J_V = J_{p+1}(\alpha) / v_\textrm{max}\)

The algorithm used is that from:

“Computation of quasi-discrete Hankel transforms of the integer order for propagating optical wave fields” Manuel Guizar-Sicairos and Julio C. Guitierrez-Vega J. Opt. Soc. Am. A 21 (1) 53-58 (2004)

The algorithm also calls the function scipy.special.jn_zeros() to calculate the roots of the bessel function.

iqdht(fv: numpy.ndarray, axis: int = -2) → numpy.ndarray

IQDHT: Inverse Quasi Discrete Hankel Transform

Performs the inverse Hankel transform of a function of frequency, returning a function of radius.

\[f_r(r) = \mathcal{H}^{-1}\{f_v(v)\}\]
Parameters:
  • fv (numpy.ndarray) – Function in frequency space (sampled at self.v)
  • axis (int) – Axis over which to compute the Hankel transform.
Returns:

Radial function (sampled at self.r) = IHT(fv)

Return type:

numpy.ndarray

original_k_grid

Return the original k grid used to construct the object, or raise a ValueError if the constructor was not called specifying a k_grid parameter.

Returns:The original k grid used to construct the object.
Return type:numpy.ndarray
original_radial_grid

Return the original radial grid used to construct the object, or raise a ValueError if the constructor was not called specifying a radial_grid parameter.

Returns:The original radial grid used to construct the object.
Return type:numpy.ndarray
qdht(fr: numpy.ndarray, axis: int = -2) → numpy.ndarray

QDHT: Quasi Discrete Hankel Transform

Performs the Hankel transform of a function of radius, returning a function of frequency.

\[f_v(v) = \mathcal{H}^{-1}\{f_r(r)\}\]
Parameters:
  • fr (numpy.ndarray) – Function in real space as a function of radius (sampled at self.r)
  • axis (int) – Axis over which to compute the Hankel transform.
Returns:

Function in frequency space (sampled at self.v)

Return type:

numpy.ndarray

to_original_k(function: numpy.ndarray, axis: int = 0) → numpy.ndarray

Interpolate a function, assumed to have been given at the Hankel transform points self.k (as returned by HankelTransform.qdht()) back onto the original grid used to construct the HankelTransform object.

If the the HankelTransform object was constructed with a (say) equally-spaced grid in \(k\), it may be useful to convert back to this grid after a QDHT. This method provides a convenient way of doing this.

Parameters:
  • function (numpy.ndarray) – The function to be interpolated. Specified at the radial points self.k.
  • axis (int) – Axis representing the frequency dependence of function.
Returns:

Interpolated function at the points held in original_k_grid.

Return type:

numpy.ndarray

to_original_r(function: numpy.ndarray, axis: int = 0) → numpy.ndarray

Interpolate a function, assumed to have been given at the Hankel transform points self.r (as returned by HankelTransform.iqdht()) back onto the original grid used to construct the HankelTransform object.

If the the HankelTransform object was constructed with a (say) equally-spaced grid in radius, it may be useful to convert back to this grid after a IQDHT. This method provides a convenient way of doing this.

Parameters:
  • function (numpy.ndarray) – The function to be interpolated. Specified at the radial points self.r.
  • axis (int) – Axis representing the radial dependence of function.
Returns:

Interpolated function at the points held in original_radial_grid.

Return type:

numpy.ndarray

to_transform_k(function: numpy.ndarray, axis: int = 0) → numpy.ndarray

Interpolate a function, assumed to have been given at the original k grid points used to construct the HankelTransform object onto the grid required of use in the IQDHT algorithm.

If the the HankelTransform object was constructed with a (say) equally-spaced grid in \(k\), then it needs the function to transform to be sampled at a specific grid before it can be passed to HankelTransform.iqdht(). This method provides a convenient way of doing this.

Parameters:
  • function (numpy.ndarray) – The function to be interpolated. Specified at the k points original_k_grid.
  • axis (int) – Axis representing the frequency dependence of function.
Returns:

Interpolated function suitable to passing to HankelTransform.qdht() (sampled at self.kr)

Return type:

numpy.ndarray

to_transform_r(function: numpy.ndarray, axis: int = 0) → numpy.ndarray

Interpolate a function, assumed to have been given at the original radial grid points used to construct the HankelTransform object onto the grid required of use in the QDHT algorithm.

If the the HankelTransform object was constructed with a (say) equally-spaced grid in radius, then it needs the function to transform to be sampled at a specific grid before it can be passed to HankelTransform.qdht(). This method provides a convenient way of doing this.

Parameters:
  • function (numpy.ndarray) – The function to be interpolated. Specified at the radial points original_radial_grid.
  • axis (int) – Axis representing the radial dependence of function.
Returns:

Interpolated function suitable to passing to HankelTransform.qdht() (sampled at self.r)

Return type:

numpy.ndarray