In [14]:
import matplotlib.pyplot as plt
%matplotlib inline
import math
import numpy as np

In [35]:
values = np.zeros((512))
with open("out.txt", "r") as f:
    count = 0
    for line in f:
        values[count] = int(line[:-1].split(",")[1][1:])
        count += 1
plt.plot(values)
plt.show()



In [42]:
values2 = np.zeros((1024))
with open("out2.txt", "r") as f:
    count = 0
    for line in f:
        values2[count] = int(line[:-1].split(",")[1][1:])
        count += 1
plt.plot(values2)
plt.show()



In [30]:
def detect_peak(start_index, end_index, values):
    index = 0
    for i in range(start_index+1, end_index-1):
        if values[i-1] < values[i] and values[i] > values[i+1] and values[i] > 0:
            index = i
            return i

print detect_peak(0, 512, values2)


51

In [29]:
print detect_peak(70, 512, values2)


128

In [25]:
print detect_peak(0, 512, values)


10

In [ ]: