Commit 2ba7b22827502222838c9f9f6b66132cd5b1aec9

Authored by jean perrot
1 parent fa67c41c

refactoring test ctselect - add usetresh phase roi

Showing 1 changed file with 81 additions and 21 deletions
test/test_ctselect.py
@@ -68,8 +68,11 @@ class Test(test): @@ -68,8 +68,11 @@ class Test(test):
68 self.append(self._test_ignore_emin_value, 'CTSELECT - Test ignore emin value') 68 self.append(self._test_ignore_emin_value, 'CTSELECT - Test ignore emin value')
69 self.append(self._test_ROI_selection_displaced, 'CTSELECT - Test ROI selection displaced') 69 self.append(self._test_ROI_selection_displaced, 'CTSELECT - Test ROI selection displaced')
70 self.append(self._test_ROI_selection_outside, 'CTSELECT - Test ROI selection outside') 70 self.append(self._test_ROI_selection_outside, 'CTSELECT - Test ROI selection outside')
71 - self.append(self._test_set_ebounds_usetresh_user,'CTSELECT - Test set ebounds usetresh user'  
72 - self.append(self._test_phase_cut, 'CTSELECT - Test phase cut') 71 + self.append(self._test_set_ebounds_usetresh_user,'CTSELECT - Test set ebounds usetresh user')
  72 + self.append(self._test_set_ebounds_usetresh_default,'CTSELECT - Test set ebounds usetresh default')
  73 + self.append(self._test_phase_selection_2inter, 'CTSELECT - Test phase selection 2 interval')
  74 + self.append(self._test_phase_selection_first_inter, 'CTSELECT - Test phase selection 2 interval')
  75 + self.append(self._test_phase_selection_second_inter, 'CTSELECT - Test phase selection 2 interval')
73 self.append(self._test_invalid_phase_value_string, 'CTSELECT - Test invalid phase value or string') 76 self.append(self._test_invalid_phase_value_string, 'CTSELECT - Test invalid phase value or string')
74 77
75 # Return 78 # Return
@@ -345,13 +348,13 @@ class Test(test): @@ -345,13 +348,13 @@ class Test(test):
345 # Return 348 # Return
346 return 349 return
347 350
348 - # Unit Test time selection function 351 + # Unit Test time selection function --------------------------------------------
349 def _test_time_selection(self): 352 def _test_time_selection(self):
350 """ 353 """
351 Unit Test time selection 354 Unit Test time selection
352 355
353 """ 356 """
354 - 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') 357 + 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')
355 358
356 # Run ctselect tool 359 # Run ctselect tool
357 select.logFileOpen() # Make sure we get a log file 360 select.logFileOpen() # Make sure we get a log file
@@ -359,7 +362,7 @@ class Test(test): @@ -359,7 +362,7 @@ class Test(test):
359 select.save() 362 select.save()
360 363
361 # Check result file 364 # Check result file
362 - self._check_result_file('ctselect_pyTimeSelection.fits', 'time selection',nevents=10) 365 + self._check_result_file('ctselect_py_TimeSelection.fits', 'time selection',nevents=10)
363 366
364 367
365 self._teardown(select) 368 self._teardown(select)
@@ -367,13 +370,13 @@ class Test(test): @@ -367,13 +370,13 @@ class Test(test):
367 # Return 370 # Return
368 return 371 return
369 372
370 - # Unit Test set ebounds function 373 + # Unit Test set ebounds function -----------------------------------------------------
371 def _test_set_ebounds_usetresh_user(self): 374 def _test_set_ebounds_usetresh_user(self):
372 """ 375 """
373 Unit Test set ebounds with USER usetresh 376 Unit Test set ebounds with USER usetresh
374 377
375 """ 378 """
376 - 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') 379 + 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')
377 380
378 # Run ctselect tool 381 # Run ctselect tool
379 select.logFileOpen() # Make sure we get a log file 382 select.logFileOpen() # Make sure we get a log file
@@ -381,7 +384,7 @@ class Test(test): @@ -381,7 +384,7 @@ class Test(test):
381 select.save() 384 select.save()
382 385
383 # Check result file 386 # Check result file
384 - self._check_result_file('ctselect_pySetEboundsUser.fits', ' USER usetresh') 387 + self._check_result_file('ctselect_py_SetEboundsUser.fits', ' USER usetresh')
385 388
386 self._teardown(select) 389 self._teardown(select)
387 390
@@ -389,9 +392,27 @@ class Test(test): @@ -389,9 +392,27 @@ class Test(test):
389 return 392 return
390 393
391 394
  395 + def _test_set_ebounds_usetresh_default(self):
  396 + """
  397 + Unit Test set ebounds with DEFAULT usetresh
  398 +
  399 + """
  400 + 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')
  401 +
  402 + # Run ctselect tool
  403 + select.logFileOpen() # Make sure we get a log file
  404 + select.run()
  405 + select.save()
  406 +
  407 + # Check result file
  408 + self._check_result_file('ctselect_py_SetEboundsDef.fits', ' DEFAULT usetresh',nevents=2000)
  409 +
  410 + self._teardown(select)
  411 +
  412 + # Return
  413 + return
392 414
393 415
394 -  
395 416
396 # Unit Test for ctselect copy 417 # Unit Test for ctselect copy
397 def _test_for_ctselect_copy(self): 418 def _test_for_ctselect_copy(self):
@@ -606,7 +627,7 @@ class Test(test): @@ -606,7 +627,7 @@ class Test(test):
606 # Return 627 # Return
607 return 628 return
608 629
609 - # Unit Test ROI selection function 630 + # Unit Test ROI selection function ----------------------------------------------------------------------------
610 def _test_ROI_selection_displaced(self): 631 def _test_ROI_selection_displaced(self):
611 """ 632 """
612 Unit Test ROI selection 633 Unit Test ROI selection
@@ -615,14 +636,14 @@ class Test(test): @@ -615,14 +636,14 @@ class Test(test):
615 # Setup ctselect tool with an RoI that is displaced and of the same 636 # Setup ctselect tool with an RoI that is displaced and of the same
616 # size as the original RoI. This should reduce the RoI radius 637 # size as the original RoI. This should reduce the RoI radius
617 # automatically. 638 # automatically.
618 - 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) 639 + 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)
619 640
620 # Execute tool 641 # Execute tool
621 select.logFileOpen() # Needed to get a new log file 642 select.logFileOpen() # Needed to get a new log file
622 select.execute() 643 select.execute()
623 644
624 # Check result file 645 # Check result file
625 - self._check_result_file('ctselect_pyROIDisp.fits','ROI displaced same size', nevents=466, dec=24.01) 646 + self._check_result_file('ctselect_py_ROIDisp.fits','ROI displaced same size', nevents=466, dec=24.01)
626 647
627 self._teardown(select) 648 self._teardown(select)
628 649
@@ -635,14 +656,14 @@ class Test(test): @@ -635,14 +656,14 @@ class Test(test):
635 656
636 """ 657 """
637 658
638 - 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) 659 + 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)
639 660
640 # Now put the RoI outside the existing RoI. This should leave to 661 # Now put the RoI outside the existing RoI. This should leave to
641 # an empty event list. 662 # an empty event list.
642 select['ra'] = 83.63 663 select['ra'] = 83.63
643 select['dec'] = -22.01 664 select['dec'] = -22.01
644 - select['outobs'] = 'ctselect_pyROIOut.fits[EVENTS;GTI]'  
645 - select['logfile'] = 'ctselect_pyROIOut.log' 665 + select['outobs'] = 'ctselect_py_ROIOut.fits[EVENTS;GTI]'
  666 + select['logfile'] = 'ctselect_py_ROIOut.log'
646 select['chatter'] = 3 667 select['chatter'] = 3
647 668
648 # Execute tool 669 # Execute tool
@@ -650,7 +671,7 @@ class Test(test): @@ -650,7 +671,7 @@ class Test(test):
650 select.execute() 671 select.execute()
651 672
652 # Check result file 673 # Check result file
653 - self._check_result_file('ctselect_pyROIOut.fits','ROI outside existing ROI', nevents=0, dec=-22.01, 674 + self._check_result_file('ctselect_py_ROIOut.fits','ROI outside existing ROI', nevents=0, dec=-22.01,
654 rad=5.0) 675 rad=5.0)
655 676
656 self._teardown(select) 677 self._teardown(select)
@@ -659,26 +680,65 @@ class Test(test): @@ -659,26 +680,65 @@ class Test(test):
659 return 680 return
660 681
661 682
662 - # Unit Test phase cut  
663 - def _test_phase_cut(self): 683 + # Unit Test phase selection function ------------------------------------------------------------------------------------------------
  684 + def _test_phase_selection_2inter(self):
664 """ 685 """
665 - Unit Test phase cut 686 + Unit Test phase selction for a double interval
666 687
667 """ 688 """
668 - 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') 689 + 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')
669 690
670 # Run ctselect tool 691 # Run ctselect tool
671 select.logFileOpen() # Make sure we get a log file 692 select.logFileOpen() # Make sure we get a log file
672 select.execute() 693 select.execute()
673 694
674 # Check result file 695 # Check result file
675 - self._check_result_file('ctselect_py11.fits','Phase cut', nevents=1909, rad=5.0) 696 + self._check_result_file('ctselect_py_Phase2Inter.fits','Phase selection with 2 interval', nevents=1909, rad=5.0)
676 697
677 self._teardown(select) 698 self._teardown(select)
678 699
679 # Return 700 # Return
680 return 701 return
681 702
  703 + def _test_phase_selection_first_inter(self):
  704 + """
  705 + Unit Test phase selection for the first interval
  706 +
  707 + """
  708 + 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')
  709 +
  710 + # Run ctselect tool
  711 + select.logFileOpen() # Make sure we get a log file
  712 + select.execute()
  713 +
  714 + # Check result file
  715 + self._check_result_file('ctselect_py_PhaseFirstInter.fits','Phase selection with first interval', nevents=1170, rad=5.0)
  716 +
  717 + self._teardown(select)
  718 +
  719 + # Return
  720 + return
  721 +
  722 + def _test_phase_selection_second_inter(self):
  723 + """
  724 + Unit Test phase selection for the second interval
  725 +
  726 + """
  727 + 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')
  728 +
  729 + # Run ctselect tool
  730 + select.logFileOpen() # Make sure we get a log file
  731 + select.execute()
  732 +
  733 + # Check result file
  734 + self._check_result_file('ctselect_py_PhaseSecondInter.fits','Phase selection with second interval', nevents=739, rad=5.0)
  735 +
  736 + self._teardown(select)
  737 +
  738 + # Return
  739 + return
  740 +
  741 +
682 # Unit Test invalid phase value or string 742 # Unit Test invalid phase value or string
683 def _test_invalid_phase_value_string(self): 743 def _test_invalid_phase_value_string(self):
684 """ 744 """