uk.ac.starlink.table.join
Class SkyMatchEngine

java.lang.Object
  extended byuk.ac.starlink.table.join.SkyMatchEngine
All Implemented Interfaces:
MatchEngine
Direct Known Subclasses:
HEALPixMatchEngine, HTMMatchEngine

public abstract class SkyMatchEngine
extends Object
implements MatchEngine

Abstract superclass for match engines which match positions on the sky. The tuples it uses are two-element arrays of Number objects, the first giving Right Ascension in radians, and the second giving Declination in radians. The separation attribute indicates how many radians may separate two points on the celestial sphere for them to be considered matching.

Since:
15 Mar 2005

Field Summary
 
Fields inherited from interface uk.ac.starlink.table.join.MatchEngine
NO_BINS
 
Constructor Summary
SkyMatchEngine(double separation, boolean useErrors)
          Constructs a new match engine which considers two points (RA,Dec tuples) to match if they are within a given angular distance on the celestial sphere.
 
Method Summary
static double calculateSeparation(double ra1, double dec1, double ra2, double dec2)
          Returns the distance along a great circle between two points.
 boolean canBoundMatch()
          Indicates that the getMatchBounds(java.lang.Comparable[], java.lang.Comparable[]) method can be invoked to provide some sort of useful result.
protected abstract  Object[] getBins(double ra, double dec, double err)
          Returns a set of keys for bins into which possible matches for a given sky position, with a given error, might fall.
 Object[] getBins(Object[] tuple)
          Returns a set of keys for bins into which possible matches for a given tuple might fall.
 Comparable[][] getMatchBounds(Comparable[] radecMinIn, Comparable[] radecMaxIn)
          Given a range of tuple values, returns a range outside which no match to anything within that range can result.
 DescribedValue[] getMatchParameters()
          Returns a set of DescribedValue objects whose values can be modified to modify the matching criteria.
 ValueInfo getMatchScoreInfo()
          Returns a description of the value returned by the matchScore(java.lang.Object[], java.lang.Object[]) method.
 double getSeparation()
          Returns the separation between points within which they will be considered to match.
 ValueInfo[] getTupleInfos()
          Returns a set of ValueInfo objects indicating what is required for the elements of each tuple.
 boolean getUseErrors()
          Indicates whether this engine is using per-row errors for matching.
 double matchScore(Object[] tuple1, Object[] tuple2)
          Determines the match score of two tuples.
 void setSeparation(double separation)
          Configures this match engine to consider two points (RA,Dec tuples) to match if they are within a given angular distance on the celestial sphere.
 void setUseErrors(boolean use)
          Sets whether this engine will use per-row errors for matching.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SkyMatchEngine

public SkyMatchEngine(double separation,
                      boolean useErrors)
Constructs a new match engine which considers two points (RA,Dec tuples) to match if they are within a given angular distance on the celestial sphere.

Parameters:
separation - match radius in radians
useErrors - if true, per-row errors can be specified as a third element of the tuples; otherwise only the fixed separation value counts
Method Detail

setSeparation

public void setSeparation(double separation)
Configures this match engine to consider two points (RA,Dec tuples) to match if they are within a given angular distance on the celestial sphere.

Parameters:
separation - match radius in radians

getSeparation

public double getSeparation()
Returns the separation between points within which they will be considered to match.

Returns:
match radius in radians

getUseErrors

public boolean getUseErrors()
Indicates whether this engine is using per-row errors for matching.

Returns:
true iff per-row error radii are in use

setUseErrors

public void setUseErrors(boolean use)
Sets whether this engine will use per-row errors for matching.

Parameters:
use - true to use per-row errors

matchScore

public double matchScore(Object[] tuple1,
                         Object[] tuple2)
Determines the match score of two tuples. If useErrors is true the tuples are three-element, giving RA, Dec and error radius, all as Number objects in radians. If it is false, they are two element, giving just RA and Dec.

Specified by:
matchScore in interface MatchEngine
Parameters:
tuple1 - values representing first point
tuple2 - values representing second point
Returns:
distance in arcseconds between first and second points if they are close enough to match, otherwise -1

getBins

public Object[] getBins(Object[] tuple)
Description copied from interface: MatchEngine
Returns a set of keys for bins into which possible matches for a given tuple might fall. The returned objects can be anything, but should have their equals and hashCode methods implemented properly for comparison.

Specified by:
getBins in interface MatchEngine
Parameters:
tuple - tuple
Returns:
set of bin keys which might be returned by invoking this method on other tuples which count as matches for the submitted tuple

getBins

protected abstract Object[] getBins(double ra,
                                    double dec,
                                    double err)
Returns a set of keys for bins into which possible matches for a given sky position, with a given error, might fall. The returned objects can be anything, but should have their equals and hashCode methods implemented properly for comparison. The err value will not be greater than the current result of getSeparation.

Parameters:
ra - right ascension of point to test (radians)
dec - declination of point to test (radians)
err - possible distance away from given location of match
See Also:
getBins(java.lang.Object[])

getMatchScoreInfo

public ValueInfo getMatchScoreInfo()
Description copied from interface: MatchEngine
Returns a description of the value returned by the MatchEngine.matchScore(java.lang.Object[], java.lang.Object[]) method. The content class should be numeric (though need not be Double), and the name, description and units should be descriptive of whatever the physical significance of the value is. If the result of matchScore is not interesting (for instance, if it's always either 0 or -1), null may be returned.

Specified by:
getMatchScoreInfo in interface MatchEngine
Returns:
metadata for the match score results

getTupleInfos

public ValueInfo[] getTupleInfos()
Description copied from interface: MatchEngine
Returns a set of ValueInfo objects indicating what is required for the elements of each tuple. The length of this array is the number of elements in the tuple. Each element should at least have a defined name and content class. The info's nullable attribute has a special meaning: if true it means that it makes sense for this element of the tuple to be always blank (for instance assigned to no column).

Specified by:
getTupleInfos in interface MatchEngine
Returns:
array of objects describing the requirements on each element of the tuples used for matching

getMatchParameters

public DescribedValue[] getMatchParameters()
Description copied from interface: MatchEngine
Returns a set of DescribedValue objects whose values can be modified to modify the matching criteria. Typically at least one of these will be some sort of tolerance separation which determines how close tuples must be to count as a match. This match engine's behaviour can be modified by calling DescribedValue.setValue(java.lang.Object) on the returned objects.

Specified by:
getMatchParameters in interface MatchEngine
Returns:
array of described values which influence the match

toString

public String toString()

canBoundMatch

public boolean canBoundMatch()
Description copied from interface: MatchEngine
Indicates that the MatchEngine.getMatchBounds(java.lang.Comparable[], java.lang.Comparable[]) method can be invoked to provide some sort of useful result.

Specified by:
canBoundMatch in interface MatchEngine
Returns:
true iff getMatchBounds may provide useful information

getMatchBounds

public Comparable[][] getMatchBounds(Comparable[] radecMinIn,
                                     Comparable[] radecMaxIn)
Description copied from interface: MatchEngine
Given a range of tuple values, returns a range outside which no match to anything within that range can result. If the tuples on which this engine works represent some kind of space, the input values and output values specify a hyper-rectangular region of this space. In the common case in which the match criteria are based on proximity in this space up to a certain error, this method should return a rectangle which is like the input one but broadened in each direction by an amount corresponding to the error.

Both the input and output rectangles are specified by tuples representing its opposite corners; equivalently, they are the minimum and maximum values of each tuple element. In either the input or output min/max tuples, any element may be null to indicate that no information is available on the bounds of that tuple element (coordinate).

This method can be used by match algorithms which know in advance the range of coordinates they will match against and wish to reduce workload by not attempting matches which are bound to fail.

For example, a 1-d Cartesian match engine with an isotropic match error 0.5 would turn input values of ((0,200),(10,210)) into output values ((-0.5,199.5),(10.5,210.5)).

This method will only be called if MatchEngine.canBoundMatch() returns true. Thus engines that cannot provide any useful information along these lines (for instance because none of its tuple elements is Comparable do not need to implement it in a meaningful way.

Specified by:
getMatchBounds in interface MatchEngine
Parameters:
radecMinIn - tuple consisting of the minimum values of each tuple element in a possible match (to put it another way - coordinates of one corner of a tuple-space rectangle containing such a match)
radecMaxIn - tuple consisting of the maximum values of each tuple element in a possible match (to put it another way - coordinates of the other corner of a tuple-space rectangle containing such a match)
Returns:
2-element array of tuples - effectively (minTuple,maxTuple) broadened by errors
See Also:
MatchEngine.canBoundMatch()

calculateSeparation

public static double calculateSeparation(double ra1,
                                         double dec1,
                                         double ra2,
                                         double dec2)
Returns the distance along a great circle between two points.

Parameters:
ra1 - right ascension of point 1 in radians
dec1 - declination of point 1 in radians
ra2 - right ascension of point 2 in radians
dec2 - declination of point 2 in radians
Returns:
angular separation of point 1 and point 2 in radians

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.