Skip to content

Fitting the plate

The agreeing quad matches say roughly how the image sits on the sky. This step makes it exact: it finds the mapping from pixels to the sky that best fits all the matched stars at once.

On the tangent plane (see Searching the sky), an ideal camera’s mapping from pixel to standard coordinates is affine:

These six numbers are the plate constants. and are where pixel lands; the matrix

carries the scale, the rotation and the mirroring:

  • the pixel scale, in arcseconds per pixel, is ;
  • the rotation is ;
  • the image is mirrored if the determinant is negative.

Each matched pair of an image position and a catalogue position gives one equation for and one for , so three pairs fix all six constants. There are usually many more, so the constants are chosen to make the total squared miss as small as possible:

These are two independent least-squares problems, one per axis, built from the same pixel positions.

Written as matrices, each problem is , with one row of per star. The textbook answer, the normal equations , squares the problem’s sensitivity to rounding error. arcsec, like ASTAP, uses Givens rotations instead (the method in Montenbruck and Pfleger’s Astronomy on the Personal Computer): each new row is rotated into a small upper-triangular matrix by a sequence of plane rotations

each of which zeroes one entry of the new row. When all rows are in, is solved by back-substitution. It is numerically stable, needs only a 3 × 3 matrix however many stars there are, and never forms at all.

The first fit uses the quads: the centre of each matched image quad paired with the centre of its catalogue quad. A quad’s five ratios say that two quads have the same shape, but not which corner is which, so centres are all that can be paired at this stage. A few pairs that do not fit the rest (shown by residuals much larger than the others) are removed by sigma clipping: fit, drop pairs more than three standard deviations out, fit again, until nothing changes.

That fit is then used to pair individual stars, which is far more precise. Every catalogue star is projected into the image through the fit, by inverting it,

and paired with the nearest detected star within 6 pixels, each detection used at most once. The plate is fitted again on those pairs, and the whole thing repeated within 3 and then 2 pixels. The final fit rests on hundreds of individual stars rather than tens of quad centres; the same pairs are what checking the answer counts.

A camera pixel is square, so the matrix should be a pure similarity: rotation, one scale, and perhaps a mirror, with no stretch or shear. Its two singular values (the largest and smallest factors by which it stretches any direction) should then be equal. For the matrix above they are and , with

and any fit with

is refused. A set of chance matches can be fitted by some affine map, but seldom by one that keeps squares square. On the test images no correct solution has a ratio above 1.03.

The fit is made in the plane that touches the sky at the trial position, which may be some way from the image’s centre. The tangent plane is only exact near its tangent point, so after a position verifies, arcsec moves the tangent point to the centre of the image, projects the catalogue again, and refits. Without this, with a hint a third of a field off, most test images came out several arcseconds to many arcminutes wrong at the corners, though the fit looked good in its own plane.

FITS describes the same mapping as a reference pixel CRPIX, its sky position CRVAL, and a matrix CD in degrees per pixel. With the tangent point at the image centre, CRPIX is the centre pixel, CRVAL the sky position there, and

(the minus signs because FITS has right ascension increasing to the left). The older keywords that many programs still read are derived from it as ASTAP derives them: with for the usual handedness () and for a mirrored image,

If the image was binned for the solve, CRPIX and the scale terms are converted back to the original pixels. These go into the .wcs and .ini files that N.I.N.A. and others read (see the command-line reference).

A real lens is not a perfect projection: towards the edges of the field the stars drift from where an affine map puts them, a little for a telescope and a lot for a camera lens. If that drift exceeds the 2-pixel matching radius, the star-level fit keeps only the part of the field where the linear map happens to fit, and is accurate there alone.

So once a position verifies, arcsec fits a polynomial plate as well, in the style of astrometry.net’s tweak. Each standard coordinate becomes a polynomial in the scaled pixel offsets from the centre,

ten terms per axis at third order. The catalogue is read again for the whole frame, stars are re-paired within a wider radius under the current model, and the model is refitted, up to ten times, until it stops moving. A higher order is used only if it earns its extra terms, by an F-test against the best lower order:

(RSS is the sum of squared residuals, the number of terms, the number of stars), and only if its stars cover the frame, so it is not extrapolating into empty corners.

The WCS that arcsec writes stays linear, as ASTAP’s is, because that is what N.I.N.A. and most other programs read. When the model shows real distortion, the linear plate reported is the one closest to the model over the whole frame (a least-squares fit to it on a 9 × 9 grid), not the one that is exact at the centre and twice as far out at the corners. With --sip, the distortion itself is written as SIP polynomial terms too, for programs that read them.

Next: Checking the answer.