The peak detection functionality can be used from peakutils library. Another option is from Eli Billauer script: http://billauer.co.il/peakdet.html
In [1]:
from matplotlib import pyplot as plt
from peakutils.plot import plot as pplot
import numpy as np
import pandas as pd
import peakutils
import matplotlib
import sys
In [2]:
# local
sys.path.insert(0, '../')
from pywim.utils import storage
In [3]:
# open file test
f = storage.open_file('../data/wim_day_001_01_20170324.h5')
data = storage.dataset_to_dataframe(f[list(f.keys())[0]])
In [4]:
data.plot()
plt.grid(True)
plt.show()
In [5]:
plt.figure(figsize=(10,6))
x = data.index.values
for k in data.keys():
y = data[k].values
indexes = peakutils.indexes(y, thres=0.5, min_dist=30)
print(indexes)
print(x[indexes], y[indexes])
pplot(x, y, indexes)
plt.title('First estimate')
plt.grid(True)
plt.show()