title: Adding noise to a 2D cosine function and doing FFT
body: <p>I am trying to properly add noise to each cosine function and then take the FFT of the sum of the cosines. I am currently doing it like so:</p>
  <pre><code>import numpy as np
  
  k = np.linspace(0,4.76*10,2400)
  kx,ky = np.meshgrid(k, k)
  
  rx = np.array([0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4])
  ry = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8])
  ry = np.tile(ry,5)
  
  for i in range(0,4):
      a = np.full((8,), 0.5 + 0.1*i)
      rx = np.append(rx, a)
  
  tensx = np.tensordot(rx,kx, axes = 0)
  tensy = np.tensordot(ry,ky, axes = 0)
  z = (0.5*np.cos(2*np.pi*(tensx+tensy)) + np.random.normal(-.1, .1, ky.shape)).sum(axis=0)
  </code></pre>
  <p>Here is the FFT in 2D without noise:</p>
  <p><a href="https://i.stack.imgur.com/kXlN4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kXlN4.png" alt="enter image description here" /></a></p>
  <p>and here is the FFT in 2D with noise:</p>
  <p><a href="https://i.stack.imgur.com/AE5up.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AE5up.png" alt="enter image description here" /></a></p>
  <p>I am confused about two things:</p>
  <ol>
  <li><p>Why is there a high amplitude at [0,0] with the noise FFT? I change the noise to various ranges and the [0,0] amplitude stays.</p>
  </li>
  <li><p>Shouldnt there be more non-purple areas due to the noise or does everything really cancel out?</p>
  </li>
  </ol>
  <p>Here is the entire code if needed:</p>
  <pre><code>from scipy.fft import fft2, fftshift
  import numpy as np
  import matplotlib.pyplot as plt
  from skimage.filters import window
  from scipy.fftpack import fftfreq
  from skimage.feature import blob_dog, blob_log, blob_doh
  from scipy.signal import find_peaks
  
  import scipy.fftpack
  from scipy.fftpack import fftfreq
  from scipy.fft import fft
  from scipy.fft import fft2
  from scipy.fft import fftn
  
  
  k = np.linspace(0,4.76*10,2400)
  kx,ky = np.meshgrid(k, k)
  
  rx = np.array([0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4])
  ry = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8])
  ry = np.tile(ry,5)
  
  for i in range(0,4):
      a = np.full((8,), 0.5 + 0.1*i)
      rx = np.append(rx, a)
  
  tensx = np.tensordot(rx,kx, axes = 0)
  tensy = np.tensordot(ry,ky, axes = 0)
  z = (0.5*np.cos(2*np.pi*(tensx+tensy)) + np.random.normal(-.1, .1, ky.shape)).sum(axis=0)
  
  
  wz = z * window('hann', z.shape)
  plt.figure(0)
  plt.imshow(wz, origin='lower')
  plt.colorbar()
  
  zf = np.abs(fftshift(fft2(wz)))[1200:, 1200:]
  
  
  fig, ax = plt.subplots()
  ax.set(xlim=(0, 1.5), ylim=(0, 1.5))
  
  f = fftfreq(len(k), np.diff(k)[0])
  plt.imshow(zf, origin='lower', extent=[0,f[:k.size//2][-1], 0 , f[:k.size//2][-1]])
  plt.xlabel('['+r'$\mathrm{\mu}$'+r'm]')
  plt.colorbar()
  plt.show()
  </code></pre>