[SciPy-user] wavevector arrays
Mon Mar 19 17:09:11 CDT 2007
I am performing a number of 3D FFTs using scipy, and I had a question
as to how to setup 3 3D arrays of wavevectors, much like one might do
with mgrid. However, because the FFT returns wavevectors running from
0,...,k_c, -k_c, ..., -1 (where k_c is the nyquist wavenumber) I'm
not sure how to get mgrid to do this.
In 2D, I could create two 1D kx and ky arrays and use meshgrid (for
an even number of points):
import numpy as N
kx = 2*N.pi/Lx * N.concatenate(N.arange(0,nx/2-1),N.arange(-nx/2, 0))
ky = 2*N.pi/Ly * N.concatenate(N.arange(0,ny/2-1),N.arange(-ny/2, 0))
kk = meshgrid(kx,ky)
where kk would have a shape (2,ny,nx). However, this (to my
knowledge) doesn't generalize to 3D.
I'm a total python/scipy neophyte, so any help you could provide
would be quite appreciated.
More information about the SciPy-user