title: Correct order of implementing fftshift and ifftshift (in python)
body: <p>I want to Fourier transform a function <code>psi(x)</code>, multiply it by a k-space function <code>exp(-kx^2-ky^2)</code>, and then inverse Fourier transform the product back to x-space. </p>
  
  <p>But my x-space and k-space grids are centred, and I know that I need <code>fftshift</code> and <code>ifftshift</code> to implement my k-space multiplication properly. But I don't understand how they work, so I don't know in which order to implement them. Could someone please tell me if I have done it correctly here?</p>
  
  <pre><code>import scipy.fftpack as spfft
  import numpy as np
  
  #Create a centred k-space grid]
  
  kxmax, kymax = 10,10
  kxgrid = np.linspace(-kxmax/2, kxmax/2, NX)
  kygrid = np.linspace(-kymax/2, kymax/2, NY)
  KX, KY = np.meshgrid(kxgrid, kygrid, indexing='xy')
  
  psi = spfft.ifft2(spfft.fftshift(np.exp(-(KX**2 + KY**2)) * spfft.fftshift(spfft.fft2(psi))))
  </code></pre>