public class Correlations
extends java.lang.Object
Various functions to do with 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.
Constructor and Description |
---|
Correlations() |
Modifier and Type | Method and Description |
---|---|
static double |
defaultTimingError(float sampleRate)
Generate a default timing error which is 1/sqrt(12) times
the sample interval
|
static double[] |
getCorrelation(double[] wave1,
double[] wave2,
boolean normalise)
Get the correlation function of waves 1 and 2 and normalise if requested.
|
double |
getCorrelationValue()
Get the value of the last correlation calculated by
any of the functions in the class.
|
double |
getDelay(Complex[] f1,
Complex[] f2,
int fftLength)
Measure the time delay between pulses on two channels.
|
double |
getDelay(Complex[] f1,
Complex[] f2,
int fftLength,
double maxDelay)
Measure the time delay between pulses on two channels.
|
double |
getDelay(double[] s1,
double[] s2,
int fftLength)
Measure the time delay between pulses on two channels.
|
double |
getDelay(double[] s1,
double[] s2,
int fftLength,
double maxDelaySamples)
Measure the time delay between pulses on two channels.
|
static double[][] |
getInterpolatedMaxima(double[] corrFunction)
Get interpolated maxima around every peak in the correlation function.
|
static double[] |
getInterpolatedPeak(Complex[] corrData,
double scale,
double maxDelay)
Get the peak position and the peak height from a complex array
returned by the ifft function.
|
static double[] |
getInterpolatedPeak(double[] corrFunction)
Find the peak of a correlation function, interpolating about each peak
using a wee parabola.
|
static double[] |
getMaxDelays(float sampleRate,
int groupHydrophones,
long currentMillis)
Get the maximum permissible delays in samples
for the set of hydrophones.
|
static double |
parabolicCorrection(double y1,
double y2,
double y3)
Calculate a parabolic fit correction based on three bin heights
The answer should always be between -0.5 and +0.5 |
static double |
parabolicHeight(double time,
double[] correlationFunction) |
static double |
parabolicHeight(double y1,
double y2,
double y3)
Calculate a parabolic maximum height based on three bin heights
|
public double getDelay(double[] s1, double[] s2, int fftLength)
f1
- waveform on channel 1f2
- waveform on channel 2fftLength
- FFT length to use (data will be packed or truncated as necessary)public double getDelay(double[] s1, double[] s2, int fftLength, double maxDelaySamples)
f1
- waveform on channel 1f2
- waveform on channel 2fftLength
- FFT length to use (data will be packed or truncated as necessary)maxDelaySamples
- Maximum possible delay in samplespublic double getDelay(Complex[] f1, Complex[] f2, int fftLength)
f1
- complex spectrum on channel 1f2
- complex spectrum on channel 2fftLength
- FFT length to use (data will be packed or truncated as necessary)public double getDelay(Complex[] f1, Complex[] f2, int fftLength, double maxDelay)
f1
- complex spectrum on channel 1f2
- complex spectrum on channel 2fftLength
- FFT length to use (data will be packed or truncated as necessary)maxDelay
- Maximum feasible delay between channels.public double getCorrelationValue()
public static double defaultTimingError(float sampleRate)
sampleRate
- sample ratepublic static double parabolicCorrection(double y1, double y2, double y3)
y1
- first biny2
- second biny3
- third binpublic static double parabolicHeight(double y1, double y2, double y3)
y1
- first biny2
- second biny3
- third binpublic static double parabolicHeight(double time, double[] correlationFunction)
t
- time to measure height at.correlationFunction
- correlation function.public static double[] getCorrelation(double[] wave1, double[] wave2, boolean normalise)
wave1
- wave2
- normalise
- public static double[] getInterpolatedPeak(Complex[] corrData, double scale, double maxDelay)
corrData
- Complex data from the ifft during cross correlation calculationscale
- Scaling factor (sqrt(sum^2 of each channel))maxDelay
- max searchable delaypublic static double[] getInterpolatedPeak(double[] corrFunction)
Note that first and last bins are not used in the search.
corrFunction
- correlation functionpublic static double[][] getInterpolatedMaxima(double[] corrFunction)
corrFunction
- correlation function.public static double[] getMaxDelays(float sampleRate, int groupHydrophones, long currentMillis)
sampleRate
- sample rate of the datagroupHydrophones
- bitmap of used hydrophones.