我正在使用numpy中的fftn来生成一个离散FT,其中一个是20单元一维阵列,另一个是20x20x20三维阵列,我想抑制高频项,从最高频率开始,扩展到低频项。我对连续FTs比较熟悉,并且很难在DFT中识别高频术语。我应该在哪里查找fftn生成的数组?(我计划在向后转换之前将这些值设置为零。)
发布于 2016-02-24 05:20:32
根据文档中的注释
输出类似于fft,包含所有轴的低阶角的零频率项、所有轴的前半部分的正频率项、所有轴中间的Nyquist频率项和所有轴的下半部分的负频率项,顺序为负频率。
但是,请注意,对于奇数大小的数组,Nyquist频率没有表示。此外,假设你处理的是实值信号,离散傅里叶变换将具有厄米特对称性.当你在频域中处理这些信号时,如果你想让信号在逆变换后保持实值,保持这种对称性是很重要的。在对频率分量进行归零时,这意味着你也应该在相应的负频率上对频率分量进行零点化。
这对你的20单元一维阵列(如阵列x)来说意味着什么?L最高频率箱(包括L/2正频率和L/2负频率)是这样的。
lower = (len(x)-L)/2+1
upper = (len(x)+L)/2+1
x[lower:upper]类似地,对于20x20x20三维数组(例如数组y),沿每个轴的L最高频率箱是:
lower = [(d-L)/2+1 for d in y.shape]
upper = [(d+L)/2+1 for d in y.shape]
y[lower[0]:upper[0],:,:] # middle of axis 0
y[:,lower[1]:upper[1],:] # middle of axis 1
y[:,:,lower[2]:upper[2]] # middle of axis 2现在假设这篇文章由hotpaw2撰写中描述的振铃效应不是您的应用程序的问题,那么您可以用以下方法将这些回收箱清零:
import numpy as np;
L = 3 # number of bins to zero out along each axis (change this to fit your needs)
# should be odd for even length array, and even for odd length array
# Following assumes x is the 1D array
lower = (len(x)-L)/2+1
upper = (len(x)+L)/2+1
x[lower:upper] = 0 # zero-out in the middle
# Following assume y is the 3D array
lower = [(d-L)/2+1 for d in y.shape]
upper = [(d+L)/2+1 for d in y.shape]
y[lower[0]:upper[0],:,:] = 0 # zero-out in the middle of axis 0
y[:,lower[1]:upper[1],:] = 0 # zero-out in the middle of axis 1
y[:,:,lower[2]:upper[2]] = 0 # zero-out in the middle of axis 2https://stackoverflow.com/questions/35589725
复制相似问题