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 pointsHankelTransform.v(frequency space) or equivalentlyHankelTransform.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:- Supply both a maximum radius
r_maxand number of transform pointsn_points - Supply the original (often equally spaced)
radial_gridon which you have currently have sample points. This approach allows easy conversion from the original grid usingHankelTransform.to_transform_r().t = HankelTransform(order, radial_grid=r)is effectively equivalent tot = HankelTransform(order, n_points=r.size, r_max=np.max(r))except for the fact the the original radial grid is stored in theHankelTransformobject for use into_transform_r()andto_original_r(). - 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()andto_transform_k(). As in option 2,HankelTransform.n_pointsis determined byk_grid.size.HankelTransform.r_maxis determined in a more complex way fromnp.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}\) byn_points = radial_grid.sizeandr_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: - fv (
-
original_k_grid¶ Return the original k grid used to construct the object, or raise a
ValueErrorif the constructor was not called specifying ak_gridparameter.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
ValueErrorif the constructor was not called specifying aradial_gridparameter.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 atself.r) - axis (
int) – Axis over which to compute the Hankel transform.
Returns: Function in frequency space (sampled at
self.v)Return type: - fr (
-
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 byHankelTransform.qdht()) back onto the original grid used to construct theHankelTransformobject.If the the
HankelTransformobject 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 pointsself.k. - axis (
int) – Axis representing the frequency dependence of function.
Returns: Interpolated function at the points held in
original_k_grid.Return type: - function (
-
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 byHankelTransform.iqdht()) back onto the original grid used to construct theHankelTransformobject.If the the
HankelTransformobject 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 pointsself.r. - axis (
int) – Axis representing the radial dependence of function.
Returns: Interpolated function at the points held in
original_radial_grid.Return type: - function (
-
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
HankelTransformobject onto the grid required of use in the IQDHT algorithm.If the the
HankelTransformobject 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 toHankelTransform.iqdht(). This method provides a convenient way of doing this.Parameters: - function (
numpy.ndarray) – The function to be interpolated. Specified at the k pointsoriginal_k_grid. - axis (
int) – Axis representing the frequency dependence of function.
Returns: Interpolated function suitable to passing to
HankelTransform.qdht()(sampled atself.kr)Return type: - function (
-
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
HankelTransformobject onto the grid required of use in the QDHT algorithm.If the the
HankelTransformobject 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 toHankelTransform.qdht(). This method provides a convenient way of doing this.Parameters: - function (
numpy.ndarray) – The function to be interpolated. Specified at the radial pointsoriginal_radial_grid. - axis (
int) – Axis representing the radial dependence of function.
Returns: Interpolated function suitable to passing to
HankelTransform.qdht()(sampled atself.r)Return type: - function (
- Supply both a maximum radius