Python module with different methods to identify peaks from data like histograms and time-series data
Project description
Identifying peaks from data is one of the most common tasks in many research and development tasks. pypeaks is a python module to detect peaks from any data like histograms and time-series.
Following are the available methods implemented in this module for peak detection: * Slope based method, where peaks are located based on how the data varies. * Intervals based method, where a set of intervals can be passed to provide apriori information that there will be at most one peak in each interval, and we just pick the maximum in each interval, filtering out irrelevant peaks at the end. * A hybrid method which combines these two methods.
Installation
$ sudo pip install --upgrade pypeaks
Usage
There is an example case included along with the code. If you don’t have this folder, please load your data instead. Or get it from https://github.com/gopalkoduri/pypeaks.
Important note
The peak finding function expects a normalized smoothed histogram. It does smoothing by default. If you want to change the smoothness, customize the corresponding argument. If the data is not normalized (so that the area under the curve comes to 1), there is a function provided to do that. If you don’t get any peaks, then you probably overlooked this!
import pickle from pypeaks import Data, Intervals [x, y] = pickle.load(file('examples/sample-histogram.pickle')) data_obj = Data(x, y, smoothness=11) #Peaks by slope method data_obj.get_peaks(method='slope') #print data_obj.peaks data_obj.plot() #Peaks by interval method ji_intervals = pickle.load('examples/ji_intervals.pickle') ji_intervals = Intervals(ji_intervals) data_obj.get_peaks(method='interval', intervals=ji_intervals) #print data_obj.peaks data_obj.plot(intervals=ji_intervals) #Read the help on Data object, and everything else is explained there. help(Data)
In case you face some issue, report it on github, or write to me at gopala [dot] koduri [at] gmail [dot] com!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pypeaks-2024.9.8.tar.gz
.
File metadata
- Download URL: pypeaks-2024.9.8.tar.gz
- Upload date:
- Size: 144.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4b423be3ef02671285bc12bd5821b8546205390e94fb995f2f0e2c25efc8d5 |
|
MD5 | 44cdc28c75897f56906227b162d104c6 |
|
BLAKE2b-256 | 77a8373644aec663f0cd9f27bd1cc4aaa3275f698f14a049189dbc0e74eafa92 |
File details
Details for the file pypeaks-2024.9.8-py3-none-any.whl
.
File metadata
- Download URL: pypeaks-2024.9.8-py3-none-any.whl
- Upload date:
- Size: 131.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ab763b017baad2cbb7c77e3f4e47ae721cc3e73adefd4d897431605f34c01ba |
|
MD5 | dd6a606593c38bc6c71f507c4513f196 |
|
BLAKE2b-256 | 068c1f89dff0e60973ec2e5f59770abba9af1b2004fd5e2e51db864e513398b8 |