Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How Solving Works

Your image holds a few hundred points of light. The catalog holds tens of millions of stars. The header gives a rough idea of where the telescope was pointing, but the field could be rotated by any angle, mirrored, and offset by a few arcminutes. How does the solver work out which dots are which stars?

It runs in five stages, and each one narrows the question:

  1. Detect the stars in the image.
  2. Match small star patterns in the image against patterns in the catalog around the hint.
  3. Verify each candidate match by asking how likely the rest of the image is if the match were true.
  4. Fit a WCS to the matched stars, then match every detected star and fit again with distortion terms.
  5. Verify the final WCS the same way, and fall back to the simpler fit if it fails.

The matching and verification follow the method of Lang et al. 2010, “Astrometry.net: Blind astrometric calibration of arbitrary astronomical images” (AJ 139, 1782).

Finding the stars

Detection has to find stars and only stars. Hot pixels, nebulosity, galaxy cores and gradients from the moon all stand above the background too, and each false star is noise for the matcher.

The detector first models the background on a grid of 64-pixel cells, so a gradient across the frame doesn’t read as signal. It then builds a structure map: the image minus a smoothed copy of itself, which keeps features about the size of a star and drops larger ones. Connected regions of that map become candidates. Regions under 5 pixels are hot pixels or cosmic rays, regions over 2000 pixels are nebulae or galaxies, and both are dropped. So are regions within 5 pixels of the edge, whose light is cut off.

Each surviving region gets a centroid, a sub-pixel position from the pixel values above the local background. A star needs a signal-to-noise ratio of at least 5, and a fainter detection within 20 pixels of a brighter one is dropped as a duplicate. Stars with large saturated cores are rejected, because their centroids are poor. The output is a list sorted by flux, brightest first.

Detection works on whatever pixel type the file holds: 8-bit and 16-bit camera frames and 32-bit float stacks all solve without conversion.

Matching star patterns

Rotation and scale make direct comparison hopeless, so the solver compares shapes instead. It takes groups of four stars, called quads, and reduces each one to four numbers that stay the same when the group is moved, rotated or scaled. The two stars farthest apart define a frame, with one at (0, 0) and the other at (1, 0). The positions of the other two stars in that frame are the four numbers, called the quad’s hash. The same four stars in the catalog give the same hash, give or take the centroid error.

On the image side, the solver picks up to 100 stars: the brightest in each cell of a grid over the image, so that one bright corner doesn’t take all of them. It builds quads from each star and three of its 10 nearest neighbors.

On the catalog side, it searches a cone around the hint. The cone’s radius is 1.2 times half the image diagonal, so the field still fits inside it when the hint is a little off. It picks catalog stars at the same density as the image stars, builds quads the same way, and indexes their hashes. Every image quad whose hash lands near a catalog quad’s hash is a candidate match.

A mirrored image has mirrored quads. Images come out mirrored after some meridian flips and with some diagonals, so the solver runs the search twice in parallel, once for each orientation, and accepts whichever finds a verified match first.

Is the match real?

Most candidate matches are chance. With thousands of quads on each side, some image quad will resemble some catalog quad by accident. The solver needs a test that rejects those and accepts real matches quickly.

Each candidate gives four star pairs, which are enough to fit a linear map from the sky to the image. That map predicts where the brightest catalog stars in the field should appear. If the match is real, many of the other detected stars sit within a pixel or so of a prediction. If it’s chance, the detections fall where they fall, with no relation to the predictions.

The solver compares these two explanations one detection at a time, in order of brightness. Each detection near a prediction makes “real” more likely, and each one far from every prediction makes it less likely. The running total is the log-odds: the natural log of how many times more likely the match is to be real than chance. The model allows for a quarter of the detections having no catalog counterpart, because satellites, hot pixels and stars fainter than the catalog limit are common. The four stars of the quad itself are left out, since they agree with the map by construction.

A match is accepted when the log-odds passes ln(10⁹), about 20.7: odds of a billion to one. The threshold comes from the paper’s cost model, in which accepting a false match costs far more than missing a true one. The test has a useful guarantee: a chance match reaches odds of K to 1 with probability at most 1/K, whatever the image looks like. A typical real match passes with a lot to spare. The M106 frame on the first page ended at 202.

The first candidate to pass is accepted, and the search stops there. The order is fixed, so the same image and catalog always give the same answer.

Fitting the WCS

The accepted match brings its star pairs: the quad’s own stars and the other detections that landed on catalog stars. The solver fits a gnomonic (TAN) projection to them, the standard projection for telescope images. It first fits a model to every set of three pairs among the 100 best, and keeps the model that most pairs agree with. That removes the occasional wrong pair. It then fits by weighted least squares, weighting each pair by how precise its centroid is, so bright stars count more than faint ones.

Two checks follow. The fitted plate scale must be within a factor of 2 of the hint, and the fitted center must be within one image diagonal of the hint position. A match that fails either one contradicts what the header says, and the solve stops with an error rather than return it.

The first fit only used the stars the matcher found. Refinement uses all of them. With the first WCS, the solver predicts where up to 2000 catalog stars around the field fall in the image, and pairs each detection with the nearest prediction within 3 pixels. It fits again with those pairs, predicts again, and repeats until the pairs stop changing, at most 5 times.

The refit also models lens and field distortion with SIP polynomials, the standard FITS way to describe distortion. Each order adds terms, and too many terms bend the solution to fit noise. To choose, the solver fits every order up to 4, and for each one predicts each star from a fit that left that star out. It keeps the order with the smallest of those prediction errors, which may be no distortion terms at all. The M106 frame chose order 3, and its RMS went from 0.56 px to 0.21 px.

Checking the result

The refined WCS goes through the same log-odds test as the matches did. It places the catalog stars, and each fitted star is scored against a fit made without it, so a WCS can’t pass by agreeing with its own inputs. The SIP terms are left out of this test, because a high-order polynomial could bend a slightly wrong solution onto its own stars.

If the refined WCS fails, or the refinement couldn’t fit at all, the solver falls back to the first WCS and tests that instead. result.refinement records which one you got and why. If neither passes, the solve fails with a NoMatch error that gives the log-odds it reached.

What you get back

A solve returns one WCS in two forms:

  • result.wcs, the linear TAN fit, with its scale, rotation and RMS.
  • result.sip, the distortion fit with its own center and CD matrix, when an order of 2 or more was chosen.

The FITS header the solver writes combines them: RA---TAN-SIP and DEC--TAN-SIP axes, the A_p_q and B_p_q coefficients, and inverse AP_p_q and BP_p_q coefficients so that readers can map sky to pixel as well as pixel to sky. Positions are ICRS, at the epoch of the image: catalog stars are moved by their proper motion from the catalog epoch, J2016.0, to the date in the header.

Limits

  • There is no blind solving. The solver searches around a position hint and a plate scale, and won’t search the whole sky. Hints and Image Metadata explains how far off they can be.
  • Dense nebulae and galaxy fields can starve detection. Bright extended regions are rejected as not star-shaped, and a field with few stars left may not reach the log-odds threshold.
  • Very small fields need a deep catalog. A field of 10 arcminutes holds few stars brighter than G 18.5, and the smaller catalog tiers hold fewer. The Star Catalog has the numbers.

Next steps