modules.calibration_association
KPF Calibration Association module.
Given a KPF observation frame, finds the most appropriate master calibration file for each calibration type (bias, dark, flat, thar) by searching the masters directory and selecting the nearest-in-time match.
- class kpfpipe.modules.calibration_association.CalibrationAssociation(l1_obj, config=None)
Bases:
objectAssociate a KPF observation frame with master calibration files.
For each requested calibration type, scans the masters directory and selects the master whose observation timestamp is nearest to the frame’s observation time. A configurable search window limits how far back (or forward) in time the search extends.
- Parameters:
l1_obj (KPF1) – KPF observation frame. For now this is always an L1 frame. The observation timestamp is read from its PRIMARY header (DATE-OBS).
config (None | dict | ConfigHandler) –
- Module configuration. Recognised keys:
- KPF_MASTERS_OUTPUTstr
Root directory under which master calibration files live (searched as {root}/masters/{datecode}/). This is where the masters recipe writes its products.
- masters_search_window_days[int, int]
Search window as [days_before, days_after] relative to the science frame’s observation date. Negative values are in the past, positive in the future. Default: [-1, 0] (search up to 1 day before and same day only).
- info()
Print a summary of the module configuration and association results.
- perform(cal_types, *, masters_search_window_days=None)
Run calibration association for the given calibration types.
- Parameters:
cal_types (list of str) – Calibration types to associate (e.g. [‘bias’, ‘dark’, ‘flat’, ‘thar’]).
masters_search_window_days ([int, int], optional) – Search window as [days_before, days_after]. Defaults to self.masters_search_window_days.
- Returns:
The input frame with calibration headers populated and a receipt entry added.
- Return type:
- Raises:
FileNotFoundError – If no master file is found for any requested calibration type.