title: Peak-finding algorithm for Python/SciPy
body: <p>I can write something myself by finding zero-crossings of the first derivative or something, but it seems like a common-enough function to be included in standard libraries.  Anyone know of one?</p>
  
  <p>My particular application is a 2D array, but usually it would be used for finding peaks in FFTs, etc.</p>
  
  <p>Specifically, in these kinds of problems, there are multiple strong peaks, and then lots of smaller "peaks" that are just caused by noise that should be ignored.  These are just examples; not my actual data:</p>
  
  <p>1-dimensional peaks:</p>
  
  <p><a href="https://i.stack.imgur.com/eJvFQ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/eJvFQ.jpg" alt="FFT output with peaks"></a></p>
  
  <p>2-dimensional peaks:</p>
  
  <p><img src="https://i.stack.imgur.com/MBh1r.png" alt="Radon transform output with circled peak"></p>
  
  <p>The peak-finding algorithm would find the location of these peaks (not just their values), and ideally would find the true inter-sample peak, not just the index with maximum value, probably using <a href="https://ccrma.stanford.edu/~jos/sasp/Quadratic_Peak_Interpolation.html" rel="noreferrer">quadratic interpolation</a> or something.</p>
  
  <p>Typically you only care about a few strong peaks, so they'd either be chosen because they're above a certain threshold, or because they're the first <em>n</em> peaks of an ordered list, ranked by amplitude.</p>
  
  <p>As I said, I know how to write something like this myself.  I'm just asking if there's a pre-existing function or package that's known to work well.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I <a href="http://gist.github.com/250860" rel="noreferrer">translated a MATLAB script</a> and it works decently for the 1-D case, but could be better.</p>
  
  <p><strong>Updated update:</strong></p>
  
  <p>sixtenbe <a href="https://gist.github.com/1178136" rel="noreferrer">created a better version</a> for the 1-D case.</p>