diff --git a/test/test_ctselect.py b/test/test_ctselect.py index c1c0fc4..8fa6349 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -68,8 +68,11 @@ class Test(test): self.append(self._test_ignore_emin_value, 'CTSELECT - Test ignore emin value') self.append(self._test_ROI_selection_displaced, 'CTSELECT - Test ROI selection displaced') self.append(self._test_ROI_selection_outside, 'CTSELECT - Test ROI selection outside') - self.append(self._test_set_ebounds_usetresh_user,'CTSELECT - Test set ebounds usetresh user' - self.append(self._test_phase_cut, 'CTSELECT - Test phase cut') + self.append(self._test_set_ebounds_usetresh_user,'CTSELECT - Test set ebounds usetresh user') + self.append(self._test_set_ebounds_usetresh_default,'CTSELECT - Test set ebounds usetresh default') + self.append(self._test_phase_selection_2inter, 'CTSELECT - Test phase selection 2 interval') + self.append(self._test_phase_selection_first_inter, 'CTSELECT - Test phase selection 2 interval') + self.append(self._test_phase_selection_second_inter, 'CTSELECT - Test phase selection 2 interval') self.append(self._test_invalid_phase_value_string, 'CTSELECT - Test invalid phase value or string') # Return @@ -345,13 +348,13 @@ class Test(test): # Return return - # Unit Test time selection function + # Unit Test time selection function -------------------------------------------- def _test_time_selection(self): """ Unit Test time selection """ - select = self._setup(inobs=self._events,tmin=0.0,tmax=10.0,emin=0.2,emax=80,outobs='ctselect_pyTimeSelection.fits',logfile='ctselect_pyTimeSelection.log') + select = self._setup(inobs=self._events,tmin=0.0,tmax=10.0,emin=0.2,emax=80,outobs='ctselect_py_TimeSelection.fits',logfile='ctselect_py_TimeSelection.log') # Run ctselect tool select.logFileOpen() # Make sure we get a log file @@ -359,7 +362,7 @@ class Test(test): select.save() # Check result file - self._check_result_file('ctselect_pyTimeSelection.fits', 'time selection',nevents=10) + self._check_result_file('ctselect_py_TimeSelection.fits', 'time selection',nevents=10) self._teardown(select) @@ -367,13 +370,13 @@ class Test(test): # Return return - # Unit Test set ebounds function + # Unit Test set ebounds function ----------------------------------------------------- def _test_set_ebounds_usetresh_user(self): """ Unit Test set ebounds with USER usetresh """ - select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,usethres='USER',outobs='ctselect_pySetEboundsUser.fits',logfile='ctselect_pySetEboundsUser.log') + select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,usethres='USER',outobs='ctselect_py_SetEboundsUser.fits',logfile='ctselect_py_SetEboundsUser.log') # Run ctselect tool select.logFileOpen() # Make sure we get a log file @@ -381,7 +384,7 @@ class Test(test): select.save() # Check result file - self._check_result_file('ctselect_pySetEboundsUser.fits', ' USER usetresh') + self._check_result_file('ctselect_py_SetEboundsUser.fits', ' USER usetresh') self._teardown(select) @@ -389,9 +392,27 @@ class Test(test): return + def _test_set_ebounds_usetresh_default(self): + """ + Unit Test set ebounds with DEFAULT usetresh + + """ + select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,usethres='DEFAULT',outobs='ctselect_py_SetEboundsDef.fits',logfile='ctselect_py_SetEboundsDef.log') + + # Run ctselect tool + select.logFileOpen() # Make sure we get a log file + select.run() + select.save() + + # Check result file + self._check_result_file('ctselect_py_SetEboundsDef.fits', ' DEFAULT usetresh',nevents=2000) + + self._teardown(select) + + # Return + return - # Unit Test for ctselect copy def _test_for_ctselect_copy(self): @@ -606,7 +627,7 @@ class Test(test): # Return return - # Unit Test ROI selection function + # Unit Test ROI selection function ---------------------------------------------------------------------------- def _test_ROI_selection_displaced(self): """ Unit Test ROI selection @@ -615,14 +636,14 @@ class Test(test): # Setup ctselect tool with an RoI that is displaced and of the same # size as the original RoI. This should reduce the RoI radius # automatically. - select = self._setup(inobs=self._events,dec=24.01,rad=5,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_pyROIDisp.fits',logfile='ctselect_pyROIDisp.log',chatter=3) + select = self._setup(inobs=self._events,dec=24.01,rad=5,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_py_ROIDisp.fits',logfile='ctselect_py_ROIDisp.log',chatter=3) # Execute tool select.logFileOpen() # Needed to get a new log file select.execute() # Check result file - self._check_result_file('ctselect_pyROIDisp.fits','ROI displaced same size', nevents=466, dec=24.01) + self._check_result_file('ctselect_py_ROIDisp.fits','ROI displaced same size', nevents=466, dec=24.01) self._teardown(select) @@ -635,14 +656,14 @@ class Test(test): """ - select = self._setup(inobs=self._events,dec=24.01,rad=5,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_pyROIOut.fits',logfile='ctselect_pyROIOut.log',chatter=3) + select = self._setup(inobs=self._events,dec=24.01,rad=5,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_py_ROIOut.fits',logfile='ctselect_py_ROIOut.log',chatter=3) # Now put the RoI outside the existing RoI. This should leave to # an empty event list. select['ra'] = 83.63 select['dec'] = -22.01 - select['outobs'] = 'ctselect_pyROIOut.fits[EVENTS;GTI]' - select['logfile'] = 'ctselect_pyROIOut.log' + select['outobs'] = 'ctselect_py_ROIOut.fits[EVENTS;GTI]' + select['logfile'] = 'ctselect_py_ROIOut.log' select['chatter'] = 3 # Execute tool @@ -650,7 +671,7 @@ class Test(test): select.execute() # Check result file - self._check_result_file('ctselect_pyROIOut.fits','ROI outside existing ROI', nevents=0, dec=-22.01, + self._check_result_file('ctselect_py_ROIOut.fits','ROI outside existing ROI', nevents=0, dec=-22.01, rad=5.0) self._teardown(select) @@ -659,26 +680,65 @@ class Test(test): return - # Unit Test phase cut - def _test_phase_cut(self): + # Unit Test phase selection function ------------------------------------------------------------------------------------------------ + def _test_phase_selection_2inter(self): """ - Unit Test phase cut + Unit Test phase selction for a double interval """ - select = self._setup(inobs=self._phased_events,rad=5.0,tmin='INDEF',tmax='INDEF',phase='0.1:0.4,0.6:0.8',outobs='ctselect_py11.fits',logfile='ctselect_py11.log') + select = self._setup(inobs=self._phased_events,rad=5.0,tmin='INDEF',tmax='INDEF',phase='0.1:0.4,0.6:0.8',outobs='ctselect_py_Phase2Inter.fits',logfile='ctselect_py_Phase2Inter.log') # Run ctselect tool select.logFileOpen() # Make sure we get a log file select.execute() # Check result file - self._check_result_file('ctselect_py11.fits','Phase cut', nevents=1909, rad=5.0) + self._check_result_file('ctselect_py_Phase2Inter.fits','Phase selection with 2 interval', nevents=1909, rad=5.0) self._teardown(select) # Return return + def _test_phase_selection_first_inter(self): + """ + Unit Test phase selection for the first interval + + """ + select = self._setup(inobs=self._phased_events,rad=5.0,tmin='INDEF',tmax='INDEF',phase='0.1:0.4',outobs='ctselect_py_PhaseFirstInter.fits',logfile='ctselect_py_PhaseFirstInter.log') + + # Run ctselect tool + select.logFileOpen() # Make sure we get a log file + select.execute() + + # Check result file + self._check_result_file('ctselect_py_PhaseFirstInter.fits','Phase selection with first interval', nevents=1170, rad=5.0) + + self._teardown(select) + + # Return + return + + def _test_phase_selection_second_inter(self): + """ + Unit Test phase selection for the second interval + + """ + select = self._setup(inobs=self._phased_events,rad=5.0,tmin='INDEF',tmax='INDEF',phase='0.6:0.8',outobs='ctselect_py_PhaseSecondInter.fits',logfile='ctselect_py_PhaseSecondInter.log') + + # Run ctselect tool + select.logFileOpen() # Make sure we get a log file + select.execute() + + # Check result file + self._check_result_file('ctselect_py_PhaseSecondInter.fits','Phase selection with second interval', nevents=739, rad=5.0) + + self._teardown(select) + + # Return + return + + # Unit Test invalid phase value or string def _test_invalid_phase_value_string(self): """