title: Python - performing FFT ignore DC offset from MEMS microphone
body: <p>I'm trying to perform FFT of a wav file which results well, but in my plot I see huge amplitude at 0 Hz. I assumed it is a DC offset. My purpose is to ignore this DC offset in my plot or directly in code because it prevents me from seeing actual noises. In my example I record a noise around 6.1kHz, I can clearly see it, if I zoom at that point but in general view it is not observable because of the 0Hz amplitude. If you tell me how can ignore 0Hz (or DC bias) I will be glad. </p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  from __future__ import print_function
  import scipy.io.wavfile as wavfile
  import scipy
  import scipy.fftpack
  import numpy as np
  from matplotlib import pyplot as plt
  
  fs_rate, signal = wavfile.read("file.wav")
  print ("Frequency sampling", fs_rate)
  l_audio = len(signal.shape)
  print ("Channels", l_audio)
  if l_audio == 2:
      signal = signal.sum(axis=1) / 2
  N = signal.shape[0]
  print ("Complete Samplings N", N)
  secs = N / float(fs_rate)
  print ("secs", secs)
  Ts = 1.0/fs_rate # sampling interval in time
  print ("Timestep between samples Ts", Ts)
  t = scipy.arange(0, secs, Ts) # time vector as scipy arange field / numpy.ndarray
  FFT = abs(scipy.fft(signal))
  FFT_side = FFT[range(N/4)] # one side FFT range
  freqs = scipy.fftpack.fftfreq(signal.size, t[1]-t[0])
  fft_freqs = np.array(freqs)
  freqs_side = freqs[range(N/4)] # one side frequency range
  fft_freqs_side = np.array(freqs_side)
  
  print (abs(FFT_side))
  
  plt.subplot(211)
  p1 = plt.plot(t, signal, "g") # plotting the signal
  plt.xlabel('Time')
  plt.ylabel('Amplitude')
  
  plt.subplot(212)
  p2 = plt.plot(freqs_side, abs(FFT_side), "b") # plotting the positive fft spectrum
  plt.xlabel('Frequency (Hz)')
  plt.ylabel('Count single-sided')
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/PXlzZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PXlzZ.png" alt="zoomed plot"></a>
  <a href="https://i.stack.imgur.com/PRaq3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PRaq3.png" alt="normal plot"></a></p>