Skip to content

Commit

Permalink
add test for RMF
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrigno committed Oct 16, 2024
1 parent 4290767 commit d203616
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Binary file added tests/test_data/isgri_rmf_Crab.fits
Binary file not shown.
25 changes: 25 additions & 0 deletions tests/test_data_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from astropy.table import Table
from matplotlib import pyplot as plt

import base64
import pickle

secret_key = 'secretkey_test'
default_exp_time = int(time.time()) + 5000
default_token_payload = dict(
Expand All @@ -33,6 +36,28 @@
mssub=True
)


def test_rmf():
isgri_rmf_dp = NumpyDataProduct.from_fits_file("test_data/isgri_rmf_Crab.fits")

encoded_numpy_data_prod = isgri_rmf_dp.encode()
decoded_numpy_data_prod = NumpyDataProduct.decode(encoded_numpy_data_prod)

binarys = base64.b64decode(encoded_numpy_data_prod['data_unit_list'][2]['binarys'])
try:
pickle.loads(binarys, encoding='bytes')
except Exception as ee:
raise Exception(ee)

_hdul = fits.HDUList()
for ID, _d in enumerate(decoded_numpy_data_prod.data_unit):
print(ID, _d.header['EXTNAME'])
try:
_hdul.append(_d.to_fits_hdu())
except Exception as ee:
raise Exception(ee)


# TODO: adapt to new product types and implement corresponding tests
def encode_decode(ndp: typing.Union[NumpyDataProduct,
ODAAstropyTable,
Expand Down

0 comments on commit d203616

Please sign in to comment.