fbianchini / fftlog

A Python wrapper (using f2py) for the logarithmic FFT Fortran code FFTLog by Andrew Hamilton.

Home Page:http://casa.colorado.edu/~ajsh/FFTLog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fftlog - python wrapper FFTLog

This is a simple f2py-wrapper for the logarithmic FFT code FFTLog as presented in Appendix B of [Hamilton_2000] and published at casa.colorado.edu/~ajsh/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 [Talman_1978].

For the full documentation, see casa.colorado.edu/~ajsh/FFTLog.

Installation

To install it in your python distribution:

python setup.py install

To just create the module that you can import locally:

f2py -c fftlog.pyf src/*

Check out the Jupyter Notebook fftlogtest.ipynb in the root directory. It is a translation of the test-function fftlogtest.f, and should get you started.

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

  1. kropt = 3 (interactive adjusting) is not possible with fftlog
  2. wsave-dimension is set to 3.5*n+19, the biggest of the four minimum sizes described in fftlog.f.

References

[Hamilton_2000]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_1978]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 and Credits

These additions to the original FFTLog-code are released to the public domain under the CC0 1.0 License.

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).

About

A Python wrapper (using f2py) for the logarithmic FFT Fortran code FFTLog by Andrew Hamilton.

http://casa.colorado.edu/~ajsh/FFTLog

License:Other


Languages

Language:Jupyter Notebook 53.0%Language:Fortran 42.2%Language:Python 4.8%