MatchPessimisticBTask matches sources to reference objects. This is often done as a preliminary step to fitting an astrometric or photometric solution.

The algorithm is based on a more “Pessimistic” version of the Optimistic Pattern Matcher B as described in DMTN-013.

Optimistic Pattern Matching is described in [Tabur2007]

 [Tabur2007] Fast algorithms for matching CCD images to a stellar catalogue* arxiv:0710.3618

## Processing summary¶

MatchPessimisticBTask runs this sequence of operations:

• Flags sources with bad centroids and low signal to noise and remove them from the matching.
• Match the usable sources with an input reference catalog using the updated V. Tabur 2007 algorithm.
• Further remove sources detected on the edge of the image and those that are saturated.
• Return these sources matched to the references.

## Python API summary¶

from lsst.meas.astrom.matchPessimisticB import MatchPessimisticBTask

classMatchPessimisticBTask(**kwargs)

Match sources to reference objects...

attributeconfig

Access configuration fields and retargetable subtasks.

See the MatchPessimisticBTask API reference for complete details.

## Configuration fields¶

### matcherIterations¶

Default
5
Field type
int RangeField
Range
[1,inf)
Number of softening iterations in matcher.

### maxOffsetPix¶

Default
300
Field type
int RangeField
Range
[-inf,4000)
Maximum allowed shift of WCS, due to matching (pixel). When changing this value, the LoadReferenceObjectsConfig.pixelMargin should also be updated.

### maxRefObjects¶

Default
65536
Field type
int RangeField
Range
[0,65537)
Maximum number of reference objects to use for the matcher. The absolute maximum allowed for is 2 ** 16 for memory reasons.

### maxRotationDeg¶

Default
1.0
Field type
float RangeField
Range
[-inf,6.0)
Rotation angle allowed between sources and position reference objects (degrees).

### minFracMatchedPairs¶

Default
0.3
Field type
float RangeField
Range
[0,1)
Minimum number of matched pairs as a fraction of the smaller of the number of reference stars or the number of good sources; the actual minimum is the smaller of this value or minMatchedPairs.

### minMatchDistPixels¶

Default
1.0
Field type
float RangeField
Range
[0.0,6.0)
Distance in units of pixels to always consider a source-reference pair a match. This prevents the astrometric fitter from over-fitting and removing stars that should be matched and allows for inclusion of new matches as the wcs improves.

### minMatchedPairs¶

Default
30
Field type
int RangeField
Range
[2,inf)

### numBrightStars¶

Default
200
Field type
int RangeField
Range
[2,inf)
Number of bright stars to use. Sets the max number of patterns that can be tested.

### numPatternConsensus¶

Default
3
Field type
int Field
Number of implied shift/rotations from patterns that must agree before it a given shift/rotation is accepted. This is only used after the first softening iteration fails and if both the number of reference and source objects is greater than numBrightStars.

### numPointsForShape¶

Default
6
Field type
int Field
Number of points to define a shape for matching.

### numPointsForShapeAttempt¶

Default
6
Field type
int Field
Number of points to try for creating a shape. This value should be greater than or equal to numPointsForShape. Besides loosening the signal to noise cut in the ‘matcher’ SourceSelector, increasing this number will solve CCDs where no match was found.

### numRefRequireConsensus¶

Default
1000
Field type
int Field
If the available reference objects exceeds this number, consensus/pessimistic mode will enforced regardless of the number of available sources. Below this optimistic mode (exit at first match rather than requiring numPatternConsensus to be matched) can be used. If more sources are required to match, decrease the signal to noise cut in the sourceSelector.

## Examples¶

See lsst.pipe.tasks.photoCal.PhotoCalTask .. note:: Pipe task will require conversion before this link is usable.

## Debugging¶

The lsst.pipe.base.CmdLineTask command line task interface supports a flag -d to import debug.py from your PYTHONPATH; see lsstDebug for more about debug.py files.

The available variables in MatchOptimisticB are

display (bool)
If True display information at three stages: after finding reference objects, after matching sources to reference objects, and after fitting the WCS; defaults to False
frame (int)
frame to use to display the reference objects; the next two frames are used to display the match list and the results of the final WCS; defaults to 0

To investigate the meas_astrom_astrometry_Debug, put something like

import lsstDebug
def DebugInfo(name):
debug = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively
if name == "lsst.meas.astrom.astrometry":
debug.display = True

return debug

lsstDebug.Info = DebugInfo


into your debug.py file and run this task with the –debug flag.