import matplotlib.pyplot as plt
import numpy as np
def CreateSeries(File,FreqRef):
with open(File) as f:
content = f.readlines()
V = [x.strip().split("\t")[1] for x in content]
V = np.array(V).astype(np.int)
t = [x.strip().split("\t")[0] for x in content]
t = np.array(t).astype(np.float)/FreqRef
MaxT = t[-1]*FreqRef
return t,V,MaxT
t,V,MaxT = CreateSeries("FirstAcq.data",10000000)
print MaxT
856908.0
plt.plot(t, V)
plt.show()
ADC1_pins = [21,22,19,15,13,11,12,10, 8]
ADC1_GPIO = [9, 25,10,22,27,17,18,15,14]
ADC2_pins = [38,37,36,35,33,32,26,24,23]
ADC2_GPIO = [20,26,16,19,13,12, 7, 8,11]
ADC1len = len(ADC1_GPIO)
ADC1len = len(ADC2_GPIO)
def GetV1(Volts):
Map = np.zeros((len(V),34), dtype=np.int)
for i in range(len(Volts)):
val = V[i]
for k in range(34):
Map[i][k] = (val & 2**k)/2**k
return Map
Map = np.asarray(GetV1(V))
Map
array([[1, 1, 1, ..., 0, 0, 0],
[1, 1, 1, ..., 0, 0, 0],
[1, 1, 1, ..., 0, 0, 0],
...,
[1, 1, 1, ..., 0, 0, 0],
[1, 1, 1, ..., 0, 0, 0],
[1, 1, 1, ..., 0, 0, 0]])
im = plt.imshow(Map, cmap='hot', aspect="auto")
plt.show()
plt.plot(np.var(Map,0))
plt.show()
for m in range(32):
if (np.var(Map,0)[m]):
print str(m)+" - "+str(np.var(Map,0)[m])
4 - 0.24969024
7 - 0.045696
8 - 0.03125671
11 - 0.03986944
12 - 0.03959431
13 - 0.03757119
16 - 0.04605744
19 - 0.042064
20 - 0.24127644
26 - 0.226896
ADC2_GPIO = [20,26,16,19,13,12, 7, 8,11]
ADC2len = len(ADC2_GPIO)
def GetV2(Volts):
Signal = []
Map = np.zeros((len(V),ADC2len), dtype=np.int)
for i in range(len(Volts)):
val = V[i]
SignalZero = 0
for k in range(ADC2len):
Map[i][k] = (val & 2**k)/2**k
for k in range(ADC2len):
SignalZero += 2**k*((val & 2**ADC2_GPIO[k])/2**ADC2_GPIO[k])
Signal.append(SignalZero)
return Signal,Map
M = GetV2(V)[0]
plt.plot(t[0:1700],M[0:1700])
plt.show()