-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing the combine evtlists function
- Loading branch information
1 parent
0396631
commit cd2475e
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |