add test for column presence in the PHACountSpectrum.read method
@@ -473,13 +473,24 @@ class PHACountsSpectrum(CountsSpectrum):
ebounds = fits_table_to_table(hdulist[2])
emin = ebounds['E_MIN'].quantity
emax = ebounds['E_MAX'].quantity
+
+ # Check if column are present in the header
+ quality=None
+ areascal=None
+ backscal=None
+ if 'QUALITY' in counts_table:
+ quality = counts_table['QUALITY'].data
+ if 'AREASCAL' in counts_table:
+ areascal = counts_table['AREASCAL'].data
+ if 'BACKSCAL' in counts_table:
+ backscal = counts_table['BACKSCAL'].data
kwargs = dict(
data=counts_table['COUNTS'] * u.ct,
- backscal=counts_table['BACKSCAL'].data,
+ backscal=backscal,
energy_lo=emin,
energy_hi=emax,
- quality=counts_table['QUALITY'].data,
- areascal=counts_table['AREASCAL'].data,
+ quality=quality,
+ areascal=areascal,
meta=counts_table.meta
)
if hdulist[1].header['HDUCLAS2'] == 'BKG':
