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 stacking works

For a numbered walk-through on real data, with the settings and troubleshooting, see Tutorial 4: Stack.

Stacking registers the frames, resamples them onto one grid, evens out their levels, weights them and combines them with outlier rejection. The function is valerian_core::stack::stack; the command is valerian stack. Registration and rejection have pages of their own: How registration works and How calibration works.

The steps

  1. Detect the stars in every frame (on the luminance, for colour frames).
  2. Choose the reference: the sharpest frame among those with a healthy number of stars, or the one you name. If fewer than half of the other frames register to the sharpest, the next three sharpest are tried, so a frame of the wrong field cannot become the reference. If no candidate gets half, the one that most frames register to is used and the rest are reported as skipped, as happens with a session that covers several fields (a mosaic).
  3. Register each frame to the reference. A frame that cannot be registered is left out and the reason is reported; the others are unaffected. Frames that are too soft can be left out too: --max-fwhm-ratio 1.5 leaves out any frame whose median FWHM is more than one and a half times the reference's (the default is no limit), and --min-stars (default 20) leaves out frames with too few stars to register. The report names the reason for each frame left out.
  4. Resample onto the reference grid. Pixels a frame does not cover are NaN, which the combiner reads as "no data", so the edges of a rotated or dithered stack are averaged over fewer frames instead of being black.
  5. Normalise. Each frame's sky level is matched to the reference's, and its transparency is matched by the median flux ratio of the matched stars (the brightest eight or more that are not saturated), so a frame shot through thin cloud counts for what it saw. A frame with too few matched stars to measure this keeps a scale of one, and the log says so. The reference's sky level stays as the pedestal of the result; where black sits is decided by the stretch, not here.
  6. Weight. The default weight is 1 / (noise^2 * FWHM^2), which is what maximises the signal-to-noise of a point source in a background-limited frame: quiet, sharp frames count for more. Equal, noise-only and FWHM-only weights are available.
  7. Combine with per-pixel rejection, chosen from the number of frames unless you ask for one (--rejection). For the schemes with limits, --low and --high set the lower and upper limit in sigmas; left out they are 3 and 3 for sigma clipping and winsorised clipping, and 5 and 2.5 for linear fit (minmax drops one sample at each end and none keeps all). Satellite trails, cosmic rays and hot pixels all disappear here: registration drags a detector-fixed defect to a different sky position in every frame, so it is an outlier at each of them.

The result carries the reference header with NCOMBINE, EXPTOTAL (the summed exposure of the frames used), STACKREF and STACKALG added. A coverage plane says how many frames contributed at each pixel, and a per-frame report gives the stars, FWHM, registration residual, flux scale, weight and the fraction of that frame's samples that were rejected.

What to expect

  • Noise falls as the square root of the number of frames when the frames are shifted by whole pixels. When they are rotated or shifted by fractions of a pixel, resampling smooths each frame's noise a little, so the per-pixel noise of the stack falls somewhat faster, at the cost of correlated noise between neighbouring pixels.
  • Stars in the stack sit within 0.05 pixel of where the reference puts them.
  • Colour frames are registered once, on the luminance, and every plane is moved by the same transform.

Not done yet

  • Mosaics, and distortion-aware warps. Drizzle for undersampled, dithered data is its own command.
  • Streaming from disk: calibration masters are streamed, but a stack holds all its frames in memory at once; the originals are replaced one at a time by their resampled versions, so the peak is about one copy of the set.
  • Meridian-flip handling beyond the rotation by 180 degrees that registration already accepts, and per-pixel-position rejection masks across sessions.