comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/fft/info.py @ 87:2a2c65a20a8b

Add Python libs and headers
author Chris Cannam
date Wed, 25 Feb 2015 14:05:22 +0000
parents
children
comparison
equal deleted inserted replaced
86:413a9d26189e 87:2a2c65a20a8b
1 """
2 Discrete Fourier Transform (:mod:`numpy.fft`)
3 =============================================
4
5 .. currentmodule:: numpy.fft
6
7 Standard FFTs
8 -------------
9
10 .. autosummary::
11 :toctree: generated/
12
13 fft Discrete Fourier transform.
14 ifft Inverse discrete Fourier transform.
15 fft2 Discrete Fourier transform in two dimensions.
16 ifft2 Inverse discrete Fourier transform in two dimensions.
17 fftn Discrete Fourier transform in N-dimensions.
18 ifftn Inverse discrete Fourier transform in N dimensions.
19
20 Real FFTs
21 ---------
22
23 .. autosummary::
24 :toctree: generated/
25
26 rfft Real discrete Fourier transform.
27 irfft Inverse real discrete Fourier transform.
28 rfft2 Real discrete Fourier transform in two dimensions.
29 irfft2 Inverse real discrete Fourier transform in two dimensions.
30 rfftn Real discrete Fourier transform in N dimensions.
31 irfftn Inverse real discrete Fourier transform in N dimensions.
32
33 Hermitian FFTs
34 --------------
35
36 .. autosummary::
37 :toctree: generated/
38
39 hfft Hermitian discrete Fourier transform.
40 ihfft Inverse Hermitian discrete Fourier transform.
41
42 Helper routines
43 ---------------
44
45 .. autosummary::
46 :toctree: generated/
47
48 fftfreq Discrete Fourier Transform sample frequencies.
49 rfftfreq DFT sample frequencies (for usage with rfft, irfft).
50 fftshift Shift zero-frequency component to center of spectrum.
51 ifftshift Inverse of fftshift.
52
53
54 Background information
55 ----------------------
56
57 Fourier analysis is fundamentally a method for expressing a function as a
58 sum of periodic components, and for recovering the function from those
59 components. When both the function and its Fourier transform are
60 replaced with discretized counterparts, it is called the discrete Fourier
61 transform (DFT). The DFT has become a mainstay of numerical computing in
62 part because of a very fast algorithm for computing it, called the Fast
63 Fourier Transform (FFT), which was known to Gauss (1805) and was brought
64 to light in its current form by Cooley and Tukey [CT]_. Press et al. [NR]_
65 provide an accessible introduction to Fourier analysis and its
66 applications.
67
68 Because the discrete Fourier transform separates its input into
69 components that contribute at discrete frequencies, it has a great number
70 of applications in digital signal processing, e.g., for filtering, and in
71 this context the discretized input to the transform is customarily
72 referred to as a *signal*, which exists in the *time domain*. The output
73 is called a *spectrum* or *transform* and exists in the *frequency
74 domain*.
75
76 Implementation details
77 ----------------------
78
79 There are many ways to define the DFT, varying in the sign of the
80 exponent, normalization, etc. In this implementation, the DFT is defined
81 as
82
83 .. math::
84 A_k = \\sum_{m=0}^{n-1} a_m \\exp\\left\\{-2\\pi i{mk \\over n}\\right\\}
85 \\qquad k = 0,\\ldots,n-1.
86
87 The DFT is in general defined for complex inputs and outputs, and a
88 single-frequency component at linear frequency :math:`f` is
89 represented by a complex exponential
90 :math:`a_m = \\exp\\{2\\pi i\\,f m\\Delta t\\}`, where :math:`\\Delta t`
91 is the sampling interval.
92
93 The values in the result follow so-called "standard" order: If ``A =
94 fft(a, n)``, then ``A[0]`` contains the zero-frequency term (the mean of
95 the signal), which is always purely real for real inputs. Then ``A[1:n/2]``
96 contains the positive-frequency terms, and ``A[n/2+1:]`` contains the
97 negative-frequency terms, in order of decreasingly negative frequency.
98 For an even number of input points, ``A[n/2]`` represents both positive and
99 negative Nyquist frequency, and is also purely real for real input. For
100 an odd number of input points, ``A[(n-1)/2]`` contains the largest positive
101 frequency, while ``A[(n+1)/2]`` contains the largest negative frequency.
102 The routine ``np.fft.fftfreq(n)`` returns an array giving the frequencies
103 of corresponding elements in the output. The routine
104 ``np.fft.fftshift(A)`` shifts transforms and their frequencies to put the
105 zero-frequency components in the middle, and ``np.fft.ifftshift(A)`` undoes
106 that shift.
107
108 When the input `a` is a time-domain signal and ``A = fft(a)``, ``np.abs(A)``
109 is its amplitude spectrum and ``np.abs(A)**2`` is its power spectrum.
110 The phase spectrum is obtained by ``np.angle(A)``.
111
112 The inverse DFT is defined as
113
114 .. math::
115 a_m = \\frac{1}{n}\\sum_{k=0}^{n-1}A_k\\exp\\left\\{2\\pi i{mk\\over n}\\right\\}
116 \\qquad m = 0,\\ldots,n-1.
117
118 It differs from the forward transform by the sign of the exponential
119 argument and the normalization by :math:`1/n`.
120
121 Real and Hermitian transforms
122 -----------------------------
123
124 When the input is purely real, its transform is Hermitian, i.e., the
125 component at frequency :math:`f_k` is the complex conjugate of the
126 component at frequency :math:`-f_k`, which means that for real
127 inputs there is no information in the negative frequency components that
128 is not already available from the positive frequency components.
129 The family of `rfft` functions is
130 designed to operate on real inputs, and exploits this symmetry by
131 computing only the positive frequency components, up to and including the
132 Nyquist frequency. Thus, ``n`` input points produce ``n/2+1`` complex
133 output points. The inverses of this family assumes the same symmetry of
134 its input, and for an output of ``n`` points uses ``n/2+1`` input points.
135
136 Correspondingly, when the spectrum is purely real, the signal is
137 Hermitian. The `hfft` family of functions exploits this symmetry by
138 using ``n/2+1`` complex points in the input (time) domain for ``n`` real
139 points in the frequency domain.
140
141 In higher dimensions, FFTs are used, e.g., for image analysis and
142 filtering. The computational efficiency of the FFT means that it can
143 also be a faster way to compute large convolutions, using the property
144 that a convolution in the time domain is equivalent to a point-by-point
145 multiplication in the frequency domain.
146
147 Higher dimensions
148 -----------------
149
150 In two dimensions, the DFT is defined as
151
152 .. math::
153 A_{kl} = \\sum_{m=0}^{M-1} \\sum_{n=0}^{N-1}
154 a_{mn}\\exp\\left\\{-2\\pi i \\left({mk\\over M}+{nl\\over N}\\right)\\right\\}
155 \\qquad k = 0, \\ldots, M-1;\\quad l = 0, \\ldots, N-1,
156
157 which extends in the obvious way to higher dimensions, and the inverses
158 in higher dimensions also extend in the same way.
159
160 References
161 ----------
162
163 .. [CT] Cooley, James W., and John W. Tukey, 1965, "An algorithm for the
164 machine calculation of complex Fourier series," *Math. Comput.*
165 19: 297-301.
166
167 .. [NR] Press, W., Teukolsky, S., Vetterline, W.T., and Flannery, B.P.,
168 2007, *Numerical Recipes: The Art of Scientific Computing*, ch.
169 12-13. Cambridge Univ. Press, Cambridge, UK.
170
171 Examples
172 --------
173
174 For examples, see the various functions.
175
176 """
177 from __future__ import division, absolute_import, print_function
178
179 depends = ['core']