Stupid simple implementation of the FFTlog algorithm in Python, first described in Hamilton, 2000.
In essence, the code computes the following integral:
or, in Latex (in case the above doesn't display properly):
I_\ell^n(y)
=
\frac{1}{2 \pi^2}
\int_0^\infty
\text{d}x\,
x^2\,
\frac{j_\ell(x y)}{(x y)^n}\,
f(x)
where j_\ell are the spherical Bessel functions of degree \ell, and f(x) is the input function, usually taken to be the matter power spectrum.
Code is heavily based on twoFAST.jl, and has been verified with their implementation on the reference power spectrum.
Clone the repo:
git clone https://github.com/JCGoran/repoYou need the numpy and scipy packages for the FFTlog module to work.
You can install them using pip from the requirements.txt file:
pip3 install -r requirements.txtYou can add a --user flag to the above if you don't want to install those packages system-wide.
See the provided example.py file; note that it needs the matplotlib package to perform the plotting.
An abridged version would be:
- Import the module:
import fftlog-
Input: two arrays,
x, andf(x);f(x)must be sampled on a large enough range ofx, otherwise spurious oscillations may appear in the output. -
To create an FFTlog:
# prepares the FFTlog with ell = 0, n = 0, with 2048 sampling points
result = fftlog.FFTlog(x, y, 0, 0, 2048)
# performs the transformation in place with min(y_output) = 1
result.transform(1)
# alternatively, you can instead directly assign the output with:
# x_transform, y_transform = result.transform(1)GPL 3.0
Make PyPI package.
