概述
文章
- 基础篇
- 进阶篇
- 其他篇
用户指南
NumPy 参考手册
- 数组对象
- 常量
- 通函数(ufunc)
- 常用 API
- 创建数组
- 数组处理程序
- 二进制运算
- 字符串操作
- C-Types 外部函数接口(numpy.ctypeslib)
- 时间日期相关
- 数据类型相关
- 可选的 Scipy 加速支持(numpy.dual)
- 具有自动域的数学函数( numpy.emath)
- 浮点错误处理
- 离散傅立叶变换(numpy.fft)
- 财金相关
- 实用的功能
- 特殊的 NumPy 帮助功能
- 索引相关
- 输入和输出
- 线性代数(numpy.linalg)
- 逻辑函数
- 操作掩码数组
- 数学函数(Mathematical functions)
- 矩阵库 (numpy.matlib)
- 杂项(Miscellaneous routines)
- 填充数组(Padding Arrays)
- 多项式(Polynomials)
- 随机抽样 (numpy.random)
- 操作集合(Set routines)
- 排序,搜索和计数(Sorting, searching, and counting)
- Statistics
- Test Support (numpy.testing)
- Window functions
- 打包(numpy.distutils)
- NumPy Distutils 用户指南
- NumPy C-API
- NumPy 的内部
- NumPy 和 SWIG
其他文档
离散傅立叶变换(numpy.fft)
标准 FFTs
方法 | 描述 |
---|---|
fftopen in new window(a[, n, axis, norm]) | 计算一维离散傅立叶变换。 |
ifftopen in new window(a[, n, axis, norm]) | 计算一维离散傅立叶逆变换。 |
fft2open in new window(a[, s, axes, norm]) | 计算二维离散傅立叶变换 |
ifft2open in new window(a[, s, axes, norm]) | 计算二维离散傅立叶逆变换。 |
fftnopen in new window(a[, s, axes, norm]) | 计算N维离散傅立叶变换。 |
ifftnopen in new window(a[, s, axes, norm]) | 计算N维逆离散傅立叶变换。 |
实际 FFTs
方法 | 描述 |
---|---|
rfftopen in new window(a[, n, axis, norm]) | 计算实数输入的一维离散傅立叶变换。 |
irfftopen in new window(a[, n, axis, norm]) | 对于实输入,计算n点DFT的逆。 |
rfft2open in new window(a[, s, axes, norm]) | 计算实数组的二维FFT。 |
irfft2open in new window(a[, s, axes, norm]) | 计算实数组的二维逆FFT。 |
rfftnopen in new window(a[, s, axes, norm]) | 计算实输入的N维离散傅立叶变换。 |
irfftnopen in new window(a[, s, axes, norm]) | 计算实输入的N维FFT的逆。 |
厄米特 FFTs
方法 | 描述 |
---|---|
hfftopen in new window(a[, n, axis, norm]) | 计算具有厄米特对称性的信号的FFT,即实谱。 |
ihfftopen in new window(a[, n, axis, norm]) | 计算具有厄米特对称性的信号的逆FFT。 |
帮助
方法 | 描述 |
---|---|
fftfreqopen in new window(n[, d]) | 返回离散傅立叶变换采样频率。 |
rfftfreqopen in new window(n[, d]) | 返回离散傅立叶变换采样频率(用于rfft、irfft)。 |
fftshiftopen in new window(x[, axes]) | 将零频率分量移至频谱中心。 |
ifftshiftopen in new window(x[, axes]) | fftshiftopen in new window的逆。 |
背景资料
傅立叶分析基本上是一种方法,用于将函数表示为周期分量之和, 并用于从这些分量中恢复函数。当函数及其傅立叶变换都被离散化的对应物替换时, 它被称为离散傅立叶变换(DFT)。DFT已成为数值计算的支柱, 部分原因是因为有一种计算它的非常快的算法,称为快速傅立叶变换(FFT), 高斯(1805)已知,并由Cooley和Tukey[CT]以其当前形式曝光。 Press et al.。[NR]提供傅立叶分析及其应用的易懂介绍。
因为离散傅立叶变换将其输入分离成在离散频率上贡献的分量, 所以它在数字信号处理中具有大量的应用, 例如用于滤波,并且在这种情况下, 对变换的离散化输入通常被称为信号, 其存在于时域中。输出被称为频谱 或 变换,并且存在于 频域 中。
实施细节
有许多方法来定义DFT,在指数符号、归一化等方面有所不同。在此实现中,DFT被定义为:
The DFT is in general defined for complex inputs and outputs, and a single-frequency component at linear frequency is represented by a complex exponential , where is the sampling interval.
The values in the result follow so-called “standard” order: If A = fft(a, n)
, then A[0]
contains the zero-frequency term (the sum of the signal), which is always purely real for real inputs. Then A[1:n/2]
contains the positive-frequency terms, and A[n/2+1:]
contains the negative-frequency terms, in order of decreasingly negative frequency. For an even number of input points, A[n/2]
represents both positive and negative Nyquist frequency, and is also purely real for real input. For an odd number of input points, A[(n-1)/2]
contains the largest positive frequency, while A[(n+1)/2]
contains the largest negative frequency. The routine np.fft.fftfreq(n)
returns an array giving the frequencies of corresponding elements in the output. The routine np.fft.fftshift(A)
shifts transforms and their frequencies to put the zero-frequency components in the middle, and np.fft.ifftshift(A)
undoes that shift.
When the input a is a time-domain signal and A = fft(a)
, np.abs(A)
is its amplitude spectrum and np.abs(A)**2
is its power spectrum. The phase spectrum is obtained by np.angle(A)
.
The inverse DFT is defined as
It differs from the forward transform by the sign of the exponential argument and the default normalization by 1/n.
Normalization
The default normalization has the direct transforms unscaled and the inverse transforms are scaled by 1/n. It is possible to obtain unitary transforms by setting the keyword argument norm
to "ortho"
(default is None) so that both direct and inverse transforms will be scaled by .
Real and Hermitian transforms
When the input is purely real, its transform is Hermitian, i.e., the component at frequency is the complex conjugate of the component at frequency , which means that for real inputs there is no information in the negative frequency components that is not already available from the positive frequency components. The family of rfft
open in new window functions is designed to operate on real inputs, and exploits this symmetry by computing only the positive frequency components, up to and including the Nyquist frequency. Thus, n
input points produce n/2+1
complex output points. The inverses of this family assumes the same symmetry of its input, and for an output of n
points uses n/2+1
input points.
Correspondingly, when the spectrum is purely real, the signal is Hermitian. The hfft
open in new window family of functions exploits this symmetry by using n/2+1
complex points in the input (time) domain for n
real points in the frequency domain.
In higher dimensions, FFTs are used, e.g., for image analysis and filtering. The computational efficiency of the FFT means that it can also be a faster way to compute large convolutions, using the property that a convolution in the time domain is equivalent to a point-by-point multiplication in the frequency domain.
高维度
在二维中,DFT定义为:
它以明显的方式延伸到更高的维度,并且在更高维度中的倒数也以同样的方式延伸。
参考文献
[CT]Cooley, James W., and John W. Tukey, 1965, “An algorithm for the machine calculation of complex Fourier series,” Math. Comput. 19: 297-301.
[NR]Press, W., Teukolsky, S., Vetterline, W.T., and Flannery, B.P., 2007, Numerical Recipes: The Art of Scientific Computing, ch. 12-13. Cambridge Univ. Press, Cambridge, UK.
示例
有关示例,请参见各种函数。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论