Table of Contents

Peak Detection

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()


[ 59 210 560]
[ 0.02953278  0.10511667  0.28031111] [ 3.97946503  3.9853428   3.97952441]
[160 309 659]
[ 0.08008889  0.15467167  0.32986611] [ 4.87014174  4.86667084  4.86558207]
[359 509 859]
[ 0.17969944  0.25478278  0.42997722] [ 3.69726257  3.69647678  3.69541703]