Analysing peaks in python
<p>I have these data-set which consist of close to perfectly spaced peaks. The peaks are not dirac delta functions but more of a gaussian shape. I need to analyze the distance between the peaks very precisely using python. 
<a href="https://i.stack.imgur.com/dogSv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dogSv.png" alt="enter image description here"></a></p>

<p>I am a beginner at python so I would really appreciate some help. 
The files are of the type <code>.csv</code> and <code>.h5</code>.</p>

<p>(I found out that the <code>.csv</code> files got too big for large samples so I had to switch to <code>.h5</code>.)</p>

<p>In my analyzing so far I have used the <code>pandas</code>-package and <code>numpy</code>-package and my guess is that they would also be able to solve this problem for me.</p>

<p>So I got this idea that I can filter out specific points on the peaks so. I tried this:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#data = [time,voltage]
data1 = pd.read_csv('1pps_withoutReference.csv', sep=',')

#Plot data
time = data1["x"];
voltage = data1["y"];
plt.plot(time,voltage)
plt.show()

t = data1["x"];
v = data1["y"];

if n+1&gt;4 and n-1&lt;4: n=n;
else v.remove('n');
for n in v;
</code></pre>

<p>I guess the idea of what I am trying to do in that last part is pretty clear but it is simply not working. 
I only wnat the points where the point right before is less than 4 and the point right after is above. This should give me discrete values and would only result in a tiny offset which is not really relevant since I am looking for the distance between the peaks. </p>

<p>I have solved the problem by the help of a friend.</p>

<pre><code>#getting t values for every peak.
time = data1["x"]
volt = data1["y"]

trig_lev = 2.5
#Creating new vector to contain the values of the peaks
t_peak = []
#For-loop updating the list with the disired values
for i in np.arange(0, len(time)):
    if volt[i] &lt; trig_lev and volt[i+1] &gt;= trig_lev:
    t_peak.append(time[i])
</code></pre>