Logarithmic Fast Fourier Transform
Project description
This is a simple f2py-wrapper for the logarithmic FFT code FFTLog as presented in Appendix B of [Hami00] and published at casa.colorado.edu/~ajsh/FFTLog.
A pure python version (pyfftlog) can be found on github.com/prisae/pyfftlog. Tests have shown that fftlog is a bit faster than pyfftlog, but pyfftlog is easier to implement, as you only need NumPy and SciPy, without the need to compile anything.
I hope that FFTLog will make it into SciPy in the future, which will make this project redundant. (If you have the bandwidth and are willing to chip in have a look at SciPy PR #7310.)
Be aware that pyfftlog has not been tested extensively. It works fine for the test from the original code, and my use case, which is pyfftlog.fftl with mu=0.5 (sine-transform), q=0 (unbiased), k=1, kropt=1, and tdir=1 (forward). Please let me know if you encounter any issues.
Documentation: https://pyfftlog.readthedocs.io
Source Code: https://github.com/prisae/fftlog
Note that the documentation is for the pure python version pyfftlog, but equally applies to fftlog.
Description of FFTLog from the FFTLog-Website
FFTLog is a set of fortran subroutines that compute the fast Fourier or Hankel (= Fourier-Bessel) transform of a periodic sequence of logarithmically spaced points.
FFTLog can be regarded as a natural analogue to the standard Fast Fourier Transform (FFT), in the sense that, just as the normal FFT gives the exact (to machine precision) Fourier transform of a linearly spaced periodic sequence, so also FFTLog gives the exact Fourier or Hankel transform, of arbitrary order m, of a logarithmically spaced periodic sequence.
FFTLog shares with the normal FFT the problems of ringing (response to sudden steps) and aliasing (periodic folding of frequencies), but under appropriate circumstances FFTLog may approximate the results of a continuous Fourier or Hankel transform.
The FFTLog algorithm was originally proposed by [Talm78].
For the full documentation, see casa.colorado.edu/~ajsh/FFTLog.
Installation
You can install fftlog either via conda:
conda install -c conda-forge fftlog
or via pip:
pip install fftlog
Creation
The power of f2py did most of the work.
The src-directory contains the original fortran files as downloaded from casa.colorado.edu/~ajsh/FFTLog. The only change I made was to recode the coding of fftlog.f, as f2py struggled with a few characters in the description part:
recode latin1..UTF-8 fftlog.f
Thereafter I used f2py to produce the pyf-instructions with the following command, generating only hooks for the functions fhti, fttl, fht, and fhtq:
f2py src/* -m fftlog -h fftlog.pyf only: fhti fftl fht fhtq :
Lastly I amended the pyf-instructions, mainly with some intent and optional statements as well as the corresponding default values.
Notes
kropt=3 (interactive adjusting) is not possible with fftlog
wsave-dimension is set to 2*n+3*(n/2)+19, the biggest of the four minimum sizes described in fftlog.f.
References
Hamilton, A. J. S., 2000, Uncorrelated modes of the non-linear power spectrum: Monthly Notices of the Royal Astronomical Society, 312, pages 257-284; DOI: 10.1046/j.1365-8711.2000.03071.x; Website of FFTLog: casa.colorado.edu/~ajsh/FFTLog.
Talman, J. D., 1978, Numerical Fourier and Bessel transforms in logarithmic variables: Journal of Computational Physics, 29, pages 35-48; DOI: 10.1016/0021-9991(78)90107-9.
License, Citation, and Credits
These additions to the original FFTLog-code are released to the public domain under the CC0 1.0 License.
All releases have a Zenodo-DOI, which can be found on 10.5281/zenodo.3830364.
Permission to distribute the original Fortran FFTLog code with this Python fftlog package has been granted (email from Andrew Hamilton to Dieter Werthmüller dated 28 September 2016).
Credits commented in the original code:
FFTLog uses the NCAR suite of FFT routines, and a modified version of the complex Gamma function from the gamerf package at momonga.t.u-tokyo.ac.jp/~ooura/gamerf.html. The original gamerf copyright statement states:
Copyright(C) 1996 Takuya OOURA (email: ooura@mmm.t.u-tokyo.ac.jp). You may use, copy, modify this code for any purpose and without fee. You may distribute this ORIGINAL package.
Permission to distribute the modified gamma function code with the FFTLog package has been granted (email from Takuya Ooura to Andrew Hamilton dated 16 March 1999).
Be kind and give credits by citing Hamilton (2000).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fftlog-0.2.1.tar.gz
.
File metadata
- Download URL: fftlog-0.2.1.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 049d420c6dbbc85b79a7682764228092cd395210b37c9c9ae909e645822210d2 |
|
MD5 | 8e95acdedfa340dd00f0ef3c39efeeed |
|
BLAKE2b-256 | 13d2ce064b166832a706bd4c0ef3a296b4438cc621e22e2ef139e7d5f9e33498 |