Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- from pylab import *
- from scipy import *
- from numpy import sin, linspace, pi, correlate
- from pylab import plot, show, title, xlabel, ylabel, subplot
- from scipy import fft, arange, signal, misc
- from scipy import array
- def intAC(eFieldSVEA):
- '''
- Compuite the optical autocorrelation trace
- '''
- result = signal.correlate(eFieldSVEA, eFieldSVEA, mode='full')
- return result[result.size/2:]
- def autocorr(x):
- result = correlate(x, x, mode='full')
- return result[result.size/2:]
- def plotSpectrum(y,Fs):
- """
- Plots a Single-Sided Amplitude Spectrum of y(t)
- """
- n = len(y) # length of the signal
- k = arange(n)
- T = n/Fs
- frq = k/T # two sides frequency range
- frq = frq[range(n/2)] # one side frequency range
- Y = rfft(y)/n # fft computing and normalization
- Y = Y[range(n/2)]
- plot(frq,abs(Y),'r') # plotting the spectrum
- xlabel('f (Hz)')
- ylabel('|Y(f)|')
- infile = open('wcdma2.csv', 'r')
- wcdmaMeasurements = []
- timestamps = []
- Fs = 32496000
- for value in infile:
- value = value.split('\n')[0]
- wcdmaMeasurements.append(value)
- #print str(int(value)*1000)
- for i in range(len(wcdmaMeasurements)):
- timestamps.append(float((i/Fs)))
- #print str(i*1/fs)
- print type(array(wcdmaMeasurements))
- test = signal.correlate(array(wcdmaMeasurements),array(wcdmaMeasurements), mode='full')
- #subplot(311)
- #plot(timestamps, wcdmaMeasurements)
- #xlabel('t (s)')
- #ylabel('y(t)')
- #title("Signal in Time and Frequency Domain")
- #subplot(312)
- #plot(intAC(array(wcdmaMeasurements)))
- #xlabel('t (s)')
- #ylabel('Corr Coeff')
- #subplot(313)
- #plotSpectrum(wcdmaMeasurements,Fs)
- #show()
Add Comment
Please, Sign In to add comment