title: Why numpy fft return incorrect phase information?
body: <p>I compare phase and amplitude spectrum in Matlab and numpy. I think Matlab work correct, but numpy compute correct amplitude spectrum, but phase spectrum is strange. How i must change python code for correct computing fft by numpy?</p>
  
  <p>Matlab:</p>
  
  <pre><code>fs = 1e4;
  dt = 1 / fs;
  t = 0:dt:0.5;
  F = 1e3;
  
  y = cos(2*pi*F*t);
  S = fftshift(fft(y) / length(y));
  f_scale = linspace(-1, 1, length(y)) * (fs / 2);
  
  a = abs(S);
  phi = (angle(S));
  
  subplot(2, 1, 1)
  plot(f_scale, a)
  title('amplitude')
  
  subplot(2, 1, 2)
  plot(f_scale, phi)
  title('phase')
  </code></pre>
  
  <p>Python:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  fs = 1e4
  dt = 1 / fs
  t = np.arange(0, 0.5, dt)
  F = 1e3
  
  y = np.cos(2*np.pi*F*t)
  S = np.fft.fftshift(np.fft.fft(y) / y.shape[0])
  f_scale = np.linspace(-1, 1, y.shape[0]) * (fs / 2)
  
  a = np.abs(S)
  phi = np.angle(S)
  
  plt.subplot(2, 1, 1, title="amplitude")
  plt.plot(f_scale, a)
  
  plt.subplot(2, 1, 2, title="phase")
  plt.plot(f_scale, phi)
  
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vdgJ2.png" rel="noreferrer">matlab output</a></p>
  
  <p><a href="https://i.stack.imgur.com/AsexQ.png" rel="noreferrer">numpy output</a></p>