Skip to content

dark_combine

Combine a stack of dark frames into a master dark.

Category Master frames
Backend numpy - implemented here on top of numpy primitives
Version 2.0.0
Reads ctx.images (a list of ImageFrame)
Writes extras.master_dark

Pixel-wise median (robust default) or σ-clipped mean over the stack. require_uniform_exptime=True (the default) ensures every input has the same EXPTIME — otherwise a non-uniform mix would render the master un-scalable by exposure time. Pass bias_key to subtract a master bias from each frame before combining. v2.0.0 (method='mean' with sigma_clip only): the σ-clip scale is 1.4826·MAD about the per-pixel median; when the MAD is 0 (integer-ADU darks with ~1 ADU read noise) it now falls back to 1.2533 × the mean absolute deviation about the median, and keeps all values when that is 0 too. v1 floored the scale at machine epsilon, which rejected every value ≠ median and turned the clipped mean into a median ([10,10,10,11,12], σ=3: v1 → 10.0, v2 → 10.6; a cosmic ray [10,10,10,11,1000] is still rejected → 10.25). method='median' is unchanged.

Parameters

Parameter Default Required Description
method 'median' - 'median' (robust default) or 'mean' (with optional sigma_clip).
bias_key None - ctx.extras key for a master bias to subtract from each frame before combining. None = no pre-subtraction.
require_uniform_exptime True - When True, refuse to combine frames with non-uniform EXPTIME (otherwise a scale_by_exptime downstream would be undefined).
sigma_clip None - σ threshold for σ-clipped mean (method='mean' only). None or ≤0 disables clipping.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("dark_combine", ctx, {
    "method": "median",
    "bias_key": None,
    "require_uniform_exptime": True,
    "sigma_clip": None
})

The CLI loads a single 1-D spectrum with --input; this algorithm needs ctx.images (a list of ImageFrame). Run it from Python or as a step of a pipeline preset.

{
  "tool": "dark_combine",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "method": "median",
      "bias_key": null,
      "require_uniform_exptime": true,
      "sigma_clip": null
    }
  }
}

Every algorithm is an MCP tool of the same name; describe_algorithm returns this page's metadata as JSON.

References

  • Howell 2006 — Handbook of CCD Astronomy, ch. 4 (CCD reduction).
  • bias_combine - Combine a stack of bias frames into one master bias.
  • bias_combine_easyspec - Combine bias frames into a master bias via easyspec.cleaning.master.
  • dark_combine_easyspec - Combine dark frames into a master dark via easyspec.cleaning.master.
  • flat_combine - Combine a stack of flat frames into a master flat (raw, not normalised).
  • flat_combine_easyspec - Combine flat frames into a master flat via easyspec.cleaning.master.