Guest User

Untitled

a guest
Jun 17th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. from __future__ import division
  2. from pylab import *
  3. from scipy import *
  4. from numpy import sin, linspace, pi, correlate
  5. from pylab import plot, show, title, xlabel, ylabel, subplot
  6. from scipy import fft, arange, signal, misc
  7. from scipy import array
  8.  
  9. def intAC(eFieldSVEA):
  10.     '''
  11.    Compuite the optical autocorrelation trace
  12.    '''
  13.     result = signal.correlate(eFieldSVEA, eFieldSVEA, mode='full')  
  14.  
  15.     return result[result.size/2:]
  16.  
  17. def autocorr(x):
  18.     result = correlate(x, x, mode='full')
  19.     return result[result.size/2:]
  20.  
  21. def plotSpectrum(y,Fs):
  22.  """
  23. Plots a Single-Sided Amplitude Spectrum of y(t)
  24. """
  25.  n = len(y) # length of the signal
  26.  k = arange(n)
  27.  T = n/Fs
  28.  frq = k/T # two sides frequency range
  29.  frq = frq[range(n/2)] # one side frequency range
  30.  
  31.  Y = rfft(y)/n # fft computing and normalization
  32.  Y = Y[range(n/2)]
  33.  
  34.  plot(frq,abs(Y),'r') # plotting the spectrum
  35.  xlabel('f (Hz)')
  36.  ylabel('|Y(f)|')
  37.  
  38. infile = open('wcdma2.csv', 'r')
  39.  
  40. wcdmaMeasurements = []
  41. timestamps = []
  42.  
  43. Fs = 32496000
  44.  
  45. for value in infile:
  46.     value = value.split('\n')[0]
  47.     wcdmaMeasurements.append(value)
  48.     #print str(int(value)*1000)
  49.  
  50. for i in range(len(wcdmaMeasurements)):
  51.     timestamps.append(float((i/Fs)))
  52.     #print str(i*1/fs)
  53.  
  54. print type(array(wcdmaMeasurements))
  55.  
  56. test = signal.correlate(array(wcdmaMeasurements),array(wcdmaMeasurements), mode='full')
  57.  
  58. #subplot(311)
  59. #plot(timestamps, wcdmaMeasurements)
  60. #xlabel('t (s)')
  61. #ylabel('y(t)')
  62. #title("Signal in Time and Frequency Domain")
  63. #subplot(312)
  64. #plot(intAC(array(wcdmaMeasurements)))
  65. #xlabel('t (s)')
  66. #ylabel('Corr Coeff')
  67. #subplot(313)
  68. #plotSpectrum(wcdmaMeasurements,Fs)
  69. #show()
Add Comment
Please, Sign In to add comment