quality_control.diagnostics.level2

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

class kpfpipe.quality_control.diagnostics.level2.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