data_models.level0

KPF Level 0 (raw CCD) data model.

Reads raw FITS files from the KPF instrument at Keck Observatory. L0 files contain amplifier readouts, exposure meter tables, guide camera, telemetry, and telescope metadata. Extensions vary between observations.

Subclasses RVDataModel (via KPFDataModel) to reuse its extension/header/data infrastructure and receipt system.

class kpfpipe.data_models.level0.KPF0

Bases: KPFDataModel

KPF Level 0 raw data model.

Represents a raw CCD readout from the KPF instrument. Extensions vary between observations; the reader accepts whatever is present in the FITS file. Construct from a FITS file with KPF0.from_fits(path), then read amplifier arrays from data (e.g. data[“GREEN_AMP1”]) and header dicts from headers (e.g. headers[“PRIMARY”]).

check_filename_convention(filename)

KPF L0 uses the WMKO-native KP.YYYYMMDD.NNNNN.NN.fits name.

generate_standard_filename()

KPF L0 filenames follow the KP.YYYYMMDD.NNNNN.NN.fits pattern.

Delegates to kpf_filename (the single source for the KPF-native naming rule), which raises a ValueError if obs_id is unset or invalid.

info()

Print summary of L0 data model contents.

read(hdul, instrument=None, overwrite=False, **kwargs)

Route L0 FITS reads to KPF0._read, then stamp DRP provenance.

RVDataModel.read has no lvl==0 dispatch branch, so the inherited from_fits would never call into _read without this override.

to_fits(fn=None)

Write L0 data to a FITS file (plain ImageHDU, no compression).

to_kpf1()

Create a KPF1 scaffold from this L0, carrying over headers and pass-through extensions.

The raw WMKO PRIMARY header is converted to EPRV-standard keyword names and values here (the single conversion site; see _map_header), so the L1 PRIMARY is already EPRV-standard (EPRV-registered keywords only). The DRP-RUN provenance cards (DRPVERNO/PROGID/KOAID/DRPSTATU) live on RECEIPT (stamped at read) and reach L1 via the RECEIPT-header forward below. The L0 PRIMARY as ingested is preserved in the immutable INSTRUMENT_HEADER extension. Downstream stages read raw instrument keywords from INSTRUMENT_HEADER and write EPRV/registered KPF keywords to PRIMARY.

Returns a KPF1 with EPRV PRIMARY header, INSTRUMENT_HEADER, pass-through extensions (CA_HK, EXPMETER_SCI/SKY, TELEMETRY, DRP_CONFIG), receipt, and obs_id copied over. GREEN_CCD, GREEN_VAR, RED_CCD, RED_VAR are created but empty — the caller (image assembly) fills those in.