quality_control.quicklook.level2
L2 quicklook plots for extracted KPF 1D spectra.
Ports the extracted-spectrum quicklook plots from the v2.12 AnalyzeL1
class (the old pipeline’s “L1” level is vNext’s L2). These plots REQUIRE an
attached wavelength solution: the per-fiber {chip}_{fiber}_WAVE arrays
must be populated (i.e. WavelengthCalibration has run). If they are not, the
plot methods raise rather than silently producing a pixel-axis plot that
could be mistaken for a wavelength-calibrated one (charter: fail loudly).
Pure visualization — no science computation is written back to the product.
- class kpfpipe.quality_control.quicklook.level2.PlotL2(l2_obj, output_dir=None, obs_id=None)
Bases:
objectQuicklook plots for KPF L2 (extracted 1D spectra) data.
- Parameters:
l2_obj – KPF2 data object (post-SpectralExtraction; requires WavelengthCalibration to have populated the per-fiber WAVE arrays).
output_dir – directory to save PNG files. None = return Figure only.
obs_id – observation ID for titles/filenames. If None, falls back to the l2_obj.obs_id attribute (populated on every construction path).
- orderlet_flux_ratios(chip)
Per-order orderlet flux ratios (SCI1/SCI2, SCI3/SCI2, SCI1/SCI3, SKY/SCI2, CAL/SCI2) vs order-center wavelength, one panel each, with the all-order median annotated.
- peak_flux(chip)
Per-order peak flux (95th pctile counts) for each fiber and the summed-SCI orderlet.
- run(which)
Generate the requested plot(s) for every chip that has data, saving each to
output_dir. In that save-to-disk mode the figure is closed so callers don’t accumulate them; whenoutput_diris None the figures are returned open, so they display when the caller renders them (e.g. interactively in a notebook).- Parameters:
which – ‘all’ to run every implemented plot, or the name of a single plot method (one of
self._PLOT_METHODS).- Returns:
dict mapping
{method_name}_{chip}to matplotlib.Figure (closed only when saved tooutput_dir; useful for tests/introspection).
- snr_per_order(chip)
Per-order SNR (95th pctile of flux/sqrt(|var|)) for each fiber plus the summed-SCI orderlet, vs order-center wavelength.
- spectrum_one_row(chip, fibers=None)
Stacked per-fiber spectrum: one panel per fiber, all orders of that fiber concatenated, x-axis is concatenated wavelength.
- spectrum_single_order(chip, order=None)
Overplot the science orderlets (and SKY/CAL) for a single spectral order vs wavelength.
- Parameters:
chip – ‘GREEN’ or ‘RED’.
order – 1-indexed spectral order. Defaults to a representative order near the middle of the chip.