title: Numpy FFT (Fast Fourier Transformation) of 1-dimensional array
body: <p>I have a simple one-dimensional array like <code>[0,0,0,0,0,1,1,1,1,1,0,0,0,0,0]</code> which describes a square impulse. I would like to transform this impulse to the frequency domain and plot its magnitude spectrum by using the code below (I got it from <a href="http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.html" rel="nofollow">OpenCV Python Tutorials</a>):</p>
  
  <pre><code>squareimpulse = np.array([0,0,0,0,0,1,1,1,1,1,0,0,0,0,0])
  
  img = (squareimpulse)
  f = np.fft.fft(img)
  fshift = np.fft.fftshift(f)
  magnitude_spectrum = 20*np.log(np.abs(fshift))
  
  plt.subplot(121),plt.imshow(img, cmap = 'gray')
  plt.title('Input Image'), plt.xticks([]), plt.yticks([])
  plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')
  plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
  plt.show()
  </code></pre>
  
  <p>The script works fine for two-dimensional arrays with <code>f = np.fft.fft2(img)</code> but not for my case where I only got one dimension.</p>
  
  <p>Hope we can figure this out.</p>