How to do it…

To follow with the example, we need to continue with the following steps:

  1. The basic routines in the scipy.fftpack module compute the DFT and its inverse, for discrete signals in any dimension—fft, ifft (one dimension), fft2, ifft2 (two dimensions), and fftn, ifftn (any number of dimensions).
  2. Verify all these routines assume that the data is complex valued. If we know beforehand that a particular dataset is actually real-valued, and should offer real-valued frequencies, we use rfft and irfft instead, for a faster algorithm.
  3. In order to complete with this, these routines are designed so that composition with their inverses always yields the identity.
  4. The syntax is the same in all cases, as follows:
fft(x[, n, axis, overwrite_x])

The first parameter, x, is always the signal in any array-like form. Note that fft performs one-dimensional transforms. This means that if x happens to be two-dimensional, for example, fft will output another two-dimensional array, where each row is the transform of each row of the original. We can use columns instead, with the optional axis parameter. The rest of the parameters are also optional; n indicates the length of the transform and overwrite_x gets rid of the original data to save memory and resources. We usually play with the n integer when we need to pad the signal with zeros or truncate it. For a higher dimension, n is substituted by shape (a tuple) and axis by axes (another tuple).

To better understand the output, it is often useful to shift the zero frequencies to the center of the output arrays with fftshift. The inverse of this operation, ifftshift, is also included in the module. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset