[Numpy-discussion] numpy FFT memory accumulation
Charles R Harris
Thu Nov 1 10:18:50 CDT 2007
On 11/1/07, Ray Schumacher <email@example.com> wrote:
> At 11:55 PM 10/31/2007, Travis wrote:
> >Ray S wrote:
> > > I am using
> > > fftRes = abs(fft.rfft(data_array[end-2**15:end]))
> > >
> >At first glance, I would say that I don't expect memory to be growing
> >here, so it looks like a problem with rfft that deserves looking into.
> I saw that Numeric did also (I still use Numeric for smaller array
> speed) but much more slowly.
> I will try to repeat with a small demo and post.
> >Does data_array keep growing?
> no, it is a 64k circular buffer
> Which reminds me, I've been wanting to try to build a Numeric
> circular buffer object; one that, when sliced or assigned to,
> auto-magically wraps as needed, exposing only an extra pointer
> attribute for the "end". I currently always do it with Python if-s
> and pointer vars for these products that only do "real time" data
In Python, collections.deque makes a pretty good circular buffer. Numpy will
make an array out of it, which involves a copy, but it might be better than
what you are doing now.
In : from collections import deque
In : a = deque([1,2,3,4])
In : fft(a)
Out: array([ 10.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
In : a.append(5)
In : a.popleft()
In : fft(a)
Out: array([ 14.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion