code: def fourier(self, freq=None):
          
          def get(y, freq):
              y = y - mean(y)
              nframes = len(y)
              ft = fft.fft(y)
              ft = ft[0:int(fix(nframes/2))]
              ampFt = 2*abs(ft)/nframes
              amp = ampFt[freq]
              ampSum = sqrt(sum(ampFt**2))
              co = amp / ampSum
              ph = -(pi/2) - angle(ft[freq])
              if ph < 0:
                  ph += pi * 2
              return array([co, ph])
  
          if freq >= int(fix(size(self.index)/2)):
              raise Exception('Requested frequency, %g, is too high, '
                              'must be less than half the series duration' % freq)
  
          index = ['coherence', 'phase']
          return self.map(lambda x: get(x, freq), index=index)
docs: Compute statistics of a Fourier decomposition on series data.
  
          Parameters
          ----------
          freq : int
              Digital frequency at which to compute coherence and phase