lightlab.util.data.peaks module

Implementation of core peak finding algorithm. It is wrapped to be more user-friendly by findResonanceFeatures().

ResonanceFeature is a data storage class returned by findResonanceFeatures()

Summary

Exceptions:

PeakFinderError

Classes:

ResonanceFeature A data holder for resonance features (i.e.

Functions:

findPeaks Takes an array and finds a specified number of peaks

Reference

class ResonanceFeature(lam, fwhm, amp, isPeak=True)[source]

Bases: object

A data holder for resonance features (i.e. peaks or dips)

lam

float – center wavelength

fwhm

float – full width half maximum – can be less if the extinction depth is less than half

amp

float – peak amplitude

isPeak

float – is it a peak or a dip

copy()[source]

Simple copy so you can modify without side effect

Returns:new object
Return type:ResonanceFeature
simplePlot(*args, **kwargs)[source]

Plots a box to visualize the resonance feature

The box is centered on the peak lam and amp with a width of fwhm.

Parameters:
  • *args – args passed to pyplot.plot
  • **kwargs – kwargs passed to pyplot.plot
Returns:

whatever pyplot.plot returns

exception PeakFinderError[source]

Bases: RuntimeError

findPeaks(yArrIn, isPeak=True, isDb=False, expectedCnt=1, descendMin=1, descendMax=3, minSep=0)[source]

Takes an array and finds a specified number of peaks

Looks for maxima/minima that are separated from others, and stops after finding expectedCnt

Parameters:
  • isDb (bool) – treats dips like DB dips, so their width is relative to outside the peak, not inside
  • descendMin (float) – minimum amount to descend to be classified as a peak
  • descendMax (float) – amount to descend down from the peaks to get the width (i.e. FWHM is default)
  • minSep (int) – the minimum spacing between two peaks, in array index units
Returns:

indeces of peaks, sorted from biggest peak to smallest peak array (float): width of peaks, in array index units

Return type:

array (float)

Raises:

Exception – if not enough peaks found. This plots on fail, so you can see what’s going on