Localiser
Class Correlations

java.lang.Object
  extended by Localiser.Correlations

public class Correlations
extends java.lang.Object

Author:
Doug Gillespie

Various functions to do wtih cross correlating two or more signals

As with the FastFFT class, these functions are no longer static so that Allocation of FFT internal storage is done separately for each detector. This avoids it having to be continually reallocated if fft's of different lenghts are taken.

Also calculates a delay correction factor based on a parabolic interpolation around the maximum value. For compatibility with previous versions, the returned results is still the integer solution. If you require greater accuracy, you should get the interpolated correction and add this to the main integer result for double precision accuracy.


Field Summary
(package private)  FastFFT fastFFT
           
private  double interpolatedCorrection
           
 
Constructor Summary
Correlations()
           
 
Method Summary
static double defaultTimingError(float sampleRate)
          Generate a default timing error which is 1/sqrt(12) times the sample interval
 double getDelay(Complex[] f1, Complex[] f2, int fftLength)
           
 double getDelay(double[] s1, double[] s2, int fftLength)
           
 double getInterpolatedCorrection()
           
static double parabolicCorrection(double y1, double y2, double y3)
          Calculate a parabolic fit correction based on three bin heights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fastFFT

FastFFT fastFFT

interpolatedCorrection

private double interpolatedCorrection
Constructor Detail

Correlations

public Correlations()
Method Detail

getDelay

public double getDelay(double[] s1,
                       double[] s2,
                       int fftLength)

getDelay

public double getDelay(Complex[] f1,
                       Complex[] f2,
                       int fftLength)

getInterpolatedCorrection

public double getInterpolatedCorrection()

defaultTimingError

public static double defaultTimingError(float sampleRate)
Generate a default timing error which is 1/sqrt(12) times the sample interval

Parameters:
sampleRate - sample rate
Returns:
typical timing error

parabolicCorrection

public static double parabolicCorrection(double y1,
                                         double y2,
                                         double y3)
Calculate a parabolic fit correction based on three bin heights

Parameters:
y1 - first bin
y2 - second bin
y3 - third bin
Returns:
correction = 0.5*(y3-y1)/(2*y2-y1-y3);