Combine calibrated images

Combine CCDData inputs and choose calibration and rejection explicitly.

Use imcombine for a FITS-aware combination of exposures. This example uses three small CCDData images so the result can be checked directly.

1. Prepare images with matching units

import numpy as np
from astropy.nddata import CCDData

from astroimred.imutil.imcombine import imcombine

frames = [
    CCDData(np.full((16, 16), level, dtype="float32"), unit="adu")
    for level in (100, 102, 104)
]

For observed images, load the frames with air.load_ccd after applying the calibration required by the instrument. Combination does not infer which bias, dark, or flat frames belong to an observation.

2. Combine and verify the result

combined = imcombine(frames, combine="average")
np.testing.assert_allclose(combined.data, 102.0)
combined.shape, float(combined.data.mean())
((16, 16), 102.0)

Use combine="median" when the sample median is the desired statistic. Choose rejection, zero/scale corrections, and weights for the observation; they can change the scientific meaning of the output.

3. Select the next operation

Need Entry point
Bias, dark, and flat correction ccdred
Group exposures by header fields group_combine
Arithmetic between images imarith
Detailed normalization and rejection controls imcombine

output_std describes sample/clipping spread. It is not a propagated uncertainty image; explicit input-uncertainty extension requests are currently unsupported. Read the API’s return values before using diagnostics downstream.