Fourier and Hankel transforms
- colibri.fourier.FFT_1D(x, f_x, N=None, compl=False)[source]
This routine returns the 1D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the FT is already normalized.
- Parameters:
x (array) – Abscissae.
f_x (array) – Function sampled at x.
N (integer, default = None) – Number of output points. If None, the same length of x is used.
compl (boolean, default = False) – Return complex values.
- Returns:
xf (array) – Frequencies in k_x (already sorted).
yf (array) – Fourier transform (sorted by frequencies).
- colibri.fourier.iFFT_1D(k, f_k, N=None, compl=False)[source]
This routine returns the 1D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the inverse FT is already normalized.
- Parameters:
k (array) – Abscissae.
f_k (array) – Function sampled at x.
N (integer, default = None) – Number of output points. If None, the same length of x is used.
compl (boolean, default = False) – Return complex values.
- Returns:
xf (array) – Frequencies in x (already sorted).
yf (array) – Inverse Fourier transform (sorted by frequencies).
- colibri.fourier.FFT_2D(x, y, f_xy, compl=False, sort=True)[source]
This routine returns the 2D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the FT is already normalized.
- Parameters:
x (array) – Abscissa 1.
y (array) – Abscissa 2.
f_xy (2D array) – Function sampled at (x,y).
compl (boolean, default = False) – Return complex values.
sort (boolean, dafault = True) – Return sorted frequencies and Fourier transform. If False, the NumPy order is used.
- Returns:
KX (array) – Frequencies in k_x.
KY (array) – Frequencies in k_y.
F_KXKY (2D array) – Fourier transform.
- colibri.fourier.iFFT_2D(kx, ky, f_kxky, compl=False, sort=True)[source]
This routine returns the inverse 2D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the FT is already normalized.
- Parameters:
kx (array) – Abscissa 1.
ky (array) – Abscissa 2.
f_kxky (2D array) – Function sampled at (kx,ky).
compl (boolean, default = False) – Return complex values.
sort (boolean, dafault = True) – Return sorted frequencies and Fourier transform. If False, the NumPy order is used.
- Returns:
X (array) – Frequencies in x.
Y (array) – Frequencies in y.
F_XY (2D array) – Fourier transform.
- colibri.fourier.FFT_3D(x, y, z, f_xyz, compl=False, sort=True)[source]
This routine returns the 3D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the FT is already normalized.
- Parameters:
x (array) – Abscissa 1.
y (array) – Abscissa 2.
z (array) – Abscissa 3.
f_xyz (3D array) – Function sampled at (x,y,z).
compl (boolean, default = False) – Return complex values.
sort (boolean, dafault = True) – Return sorted frequencies and Fourier transform. If False, the NumPy order is used.
- Returns:
KX (array) – Frequencies in k_x.
KY (array) – Frequencies in k_y.
KZ (array) – Frequencies in k_z.
F_KXKYKZ (3D array) – Fourier transform.
- colibri.fourier.iFFT_3D(kx, ky, kz, f_kxkykz, compl=False, sort=True)[source]
This routine returns the inverse 3D FFT of a linearly-spaced array. It returns the radian frequencies and the Fourier transform. N.B.: the frequencies and FT are sorted. Note on normalizations: the returned frequencies are \(2\pi\nu\); the FT is already normalized.
- Parameters:
kx (array) – Abscissa 1.
ky (array) – Abscissa 2.
kz (array) – Abscissa 3.
f_kxkykz (3D array) – Function sampled at (kx,ky,kz).
compl (boolean, default = False) – Return complex values.
sort (boolean, dafault = True) – Return sorted frequencies and Fourier transform. If False, the NumPy order is used.
- Returns:
X (array) – Frequencies in x.
Y (array) – Frequencies in y.
Z (array) – Frequencies in z.
F_XYZ (3D array) – Fourier transform.
- colibri.fourier.FFT_iso_3D(r, f, N=4096)[source]
This routine returns the FFT of a radially symmetric function. It employs the
FFTlogmodule, which in turn makes use of the Hankel transform: therefore the function that will be actually transformed is \(f(r) \ (2\pi r)^{1.5}/k^{1.5}\). N.B. Since the integral is performed in log-space, the exponent of r is 1.5 instead of 0.5. The computation is\[f(k) = \int_0^\infty dr \ 4\pi r^2 \ f(r) \ j_0(kr)\]- Parameters:
r (array) – Abscissae of function, log-spaced.
f (array) – ordinates of function.
N (int, default = 4096) – Number of output points
- Returns:
kk (array) – Frequencies.
Fk (array) – Transformed array.
- colibri.fourier.iFFT_iso_3D(k, f, N=4096)[source]
This routine returns the inverse FFT of a radially symmetric function. It employs the
FFTlogmodule, which in turn makes use of the Hankel transform: therefore the function that will be actually transformed is \(f(k) \ k^{1.5}/(2\pi r)^{1.5}\). N.B. Since the integral is performed in log-space, the exponent of r is 1.5 instead of 0.5. The computation is\[f(r) = \int_0^\infty \frac{dk \ k^2}{2\pi^2} \ f(k) \ j_0(kr)\]- Parameters:
k (array) – Abscissae of function, log-spaced.
f (array) – ordinates of function.
N (int, default = 4096) – Number of output points
- Returns:
rr (array) – Frequencies.
Fr (array) – Transformed array.
- colibri.fourier.Hankel_spherical_Bessel(r, f, N=4096, order=0)[source]
This routine is analogous to the Fourier transform in 3D but it can return any order of the Bessel function
\[f_\ell(k) = \int_0^\infty dr \ 4\pi r^2 \ f(r) \ j_\ell(kr)\]
- colibri.fourier.iHankel_spherical_Bessel(k, f, N=4096, order=0)[source]
This routine is similar to the Fourier transform in 3D but it can return any order of the Bessel function
\[f_\ell(r) = \int_0^\infty \frac{dk \ k^2}{2\pi^2} \ f(k) \ j_\ell(kr)\]
- colibri.fourier.Hankel(r, f, N=4096, order=0.5)[source]
This routine returns the Hankel transform of order \(\nu\) of a log-spaced function. The computation is
\[f_\nu(k) = \int_0^\infty \ dr \ r \ f(r) \ J_\nu(kr)\]Warning
Because of log-spacing, an extra r factor has been already added in the code.
Warning
If
order = 0.5it is similar to the 3D Fourier transform of a spherically symmetric function.
- colibri.fourier.iHankel(k, f, N=4096, order=0.5)[source]
This routine returns the inverse Hankel transform of order \(\nu\) of a log-spaced function. The computation is
\[f(r) = \int_0^\infty \ dk \ k \ f(k) \ J_\nu(kr)\]Warning
Because of log-spacing, an extra k factor has been already added in the code.
Warning
If
order = 0.5it is similar to the 3D Fourier transform of a spherically symmetric function.
- colibri.fourier.correlation_function(k, pk, N=4096)[source]
This routine computes the 2-point correlation function of a field given its power spectrum.
- Parameters:
k (array) – Abscissae of function, log-spaced.
pk (array) – Power spectrum
N (int, default = 4096) – Number of output points
- Returns:
r (array) – Radii.
xi (array) – Correlation function.
- colibri.fourier.projected_correlation_function(k, pk, N=4096)[source]
This routine computes the projected 2-point correlation function of a field given its power spectrum.
- Parameters:
k (array) – Abscissae of function, log-spaced.
pk (array) – Power spectrum
N (int, default = 4096) – Number of output points
- Returns:
rp (array) – Radii.
wp (array) – Projected correlation function.
- colibri.fourier.angular_correlation_function(theta, k, pk, z, chi_z, N_z, H_z, N=4096)[source]
This routine computes the angular 2-point correlation function of a field given its power spectrum.
- Parameters:
theta (array) – Angles in arcminutes.
- k: array
Abscissae of function, log-spaced.
- pk: array
Power spectrum
- z: array
Redshifts at which to integrate.
- chi_z: array
Comoving distances at redshifts of integration.
- N_z: array
Source density at redshifts of integration.
- H_z: array
Hubble parameters (in km/s/(Mpc/h)) at redshifts of integration.
- N: int, default = 4096
Number of output points
- Returns:
theta (array) – Angles.
wt (array) – Angular correlation function.