Skip to content

flat_normalize

Divide ctx.image by a master flat normalised to unity.

Category Preprocessing (2-D image)
Backend numpy - implemented here on top of numpy primitives
Version 1.0.1
Reads ctx.image (an ImageFrame)
Writes image

Normalisation is by ONE global median of the master flat — not per row and not along the dispersion axis — so the flat lamp's spectral shape remains in the normalised flat and is divided into the science frame. This removes pixel-to-pixel response but also imprints the inverse lamp continuum; the catalogue has no equivalent of IRAF's response (dispersion-direction fit of the lamp) yet, so for spectrophotometry derive the instrumental response afterwards with response_from_standard. Low-response pixels (normalised flat < min_response, or non-finite result) are NOT masked: the original science value is substituted, i.e. those pixels stay un-flattened.

Parameters

Parameter Default Required Description
flat_key 'master_flat' - Key in ctx.extras where the master flat is stored.
min_response 0.05 - Below this normalised flat value the science pixel is left unchanged (not divided, not masked).

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("flat_normalize", ctx, {
    "flat_key": "master_flat",
    "min_response": 0.05
})

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": "flat_normalize",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "flat_key": "master_flat",
      "min_response": 0.05
    }
  }
}

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 (flat fielding).