Class PeakSearch

java.lang.Object
Localiser.algorithms.PeakSearch

public class PeakSearch extends Object
Peak search algorithms which can find a peak in an array of real numbers.

Used by various localisers to find the best peak in correlation data.

Contains a number of options for interpolating in both x and y to find the best peak position. All functions return a PeakData object which contains the peak position and it's height.

Author:
Doug Gillespie
  • Constructor Details

    • PeakSearch

      public PeakSearch(boolean interpolateY)
      Construct peak search algorithms.
      Parameters:
      interpolateY - interpolate the Y coordinate (only when also interpolating x)
  • Method Details

    • simplePeakSearch

      public PeakPosition simplePeakSearch(double[] data)
      Find the highest bin, no interpolation or anything.
      Parameters:
      data -
      Returns:
    • simplePeakSearch

      public PeakPosition simplePeakSearch(double[] data, int binFrom, int binTo)
      find the height and position of the peak in a range or data, starting from binFrom and searching up to and including binTo-1
      Parameters:
      data -
      binFrom - first bin to search
      binTo - last bin + 1
      Returns:
      peak position (bin and height)
    • simplePeakSearch

      public PeakPosition2D simplePeakSearch(double[][] data)
      Simple peak search in two dimensions.
      Parameters:
      data - 2D array
      Returns:
      Peak row, col and height.
    • simplePeakSearch

      public PeakPosition2D simplePeakSearch(double[][] data, int binFrom0, int binTo0, int binFrom1, int binTo1)
      Simple peak search in two dimensions.
      Parameters:
      data - 2D array
      binFrom0 - start search bin in first dimension
      binTo0 - end search bin in first dimension
      binFrom1 - start search bin in second dimension
      binTo1 - end search bin in second dimension
      Returns:
      Peak row, col and height.
    • interpolatedPeakSearch

      public PeakPosition interpolatedPeakSearch(double[] data)
      find the height and position of the peak in a range or data, starting from binFrom and searching up to and including binTo-1

      Uses parabolic interpolation to get a more accurate value

      Parameters:
      data -
      Returns:
      peak position
    • interpolatedPeakSearch

      public PeakPosition interpolatedPeakSearch(double[] data, int binFrom, int binTo)
      find the height and position of the peak in a range or data, starting from binFrom and searching up to and including binTo-1

      Uses parabolic interpolation to get a more accurate value

      Parameters:
      data -
      binFrom - first bin to search
      binTo - last bin + 1
      Returns:
      peak position (bin and height)
    • interpolatedPeakSearch

      public PeakPosition2D interpolatedPeakSearch(double[][] data)
      Interpolated peak search in two dimensions.
      Parameters:
      data - 2D array
      Returns:
      Peak row, col and height.
    • interpolatedPeakSearch

      public PeakPosition2D interpolatedPeakSearch(double[][] data, int binFrom0, int binTo0, int binFrom1, int binTo1)
      Interpolated peak search in two dimensions.
      Parameters:
      data - 2D array
      binFrom0 - start search bin in first dimension
      binTo0 - end search bin in first dimension
      binFrom1 - start search bin in second dimension
      binTo1 - end search bin in second dimension
      Returns:
      Peak row, col and height.
    • parabolicHeight

      public double parabolicHeight(double x, double y1, double y2, double y3)
      Calculate a parabolic maximum height based on three bin heights
      Parameters:
      x - X offset from y2.
      y1 - first bin
      y2 - second bin
      y3 - third bin
      Returns:
      height of parabola through those points.
    • isInterpolateY

      public boolean isInterpolateY()
      Returns:
      the interpolateY
    • setInterpolateY

      public void setInterpolateY(boolean interpolateY)
      Parameters:
      interpolateY - the interpolateY to set
    • isWrapDim0

      public boolean isWrapDim0()
      When interpolating, allow dim0 to wrap (useful for circular angles)
      Returns:
      the wrapDim0
    • setWrapDim0

      public void setWrapDim0(boolean wrapDim0)
      When interpolating, allow dim0 to wrap (useful for circular angles)
      Parameters:
      wrapDim0 - the wrapDim0 to set
    • isWrapDim1

      public boolean isWrapDim1()
      When interpolating, allow dim1 to wrap (useful for circular angles)
      Returns:
      the wrapDim1
    • setWrapDim1

      public void setWrapDim1(boolean wrapDim1)
      When interpolating, allow dim1 to wrap (useful for circular angles)
      Parameters:
      wrapDim1 - the wrapDim1 to set
    • getWrapStep0

      public int getWrapStep0()
      Returns:
      the wrapStep0
    • setWrapStep0

      public void setWrapStep0(int wrapStep0)
      Parameters:
      wrapStep0 - the wrapStep0 to set
    • getWrapStep1

      public int getWrapStep1()
      Returns:
      the wrapStep1
    • setWrapStep1

      public void setWrapStep1(int wrapStep1)
      Parameters:
      wrapStep1 - the wrapStep1 to set