def validate_raft_results(results, raft_names):
    """Validate the raft level results."""
    run = siteUtils.getRunNumber()
    slot_names = camera_info.get_slot_names()
    md = siteUtils.DataCatalogMetadata(ORIGIN=siteUtils.getSiteName(),
                                       TEST_CATEGORY='EO',
                                       DATA_PRODUCT='EOTEST_RESULTS')
    missing_raft_names = []
    for raft_name in raft_names:
        for slot_name in slot_names:
            det_name = make_file_prefix(raft_name, slot_name)
            file_prefix = make_file_prefix(run, det_name)
            results_file = '{}_eotest_results.fits'.format(file_prefix)
            if not os.path.isfile(results_file):
                if raft_name not in missing_raft_names:
                    missing_raft_names.append(raft_name)
                continue
            eotestUtils.addHeaderData(results_file,
                                      DETECTOR=det_name,
                                      DATE=eotestUtils.utc_now_isoformat(),
                                      RUNNUM=run)
            results.append(
                lcatr.schema.fileref.make(results_file,
                                          metadata=md(SLOT=slot_name,
                                                      RAFT=raft_name)))

        # Persist the png files.
        png_file_list = '{}_raft_results_task_png_files.txt'.format(raft_name)
        if not os.path.isfile(png_file_list):
            continue
        with open(png_file_list, 'r') as input_:
            png_files = [x.strip() for x in input_]
        metadata = dict(TEST_CATEGORY='EO', DETECTOR=det_name, RUN=run)
        results.extend(
            siteUtils.persist_png_files('',
                                        file_prefix,
                                        png_files=png_files,
                                        metadata=metadata))

    report_missing_data("validate_raft_results",
                        missing_raft_names,
                        components='rafts',
                        total=21)

    return results
def get_raft_files_by_slot(raft_name, file_suffix, jobname=None):
    """Return a dictionary of raft filenames, keyed by slot_name."""
    run = '*'
    template = '{}_{}_{}_' + file_suffix
    raft_files = dict()
    for slot_name in camera_info.get_slot_names():
        pattern = template.format(raft_name, slot_name, run)
        filenames = glob.glob(pattern)
        if filenames:
            raft_files[slot_name] = filenames[0]
        else:
            filenames = siteUtils.dependency_glob(pattern, jobname=jobname)
            if filenames:
                raft_files[slot_name] = filenames[0]
    if not raft_files:
        raise FileNotFoundError("no files found for raft %s with suffix %s"
                                % (raft_name, file_suffix))
    return raft_files
Beispiel #3
0
# Query for the files for each run in order to cache results locally.
fp_server.query_file_paths(Run)
fp_server.query_file_paths(Fe55Run)

det_name = '_'.join((raft, slot))
# eotest results files for the different runs.
fe55_results_file = '_'.join((det_name, Fe55Run, 'eotest_results.fits'))
eotest_results_file = '_'.join((det_name, Run, 'eotest_results.fits'))

fe55_files = fp_server.get_files('BOT_acq',
                                 f'fe55_flat_*/*{det_name}.fits',
                                 run=Fe55Run)
bias_files = fp_server.get_files('BOT_acq', f'bias_bias_*/*{det_name}.fits')

# Science raft slot names
slots = [_ for _ in camera_info.get_slot_names() if _ not in 'SG0 SG1 SW0 SW1']

# Bias frames for the C-protocol run
bias_frames = sorted(
    [os.path.basename(os.path.dirname(_)) for _ in bias_files])

# This dict is needed by the raft noise correlations task.
bias_file_dict = {
    _: fp_server.get_files('BOT_acq', f'{bias_frames[0]}/*{raft}_{_}.fits')[0]
    for _ in slots
}

# Find other types of files in the C-protocol run.
dark_files = fp_server.get_files('BOT_acq', f'dark_dark_*/*{det_name}.fits')
sflat_files = fp_server.get_files('BOT_acq',
                                  f'sflat_flat_*_H_*/*{det_name}.fits')