Source code for process.soex.io.outputs
'''fits outputs for SOEX
Created on 21 february 2019
@author: Catalano Camille, APC
'''
from astropy.io import fits
from common.io import fits_tools
[docs]def save_spectrum(self, file_path, tstart, tstop, creator='SOEX?', proc_id="01"):
"""write the spectrum into a fits file ECL-SPS-S1
common keywords are included
filename is 'ECL-SPS-S1-' + proc_id + '.fits'
:param file_path: PATH to the directory where to write the file
:type file_path: string
:param tstart: start time of the observation in s from mjdref
:type tstart: float
:param tstop: end time of the observation in s from mjdref
:type tstop: float
:param creator: program that has generated the file. Default='SOEX?'
:type creator: string
:param proc_id: id of the process. Default="01".
:type proc_id: string
"""
# construction of the fits file
tbhdu = fits.table_to_hdu(self.spectrum)
prihdr = fits.Header()
prihdu = fits.PrimaryHDU(header=prihdr)
fits_tools.common_keyword(tbhdu, tstart, tstop, creator, 1.0, proc_id)
thdulist = fits.HDUList([prihdu, tbhdu])
thdulist[1].header['comment'] = "Count Spectrum"
thdulist[1].name = 'SPS'
thdulist.writeto(file_path + '/ECL-SPS-S1-' + proc_id + '.fits', overwrite=True, checksum=True)
[docs]def save_lightcurve(self, file_path, tstart, tstop, creator='SOEX?', proc_id="01"):
"""write the light curve into a fits file ECL-LCS-S1
common keywords are included
filename is 'ECL-LCS-S1-' + proc_id + '.fits'
:param file_path: PATH to the directory where to write the file
:type file_path: string
:param tstart: start time of the observation in s from mjdref
:type tstart: float
:param tstop: end time of the observation in s from mjdref
:type tstop: float
:param creator: program that has generated the file. Default='SOEX?'
:type creator: string
:param proc_id: id of the process. Default="01".
:type proc_id: string
"""
# construction of the fits file
tbhdu = fits.table_to_hdu(self.light_curve)
prihdr = fits.Header()
prihdu = fits.PrimaryHDU(header=prihdr)
fits_tools.common_keyword(tbhdu, tstart, tstop, creator, 1.0, proc_id)
thdulist = fits.HDUList([prihdu, tbhdu])
thdulist[1].header['comment'] = "Light curve"
thdulist[1].name = 'LCS'
thdulist.writeto(file_path + '/ECL-LCS-S1-' + proc_id + '.fits', overwrite=True, checksum=True)