Class Chi2TimeDelays
java.lang.Object
Localiser.algorithms.genericLocaliser.Chi2TimeDelays
- All Implemented Interfaces:
 MinimisationFunction
Minimisation function for a localisation performed using time delay calculations. This can be used with any PAMGuard minimisation algorithm; 
 
The time delay minimisation function is based on a set of observed time delays. A generic structure for observed time delays is used.
 Each row in the time delay ArrayList contains a group time delays calculated from N synchrnoised hydrophones 
 in the corresponding ArrayListinvalid input: '<'ArrayList
- Author:
 - Jamie Macaulay
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleThe speed of sound in meters per second. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionaddTimingError(ArrayList<ArrayList<Double>> timeDelayErrors, double timeError, float sampleRate) Adds the a constant timing error to the time delays error array e.g.calcTimeDelays(double[] sourceLoc, ArrayList<ArrayList<double[]>> hydrophonePos, double speedOfSound) Calculate the theoretical time delays if a source was located at position in space.static doublechiSquared(ArrayList<ArrayList<Double>> observedTimeDelays, ArrayList<ArrayList<Double>> chainPosTimeDelays, ArrayList<ArrayList<Double>> errors) Calculates the chi^2 value between observed data and theoretical delays calculated for a certain point in space.intgetDim()Get the simulation dimensions e.g.double[]Get first search jump (often not needed)double// * Get the sound speed.double[]getStart()Get starting position for search algorithm.voidsetFirstStep(double[] firstStep) Set the start location for the algorithm.voidsetHydrophonePos(ArrayList<ArrayList<double[]>> hydrophonePos) Set the hydrophone positionsvoidsetSpeedOfSound(double speedOfSound) Set the sound speed.voidsetStart(double[] start) Set the start location for the algorithm.voidsetTimeDelays(ArrayList<ArrayList<Double>> timeDelays) Set the time delays.voidsetTimeDelaysErrors(ArrayList<ArrayList<Double>> timeDelayErrors) doublevalue(double[] sourceLoc) Return the Chi2 value at a specified 'location'/ for a set of points which can be used to generated expected data that is then used to calculated a chi2 value with observed data. 
- 
Field Details
- 
speedOfSound
protected double speedOfSoundThe speed of sound in meters per second. 
 - 
 - 
Constructor Details
- 
Chi2TimeDelays
public Chi2TimeDelays()Chi2 time delays - 
Chi2TimeDelays
public Chi2TimeDelays(ArrayList<ArrayList<Double>> timeDelaysObs, ArrayList<ArrayList<Double>> timeDelayErrors, ArrayList<ArrayList<double[]>> hydrophoneArray) Chi2 time delays.- Parameters:
 timeDelaysObs- - the observed time delays in secondstimeDelayErrors- - the time delay errors in secondshydrophoneArray- - the hydrophone arrays.
 
 - 
 - 
Method Details
- 
value
public double value(double[] sourceLoc) Description copied from interface:MinimisationFunctionReturn the Chi2 value at a specified 'location'/ for a set of points which can be used to generated expected data that is then used to calculated a chi2 value with observed data. Example location might be [x y z] location to generate time delays which are then compared to expected time delays.- Specified by:
 valuein interfaceMinimisationFunction- Parameters:
 sourceLoc- - the point at which chi2 value is to be calculated;- Returns:
 - the chi2 value.
 
 - 
getDim
public int getDim()Description copied from interface:MinimisationFunctionGet the simulation dimensions e.g. if solving for [x y z] location getDim()=3;- Specified by:
 getDimin interfaceMinimisationFunction
 - 
chiSquared
public static double chiSquared(ArrayList<ArrayList<Double>> observedTimeDelays, ArrayList<ArrayList<Double>> chainPosTimeDelays, ArrayList<ArrayList<Double>> errors) Calculates the chi^2 value between observed data and theoretical delays calculated for a certain point in space.- Parameters:
 observedTimeDelays- - the observed time delays (seconds).chainPosTimeDelays- - the set of time delays to compare to the observed time delays (seconds).errors- - the measurement errors in the observed time delays.- Returns:
 - chi squared value for observed time delays compared to chain position time delays.
 
 - 
calcTimeDelays
public static ArrayList<ArrayList<Double>> calcTimeDelays(double[] sourceLoc, ArrayList<ArrayList<double[]>> hydrophonePos, double speedOfSound) Calculate the theoretical time delays if a source was located at position in space. (Technically space can be any number of dimensions but probably useful to stick to 3D)- Parameters:
 sourceLoc- - theoretical position of the source.hydrophonePos- - the positions of all the hydrophones within the array in Cartesian coOrdinates.speedOfSound- - the speed of sound in meters per second.- Returns:
 - The time delays that would result from a source at this location.
 
 - 
setTimeDelays
Set the time delays. Each row is a set for delays from N synchronised hydrophones. Different rows can have different numbers of synchronised hydrophones.- Parameters:
 timeDelays- - a set of time delays in seconds.
 - 
setTimeDelaysErrors
- Parameters:
 timeDelayErrors-
 - 
setHydrophonePos
Set the hydrophone positions- Parameters:
 hydrophonePos- - the hydrophone positions.
 - 
addTimingError
public static ArrayList<ArrayList<Double>> addTimingError(ArrayList<ArrayList<Double>> timeDelayErrors, double timeError, float sampleRate) Adds the a constant timing error to the time delays error array e.g. this could be used to add an average cross correlation timing error.- Parameters:
 timeDelayErrors- - list of time delay errors.timeError- - the timing error to add, in samplessampleRate- - the sample rate in samples per second.- Returns:
 - an array with the timeError added appropriately to each measurement.
 
 - 
getFirstStep
public double[] getFirstStep()Description copied from interface:MinimisationFunctionGet first search jump (often not needed)- Specified by:
 getFirstStepin interfaceMinimisationFunction- Returns:
 - first jump location with getDim() dimensions.
 
 - 
getSpeedOfSound
public double getSpeedOfSound()// * Get the sound speed.- Returns:
 - - the sound speed in meters per second
 
 - 
setSpeedOfSound
public void setSpeedOfSound(double speedOfSound) Set the sound speed.- Parameters:
 speedOfSound- - the sound speed in meters per second.
 - 
getStart
public double[] getStart()Description copied from interface:MinimisationFunctionGet starting position for search algorithm.- Specified by:
 getStartin interfaceMinimisationFunction- Returns:
 - starting location with getDim() dimensions.
 
 - 
setStart
public void setStart(double[] start) Set the start location for the algorithm. If null then a random first step is assigned.- Parameters:
 start- location. Must be the same length as number of dimensions
 - 
setFirstStep
public void setFirstStep(double[] firstStep) Set the start location for the algorithm. If null then a random location is selected- Parameters:
 start- location. Must be the same length as number of dimensions
 
 -