Skip to content

Commit

Permalink
testing the combine evtlists function
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicapilling committed Dec 18, 2024
1 parent 0396631 commit cd2475e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/generate/test_esass_misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import unittest

import os
import shutil
import numpy as np

from astropy.units import Quantity

from .. import set_up_test_config, restore_og_cfg

# I know it is horrible to write code in the middle of importing modules, but this needs to
# happen before xga is imported, as we are moving config files
set_up_test_config()

# Now when xga is imported it will make a new census with the test_data
import xga
from xga.sources import GalaxyCluster
from xga.generate.esass.misc import evtool_combine_evts

class TestPhotFuncs(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""
This is run once before all tests. Here we define class objects that we want to test.
"""
cls.test_src = GalaxyCluster(226.0318, -2.8046, 0.2093, r500=Quantity(500, 'kpc'),
name="1eRASS_J150407.6-024816", use_peak=False,
telescope='erosita',
search_distance={'erosita': Quantity(3.6, 'deg')})
cls.test_src_all_tels = GalaxyCluster(226.0318, -2.8046, 0.2093, r500=Quantity(500, 'kpc'),
name="1eRASS_J150407.6-024816", use_peak=False,
search_distance={'erosita': Quantity(3.6, 'deg')})

@classmethod
def tearDownClass(cls):
"""
This is run once after all the tests.
"""
# This function restores the user's original config file and deletes the test one made
restore_og_cfg()
# Then we will delete all the products that xga has made so there aren't loads of big files
# in the package
# shutil.rmtree('tests/test_data/xga_output')

def test_evtool_combine_evts(self):
evtool_combine_evts(self.test_src)

evtlist = self.test_src.get_products("combined_events", just_obj=False, telescope='erosita')[0]

assert evtlist.telescope == 'erosita'
assert set(evtlist.obs_ids) == set(self.test_src.obs_ids['erosita'])

if __name__ == "__main__":
unittest.main()

0 comments on commit cd2475e

Please sign in to comment.