Home:ALL Converter>Fourier coefficients for NFFT - non uniform fast Fourier transform?

Fourier coefficients for NFFT - non uniform fast Fourier transform?

Ask Time:2014-09-24T18:18:06         Author:elle

Json Formatter

I am trying to use the package pynfft in python 2.7 to do the non-uniform fast Fourier transform (nfft). I have learnt python for only two months, so I have some difficulties.

This is my code:

import numpy as np
from pynfft.nfft import NFFT

#loading data, 104 lines
t_diff, x_diff = np.loadtxt('data/analysis/amplitudes.dat', unpack = True)

N = [13,8]
M = 52

#fourier coefficients
f_hat = np.fft.fft(x_diff)/(2*M)

#instantiation
plan = NFFT(N,M)

#precomputation
x = t_diff
plan.x = x
plan.precompute()

# vector of non uniform samples
f = x_diff[0:M]

#execution
plan.f = f
plan.f_hat = f_hat
f = plan.trafo()

I am basically following the instructions I found in the pynfft tutorial (http://pythonhosted.org/pyNFFT/tutorial.html).

I need the nfft because the time intervals in which my data are taken are not constant (I mean, the first measure is taken at t, the second after dt, the third after dt+dt' with dt' different from dt and so on).

The pynfft package wants the vector of the fourier coefficients ("f_hat") before execution, so I calculated it using numpy.fft, but I am not sure this procedure is correct. Is there another way to do it (maybe with the nfft)?

I would like also to calculate the frquencies; I know that with numpy.fft there is a command: is ther anything like that also for pynfft? I did not find anything in the tutorial.

Thank you for any advice you can give me.

Author:elle,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26014375/fourier-coefficients-for-nfft-non-uniform-fast-fourier-transform
yy