numpy.fft.rfft(a,n=None,axis=-1,norm=None)[source]¶Compute the one-dimensional discrete Fourier Transform for real input.
This function computes the one-dimensionaln-point discrete FourierTransform (DFT) of a real-valued array by means of an efficient algorithmcalled the Fast Fourier Transform (FFT).
| Parameters: |
|
|---|---|
| Returns: |
|
| Raises: |
|
See also
Notes
When the DFT is computed for purely real input, the output isHermitian-symmetric, i.e. the negative frequency terms are just the complexconjugates of the corresponding positive-frequency terms, and thenegative-frequency terms are therefore redundant. This function does notcompute the negative frequency terms, and the length of the transformedaxis of the output is thereforen//2+1.
WhenA=rfft(a) and fs is the sampling frequency,A[0] containsthe zero-frequency term 0*fs, which is real due to Hermitian symmetry.
Ifn is even,A[-1] contains the term representing both positiveand negative Nyquist frequency (+fs/2 and -fs/2), and must also be purelyreal. Ifn is odd, there is no term at fs/2;A[-1] containsthe largest positive frequency (fs/2*(n-1)/n), and is complex in thegeneral case.
If the inputa contains an imaginary part, it is silently discarded.
Examples
>>>np.fft.fft([0,1,0,0])array([ 1.+0.j, 0.-1.j, -1.+0.j, 0.+1.j])>>>np.fft.rfft([0,1,0,0])array([ 1.+0.j, 0.-1.j, -1.+0.j])
Notice how the final element of thefft output is the complex conjugateof the second element, for real input. Forrfft, this symmetry isexploited to compute only the non-negative frequency terms.