Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

find positive splike-like peaks, using Delta_raise and Delta_fall thresholds.

Project description

Find positive spike-like peaks from 1-D array.

example

from peakdetect_delta import peakdetect, peakdetect_simpleedge

# peak are represented as a tuple ((pvalue, pidx), (sidx, eidx))
#   pvalue: value at pidx
#   pidx: index of the peak
#   sidx: index where y[sidx+1] - y[sidx] > rdelta
#   eidx: index where y[eidx] - y[eidx-1] < fdelta
#   so, y[sidx:eidx] takes the detected peak

# examples of peakdetect_simpleedge
# case 1.1
s = [0, 0, 1.5, 2, 0, 0]
assert peakdetect_simpleedge(s, rdelta=1, fdelta=-1) == [((2, 3), (1, 5))]

# case 1.2
s = [0, 2, 0, -2, 0, -2]
assert peakdetect_simpleedge(s, rdelta=1, fdelta=1) == [((2, 1), (0, 3)),
                                                        ((0, 4), (3, 6))]

# example of peakdetect
s= [0, 3, 0, 2, 0, 0, -1, 1, -2, -1]
# same as peakdetect_simpleedge
assert peakdetect(s, rdelta=1, fdelta=-1, minimumspace=-1)
           == [((3, 1), (0, 3)), ((2, 3), (2, 5)), ((1, 7), (6, 9))]
# first 2 peaks are merged
assert peakdetect(s, rdelta=1, fdelta=-1, minimumspace=0)
           == [((3, 1), (0, 5)), ((1, 7), (6, 9))]
peakdetect(s, rdelta=1, fdelta=-1, minimumspace=2)
           == [((3, 1), (0, 9))]

Project details


Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page