Visually verified the shift and rotation as measured by matchPessimisticB on visits from 3 different instruments: HSC (3358), DECam (406285, 410827), CFHT (793169, 896070, 980526). The matcher discovers the initial shift and rotation correctly for all ccds in these visits which represent a large range of density and distortion amounts.
With this ticket comes some minor improvements to the matching. A side effect of these updates is the code now passes unittests as they were written for matchOptimisticB without modification:
Use a iterative sigma clipped distance to cut matches and send them to the WCS fitter.
Use a least squares fit to the matched pattern between reference and sources with the shift/rotation implied by the first spoke of the pattern used as a the initial guess. The shift/rotation is forced to be approximately unitary in the fit so no requirement on the rotation matrix determinant is needed.
Small changes to match and fit loop. Now always tries to use pessimistic mode for first blind match. Once a match is found from a previous match/fit iteration it then uses optimistic mode.
Some ccds in the CFHT and DECam find the correct shift/rotation but end up with poor fits. This is usually caused by a star being matched to the incorrect star in a close pair of stars and is mainly a problem in fields were the source density is low (<100 per ccd). This can be solved by decreasing the signal to noise cut on sources and thus increasing their number. It could also be rectified by better outlier rejection in the fitter or by allowing for slight distortions in the shift/rotation matrix. These are left for future tickets.