modules.spectral_extraction

KPF Spectral Extraction module.

class kpfpipe.modules.spectral_extraction.SpectralExtraction(l1_obj, config=None)

Bases: object

This class performs spectral extraction of the 1D spectrum. Processes data from KPF1 to KPF2.

Notes

Single-letter variable names for 2D images in this class follow Horne 1986 optimal extraction, with small modifcations:

  • D = data

  • V = variance

  • S = sky / scattered light

  • F = flat

  • P = profile

  • M = mask

  • W = weight

extract_ffi(chip, fibers=None, extraction_method=None)

Extract all spectral orders from a full-frame image (FFI).

Parameters:
  • chip (str) – Chip identifier, i.e. ‘GREEN’ or ‘RED’

  • fibers (list of str, optional) – Fibers identifiers, e.g. ‘SCI2’

  • extraction_method (str, optional) – Extraction method (‘box’, ‘optimal’, or ‘flat_relative’).

Returns:

Dictionary containing 2D arrays of shape (norder, ncol) for extracted flux and variance. Keys follow standard KPF name conventions, e.g. ‘GREEN_SCI2_FLUX’.

Return type:

dict

Notes

Loops over all spectral orders and requested fibers, performing order-by-order extraction.

extract_orderlet(chip, fiber, order, extraction_method=None)

Extract a single orderlet as a 1D spectrum.

Parameters:
  • chip (str) – Chip identifier, i.e. ‘GREEN’ or ‘RED’

  • fiber (str) – Fiber identifier, e.g. ‘SCI2’

  • order (int) – Spectral order number.

  • extraction_method (str, optional) – Extraction method (‘box’, ‘optimal’, or ‘flat_relative’).

Returns:

  • flux_1d (ndarray) – Extracted 1D flux spectrum for the specified orderlet.

  • var_1d (ndarray) – Corresponding 1D variance spectrum.

Notes

Retrieves the orderlet pixel region and dispatches to the selected extraction method.

info()

Print a summary of the module configuration and extraction results.

perform(chips=None, fibers=None, *, extraction_method=None)

Execute spectral extraction. Optional keyword arguments default to config settings.

Parameters:
  • chips (list of str, optional) – Chip identifiers, i.e. ‘GREEN’ or ‘RED’

  • fibers (list of str, optional) – Fiber identifiers, e.g. ‘SCI2’

  • extraction_method (str, optional) – Extraction method (‘box’, ‘optimal’, or ‘flat_relative’).

Returns:

l2_obj – L2 data object containing extracted 1D flux and variance arrays.

Return type:

KPF2

Notes

Creates a KPF2 object from the input KPF1 object and populates it with extracted spectra for all requested chips and fibers.