quality_control.diagnostics

class kpfpipe.quality_control.diagnostics.DiagL0(kpf_obj)

Bases: Diagnostics

LEVEL = 'L0'
gaia_ra_dec_offset()

GAIAOFF: arcsec, RA/DEC pointing vs GAIAID position at obs epoch.

Skipped when the frame has no pointing or no usable GAIAID; a Gaia network/lookup failure warns and skips (fail-soft).

object_ra_dec_offset()

OBJOFF: arcsec, RA/DEC pointing vs SIMBAD(OBJECT) position at obs epoch.

Skipped when the frame has no pointing or no OBJECT name; a SIMBAD network/lookup failure (or an unresolvable name) warns and skips.

target_ra_dec_offset()

TARGOFF: arcsec, RA/DEC pointing vs TARGRA/DEC target at obs epoch.

Skipped when the frame has no pointing or no DCS target (e.g. a calibration frame).

class kpfpipe.quality_control.diagnostics.DiagL1(kpf_obj)

Bases: Diagnostics

LEVEL = 'L1'
calibration_ages()

Signed fractional-day age (master - obs) for each associated master.

Recomputed from the finished L1 product: the master path is read from RECEIPT ({PREFIX}FILE, written by CalibrationAssociation) and the observation timestamp from PRIMARY (DATE-OBS). The master timestamp is parsed from its filename. A cal type is skipped when its path is absent; the whole metric is skipped when DATE-OBS is missing.

Returns:

Maps each present {PREFIX}AGE keyword to its (age, comment).

Return type:

dict

class kpfpipe.quality_control.diagnostics.DiagL2(kpf_obj)

Bases: Diagnostics

Diagnostics for KPF Level 2 extracted spectra products.

LEVEL = 'L2'
nan_counts()

Count NaN pixels per fiber in {CHIP}_{FIBER}_FLUX, summed across chips.

Always emits all five keys; fibers with no extracted data report 0.

Returns:

Maps each per-fiber NaN-count keyword to its (value, comment).

Return type:

dict

orderlet_flux_ratios()

Median inter-fiber flux ratios per chip (fiber-throughput stability).

Ratio is the per-order median flux of fiber A over fiber B, then the median across orders. All fibers share the order/pixel grid, so no wavelength resampling is needed.

snr()

Representative SNR per chip for the summed-SCI, SKY, and CAL fibers.

A compact RV-stability indicator: per order take the 95th-percentile of flux/sqrt(|var|), then the median across orders. Summed SCI uses SCI1+SCI2+SCI3 flux and variance. Skipped per (chip, fiber) when that data is absent.

zero_flux_fraction()

Compute the fraction of L2 flux pixels exactly equal to zero.

Counts across all {CHIP}_{FIBER}_FLUX extensions. Skipped (no key written) when no L2 data is present — QCL2.DATAPRL2 will have already failed in that case.

Returns:

{"ZEROFRAC": (fraction, comment)}, or empty when no L2 data is present.

Return type:

dict

class kpfpipe.quality_control.diagnostics.DiagL4(kpf_obj)

Bases: Diagnostics

Diagnostics for KPF Level 4 RV/CCF products.

LEVEL = 'L4'
berv_dispersion()

Weighted-mean barycentric RV correction and per-order spread (SCI2).

bjd_dispersion()

Photon-weighted mean BJD_TDB and its per-order spread (SCI2).

class kpfpipe.quality_control.diagnostics.Diagnostics(kpf_obj)

Bases: object

Base runner for per-level diagnostic metric methods.

Parameters:

kpf_obj (KPFDataModel) – Finished data product whose headers receive the metrics (via set_keyword, routed to each keyword’s registry-home extension).

LEVEL = None
run()

Run all diagnostic methods, writing each result via set_keyword.

Resets self.results at the start so calling run() repeatedly is deterministic.

Returns:

Maps each FITS keyword to its (value, comment) pair.

Return type:

dict

Submodules

base

Diagnostics framework base class.

level0

Diagnostics for KPF Level 0 (raw CCD) data products.

level1

Diagnostics for KPF Level 1 (assembled FFI) data products.

level2

Diagnostics for KPF Level 2 (extracted spectra) data products.

level4

Diagnostics for KPF Level 4 (RVs and CCFs) data products.