4.3. findpeaks

Functions to find peaks in data above a certain threshold as part of the EQcorrscan package written by Calum Chamberlain of Victoria University of Wellington in early 2015.

Copyright 2015 Calum Chamberlain

This file is part of EQcorrscan.

EQcorrscan is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EQcorrscan is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with EQcorrscan. If not, see <http://www.gnu.org/licenses/>.

findpeaks.find_peaks2(arr, thresh, trig_int, debug=0, maxwidth=10, starttime=False, samp_rate=1.0)[source]

Function to determine peaks in an array of data using scipy find_peaks_cwt, works fast in certain cases, but for match_filter cccsum peak finding, find_peaks2_short works better. Test it out and see which works best for your application.

Parameters:
  • arr (ndarray) – 1-D numpy array is required
  • thresh (float) – The threshold below which will be considered noise and

peaks will not be found in. :type trig_int: int :param trig_int: The minimum difference in samples between triggers, if multiple peaks within this window this code will find the highest. :type debug: int :param debug: Optional, debug level 0-5 :type maxwidth: int :param maxwidth: Maximum peak width to look for in samples :type starttime: osbpy.UTCDateTime :param starttime: Starttime for plotting, only used if debug > 2. :type samp_rate: float :param samp_rate: Sampling rate in Hz, only used for plotting if debug > 2.

Returns:peaks: Lists of tuples of peak values and locations.
findpeaks.find_peaks2_short(arr, thresh, trig_int, debug=0, starttime=False, samp_rate=1.0)[source]

Function to determine peaks in an array of data above a certain threshold. Uses a mask to remove data below threshold and finds peaks in what is left.

Parameters:
  • arr (ndarray) – 1-D numpy array is required
  • thresh (float) – The threshold below which will be considered noise and peaks will not be found in.
  • trig_int (int) – The minimum difference in samples between triggers,if multiple peaks within this window this code will find the highest.
  • debug (int) – Optional, debug level 0-5
  • starttime (osbpy.UTCDateTime) – Starttime for plotting, only used if debug > 2.
  • samp_rate (float) – Sampling rate in Hz, only used for plotting if debug > 2.
Returns:

peaks: Lists of tuples of peak values and locations.

findpeaks.find_peaks_dep(arr, thresh, trig_int, debug=0, starttime=False, samp_rate=1.0)[source]

Function to determine peaks in an array of data above a certain threshold.

Depreciated peak-finding routine, very slow, but accurate. If all else fails this one should work.

Parameters:
  • arr (ndarray) – 1-D numpy array is required
  • thresh (float) – The threshold below which will be considered noise and peaks will not be found in.
  • trig_int (int) – The minimum difference in samples between triggers,if multiple peaks within this window this code will find the highest.
  • starttime (osbpy.UTCDateTime) – Starttime for plotting, only used if debug > 2.
  • samp_rate (float) – Sampling rate in Hz, only used for plotting if debug > 2.
Returns:

peaks: Lists of tuples of peak values and locations.

findpeaks.is_prime(number)[source]

Function to test primality of a number. Function lifted from online resource:

This function is distributed under a seperate licence:
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Parameters:number (int) – Integer to test for primality
Returns:bool