- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个二维复数数组,代表在真实空间中沿平面测量的势场。假设阵列是 128 x 128 单元,平面的总面积是 500m x 500m。该数组中的每个单元表示空间域中的一个点,其坐标在 x 和 y 中给出。
当我在这个二维数组上使用 scipy.fftpack 中的二维 FFT 时,我得到了在波域中表示的相同信息。如何计算输出阵列点的波域坐标 kx 和 ky?
最佳答案
这里有一些代码可以充分展示问题和我能够找到的解决方案。
from numpy import linspace , arange , reshape ,zeros
from scipy.fftpack import fft2 , fftfreq
from cmath import pi
# create some arbitrary data
some_data = arange(0.0 , 16384.0 , dtype = complex)
# reshape it to be a 128x128 2d grid
some_data_grid = reshape(some_data , (128 , 128) )
# assign some real spatial co-ordinates to the grid points
# first define the edge values
x_min = -250.0
x_max = 250.0
y_min = -250.0
y_max = 250
# then create some empty 2d arrays to hold the individual cell values
x_array = zeros( (128,128) , dtype = float )
y_array = zeros( (128,128) , dtype = float )
# now fill the arrays with the associated values
for row , y_value in enumerate(linspace (y_min , y_max , num = 128) ):
for column , x_value in enumerate(linspace (x_min , x_max , num = 128) ):
x_array[row][column] = x_value
y_array[row][column] = y_value
# now for any row,column pair the x_array and y_array hold the spatial domain
# co-ordinates of the associated point in some_data_grid
# now use the fft to transform the data to the wavenumber domain
some_data_wavedomain = fft2(some_data_grid)
# now we can use fftfreq to give us a base for the wavenumber co-ords
# this returns [0.0 , 1.0 , 2.0 , ... , 62.0 , 63.0 , -64.0 , -63.0 , ... , -2.0 , -1.0 ]
n_value = fftfreq( 128 , (1.0 / 128.0 ) )
# now we can initialize some arrays to hold the wavenumber co-ordinates of each cell
kx_array = zeros( (128,128) , dtype = float )
ky_array = zeros( (128,128) , dtype = float )
# before we can calculate the wavenumbers we need to know the total length of the spatial
# domain data in x and y. This assumes that the spatial domain units are metres and
# will result in wavenumber domain units of radians / metre.
x_length = x_max - x_min
y_length = y_max - y_min
# now the loops to calculate the wavenumbers
for row in xrange(128):
for column in xrange(128):
kx_array[row][column] = ( 2.0 * pi * n_value[column] ) / x_length
ky_array[row][column] = ( 2.0 * pi * n_value[row] ) / y_length
# now for any row,column pair kx_array , and ky_array will hold the wavedomain coordinates
# of the correspoing point in some_data_wavedomain
我知道这可能不是最有效的方法,但希望它很容易理解。我希望这可以帮助人们避免一些挫折。
关于python - 如何从 2d FFT 计算波数域坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7161417/
这是我的问题 1)我有动态y数组数据,使用该数组如何连续绘制波浪。 如果Y数组数据完整,则使用相同的y数组数据继续。 2)声音自动播放在该数组值是143.if我停止不停止。 这是我的代码:
网络上有太多使用 WiFi 或蓝牙传输数据的对讲机应用程序(至少我见过的所有应用程序),但没有一个使用内置天线通过 radio 波传输数据真正的对讲机设备。 是否有任何安全原因?还是限制作为发送器/接
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve this
我正在尝试着手研究 boost wave,但到目前为止,我的运气并不好。 我尝试了网站上的示例代码。如下: #include #include #include #include #inclu
我正在尝试使用 svg 编写一个 javascript 加载器。想法是,它是一个从下到上两侧均匀填充的圆圈,加载器的顶线是一个从左到右不断移动的正弦波。 我能够根据百分比为加载程序创建弧线,如下所示:
这个问题在这里已经有了答案: Is there a one-line function that generates a triangle wave? (8 个答案) 关闭 9 年前。 我试图用 A
当我在论坛中搜索时,我了解到要定位 GPS,我必须通过互联网连接或短信发送坐标。但据我所知,我们可以通过 radio 波进行通信,发送语音、图片、数据。我可以用它来获取数据吗? GPS 设备?因为业余
我是一名优秀的程序员,十分优秀!