In [1]:
import sys
sys.path.append("C:\Users\svejlani\Documents\expeyes-3.0.0\expeyes-3.0.0\eyes-junior")
import expeyes.eyesj
p=expeyes.eyesj.open()
In [2]:
t,v=p.capture(1,512,100)
#Capturing 512 samples at a sampling rate of 10KHz(100us Interval)
In [4]:
from pylab import *
In [8]:
%matplotlib inline
In [9]:
plot(t,v)
Out[9]:
[<matplotlib.lines.Line2D at 0xb91a978>]
In [10]:
import numpy as np
In [11]:
from scipy import fftpack as f
In [12]:
#convert t,v to numpy array
x_n=np.array(v)
In [13]:
plot(x_n)
Out[13]:
[<matplotlib.lines.Line2D at 0xbccb3c8>]
In [15]:
fft_x_n=f.fft(x_n)
In [16]:
plot(abs(fft_x_n))
Out[16]:
[<matplotlib.lines.Line2D at 0xc672438>]
In [18]:
#Finding Peaks using visual inspection of magnitude and finding corresponding index below
[x for x in range(len(fft_x_n)) if abs(fft_x_n[x]) > 500 ]
Out[18]:
[8, 504]
In [19]:
#Sampling freq=10KHz
#Max i/p freq = Fs/2 = 5KHz
#Max freq in DFT, is of pi which corresponds to mid-point sample in sample(post that spectrum repeats itself)
#so for 0-511 sample fft, sample 255 corresponds to max freq=5KHz.
#simple mapping results the peak's index(found above as 8) ,corresponds to as below:
(5.0/255)*8
Out[19]:
0.1568627450980392
In []:
#Freq of sine wave is around 156Hz ( The manual says "SINE wave: Fixed frequency sine wave generator, frequency is around 150Hz.")
#So in decent agreement for a 512 point FFT sampled at rate of 10KHz