Keck-DataReductionPipelines / KPF-Pipeline

KPF-Pipeline
https://kpf-pipeline.readthedocs.io/en/latest/
Other
11 stars 2 forks source link

Added a QC function for data products #724

Closed awhoward closed 11 months ago

awhoward commented 11 months ago

This QC function checks if the expected data products (from the TRIGTARG keyword) are present and have non-zero array sizes. @rrubenza will also be interested in this. This is the related Issue: https://github.com/Keck-DataReductionPipelines/KPF-Pipeline/issues/665

For now, I'd just like to see if it passes CI. And @RussLaher mightlook at it.

I have not included this explicitly in any recipes. It will only work with L0 files (I think), not 2D, L1, L2.

Here's some sample code to run this from my Jupyter Notebook:

# Import packages for reading files
from modules.Utils.kpf_parse import get_datecode
from kpfpipe.models.level0 import KPF0

ObsID = 'KP.20231108.77769.16'  # file with missing Red data that Ryan flagged
L0_filename = '/data/L0/' + get_datecode(ObsID) + '/' + ObsID + '.fits'
L0 = KPF0.from_fits(L0_filename)

# Test of 'L0_data_products_check' QC check
import modules.quality_control.src.quality_control as qc
from modules.quality_control.src.quality_control import L0_data_products_check
qc_name = 'L0_data_products_check'
qc_value = L0_data_products_check(L0)
qcl0 = qc.QCL0(L0)
qcl0.add_qc_keyword_to_header(qc_name,qc_value)
L0_new = qcl0.fits_object
print(L0_new.header['PRIMARY']['DATAPRES'])