Source code for ecpi.process.dpco.io.outputs

"""
@author: BACON Philippe, APC/CNRS/IN2P3
"""
from os import rename
from glob import glob
from shutil import copy
from astropy.io import fits


[docs]def save_cal_events(workdir_in, workdir_out, tstart, file_path, creator='DPCO?', proc_id="01"): """Save calibrated event data: ECL-EVT-CAL. ..warning: For DC1 this function only consists in copying the input event files and rename them. :param workdir_in: PATH to the working in directory :type workdir_in: string :param workdir_out: PATH to the working out directory :type workdir_out: string :param creator: program that has generated the file. Default='DPCO?'. :type creator: string :param proc_id: id of the process. Default="01". :type proc_id: string """ event_files_in = [fname for fname in glob(workdir_in + "/*.fits") \ if fname.split("/")[-1].startswith("ECL-EVT-SEC")] for file in event_files_in: copy(file, workdir_out) event_files_out = [fname for fname in glob(workdir_out + "/*.fits") \ if fname.split("/")[-1].startswith("ECL-EVT-SEC")] for file in event_files_out: new_name = file.replace("ECL-EVT-SEC-", "ECL-EVT-CAL-UTC") rename(file, new_name) # change CARD KW from ECL-EVT-SEC to ECL-EVT-CAL. hdulist = fits.open(new_name) header = hdulist[0].header header['CARD'] = 'ECL-EVT-CAL' header['OBS_ID'] = (1, 'Observation identifier (type_number)') hdulist.writeto(new_name, overwrite=True)