code: def fft(fEM, time, freq, ftarg):
      r
      # Get ftarg values
      dfreq, nfreq, ntot, pts_per_dec = ftarg
  
      # If pts_per_dec, we have first to interpolate fEM to required freqs
      if pts_per_dec:
          sfEMr = iuSpline(np.log(freq), fEM.real)
          sfEMi = iuSpline(np.log(freq), fEM.imag)
          freq = np.arange(1, nfreq+1)*dfreq
          fEM = sfEMr(np.log(freq)) + 1j*sfEMi(np.log(freq))
  
      # Pad the frequency result
      fEM = np.pad(fEM, (0, ntot-nfreq), 'linear_ramp')
  
      # Carry out FFT
      ifftEM = fftpack.ifft(np.r_[fEM[1:], 0, fEM[::-1].conj()]).real
      stEM = 2*ntot*fftpack.fftshift(ifftEM*dfreq, 0)
  
      # Interpolate in time domain
      dt = 1/(2*ntot*dfreq)
      ifEM = iuSpline(np.linspace(-ntot, ntot-1, 2*ntot)*dt, stEM)
      tEM = ifEM(time)/2*np.pi  # (Multiplication of 2/pi in model.tem)
  
      # Return the electromagnetic time domain field
      # (Second argument is only for QWE)
      return tEM, True
docs: r"""Fourier Transform using the Fast Fourier Transform.
  
      The function is called from one of the modelling routines in :mod:`model`.
      Consult these modelling routines for a description of the input and output
      parameters.
  
      Returns
      -------
      tEM : array
          Returns time-domain EM response of ``fEM`` for given ``time``.
  
      conv : bool
          Only relevant for QWE/QUAD.