title: Fourier transformation of experimental data into frequency domain
body: <p>I'm totally new to python. I have conducted a wave data test experiment. I have the time series data available with me. How do I proceed to show that in a frequency domain? Is there any examples I can refer to? I came up with a program as given below but it doesn't seem to work. Please help.</p>
  
  <pre><code>#Program for Fourier Transformation
  import numpy as np
  import numpy.fft as fft
  import matplotlib.pyplot as plt
  
  def readdat( filename ):
      """
          Reads sectional area curve data from file filename
      """
  
      # read all lines of input files
      fp = open( filename, 'r')
      lines = fp.readlines() # to read the tabulated data
      fp.close()
  
      # interpret data
      time = []
      ampl = []
      for line in lines:
          if line[0:1] == '#':
              continue # ignore comments in the file
          try:
              time.append(float(line.split()[0])) #first column is time
              ampl.append(float(line.split()[1])) # second column is corresponding amplitude
          except:
              # if the data interpretation fails..
              continue
      return np.asarray(time), np.asarray(ampl)
  
  if __name__ == '__main__':
  
      time, ampl = readdat( 'data.dat')
      print time
      print ampl
  
  spectrum = fft.fft(ampl)
  freq = fft.fftfreq(len(spectrum))
  print freq
  </code></pre>