Skip to content

subtract_bias

Subtract the master bias (or a constant bias level) from ctx.image.

Category Preprocessing (2-D image)
Backend numpy - implemented here on top of numpy primitives
Version 1.0.0
Reads ctx.image (an ImageFrame)
Writes image, metrics.bias_median, metrics.median_after, metrics.n_negative, metrics.n_clipped

Native counterpart of subtract_bias_easyspec: the same arithmetic without the easyspec staging (no temporary FITS, no clipping unless clip_negative is set), so integer-ADU frames and BZERO-scaled files are handled in float64 end to end. Precedence: an explicit bias_level wins over the master frame stored in ctx.extras[bias_key]; with neither available the brick fails. Negative pixels are kept by default because clipping biases the sky statistics of faint frames; clip_negative=True reproduces the easyspec pad_with_zeros behaviour. Companion of dark_subtract (which scales by exposure time) and flat_normalize.

Parameters

Parameter Default Required Description
bias_key 'master_bias' - Key in ctx.extras where the master bias (an ImageFrame) is stored.
bias_level None - Constant bias level in ADU to subtract instead of a master frame (e.g. the overscan mean); takes precedence over the master frame when set.
clip_negative False - Set the pixels that become negative after subtraction to zero.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("subtract_bias", ctx, {
    "bias_key": "master_bias",
    "bias_level": None,
    "clip_negative": False
})

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

{
  "tool": "subtract_bias",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "bias_key": "master_bias",
      "bias_level": null,
      "clip_negative": false
    }
  }
}

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, 2nd ed., ch. 4 (bias frames, zero level).
  • Massey 1997 — A User's Guide to CCD Reductions with IRAF (NOAO), zero-level correction.