data_models.level2
KPF Level 2 (extracted spectra) data model.
Inherits from RV2 (EPRV standard) and adds KPF-friendly extension aliases so pipeline code can use either EPRV names (TRACE3_FLUX) or KPF names (SCI2_FLUX). Per-chip access (GREEN_SCI2_FLUX, RED_SCI2_FLUX) is handled transparently — these return numpy views into the concatenated trace arrays.
Each trace stores green+red orders concatenated (green first), matching the EPRV standard. The chip prefix dynamically slices using NORDER_GREEN.
The alias mechanism (AliasedOrderedDict) is generic and could be upstreamed into the EPRV standard (which rvdata implements).
- class kpfpipe.data_models.level2.KPF2
Bases:
KPFDataModel,RV2KPF Level 2 extracted spectra data model.
Extends RV2 with KPF-friendly extension aliases and per-chip access. EPRV-standard extension names remain canonical; aliases are transparent synonyms.
Each trace contains green+red orders concatenated (35 green + 32 red = 67 orders total). Per-chip access via GREEN_/RED_ prefix returns numpy views into the concatenated array. As examples of the aliasing, data[“SCI2_FLUX”] is data[“TRACE3_FLUX”], data[“CAL_WAVE”] is data[“TRACE1_WAVE”], and data[“CA_HK”] is data[“ANCILLARY_SPECTRUM”]; per-chip, data[“GREEN_SCI2_FLUX”] returns TRACE3_FLUX[:35] (the green orders) and data[“RED_SCI2_FLUX”] returns TRACE3_FLUX[35:] (the red orders).
- check_filename_convention(filename)
KPF L2 is EPRV-standard (SL2 name); delegate to rvdata’s check.
- generate_standard_filename()
KPF L2 standard filename (EPRV-standard SL2 name).
Delegates to kpf_filename (the single source for KPF product naming, so generation lives in one place across all levels), deriving the name from obs_id. check_filename_convention still defers to rvdata’s EPRV validator. Raises a ValueError if obs_id is unset or invalid.
- info()
Print summary of KPF2 data model contents.
- to_fits(fn=None)
KPF keeps a single-filepath
to_fits; rvdata >=0.4.0 renamed the parameter toout_filename. Delegate so all our call sites can keep passing one path (to_fits(fn)).
- to_kpf4()
Create a KPF4 scaffold from this KPF2, carrying over headers and receipt.
Returns a KPF4 with PRIMARY header keywords forwarded from L2, and the receipt chain preserved. RV and CCF data extensions are created but empty — the caller (RV computation) fills those in.