Commit c41c774afda57845fb9b4032ba6daad5fb5295f9
1 parent
047380aa
test ctselect add functionnal tests and invalide phase tests
Showing
1 changed file
with
188 additions
and
157 deletions
test/test_ctselect.py
| @@ -56,11 +56,9 @@ class Test(test): | @@ -56,11 +56,9 @@ class Test(test): | ||
| 56 | 56 | ||
| 57 | # Append tests | 57 | # Append tests |
| 58 | self.append(self._test_cmd, 'Test ctselect on command line') | 58 | self.append(self._test_cmd, 'Test ctselect on command line') |
| 59 | - self.append(self._test_empty_ctselect_tool, 'CTSELECT - Test empty ctselect tool') | ||
| 60 | - self.append(self._test_saving_empty_does_nothing, 'CTSELECT - Test saving empty does nothing') | ||
| 61 | - self.append(self._test_with_parameters,'CTSELECT - Test with parameters') | 59 | + self.append(self._test_init, 'CTSELECT - Test constructor and init') |
| 60 | + self.append(self._test_save_empty_does_nothing, 'CTSELECT - Test save empty does nothing') | ||
| 62 | self.append(self._test_time_selection,'CTSELECT - Test time_selection') | 61 | self.append(self._test_time_selection,'CTSELECT - Test time_selection') |
| 63 | - self.append(self._test_for_ctselect_copy,'CTSELECT - Test ctselect copy') | ||
| 64 | self.append(self._test_set_emin_emax, 'CTSELECT - Test set emin emax') | 62 | self.append(self._test_set_emin_emax, 'CTSELECT - Test set emin emax') |
| 65 | self.append(self._test_clear,'CTSELECT - Test Clear') | 63 | self.append(self._test_clear,'CTSELECT - Test Clear') |
| 66 | self.append(self._test_copy,'CTSELECT - Test Copy') | 64 | self.append(self._test_copy,'CTSELECT - Test Copy') |
| @@ -79,7 +77,14 @@ class Test(test): | @@ -79,7 +77,14 @@ class Test(test): | ||
| 79 | self.append(self._test_phase_selection_2inter, 'CTSELECT - Test phase_selection 2 interval') | 77 | self.append(self._test_phase_selection_2inter, 'CTSELECT - Test phase_selection 2 interval') |
| 80 | self.append(self._test_phase_selection_first_inter, 'CTSELECT - Test phase_selection first interval') | 78 | self.append(self._test_phase_selection_first_inter, 'CTSELECT - Test phase_selection first interval') |
| 81 | self.append(self._test_phase_selection_second_inter, 'CTSELECT - Test phase_selection second interval') | 79 | self.append(self._test_phase_selection_second_inter, 'CTSELECT - Test phase_selection second interval') |
| 82 | - self.append(self._test_invalid_phase_value_string, 'CTSELECT - Test invalid phase value or string') | 80 | + self.append(self._test_phase_invalid_min_negative,'CTSELECT - Test phase min negative value') |
| 81 | + self.append(self._test_phase_invalid_max_negative,'CTSELECT - Test phase max negative value') | ||
| 82 | + self.append(self._test_phase_invalid_minsupmax,'CTSELECT - Test phase min sup max') | ||
| 83 | + self.append(self._test_phase_invalid_missmin,'CTSELECT - Test phase missing min value') | ||
| 84 | + self.append(self._test_phase_invalid_missmax,'CTSELECT - Test phase missing max value') | ||
| 85 | + self.append(self._test_phase_invalid_syntax,'CTSELECT - Test phase invalid syntax') | ||
| 86 | + self.append(self._FuncTest_copy_none,'CTSELECT - Functionnal Test ctselect copy and none param') | ||
| 87 | + self.append(self._Functest_with_parameters,'CTSELECT - Test with parameters') | ||
| 83 | 88 | ||
| 84 | # Return | 89 | # Return |
| 85 | return | 90 | return |
| @@ -299,8 +304,8 @@ class Test(test): | @@ -299,8 +304,8 @@ class Test(test): | ||
| 299 | # Return | 304 | # Return |
| 300 | return | 305 | return |
| 301 | 306 | ||
| 302 | - # Unit Test empty ctselect tool | ||
| 303 | - def _test_empty_ctselect_tool(self): | 307 | + # Unit Test constructor and init ------------------------------------------------------------------ |
| 308 | + def _test_init(self): | ||
| 304 | """ | 309 | """ |
| 305 | Unit Test empty ctselect tool | 310 | Unit Test empty ctselect tool |
| 306 | 311 | ||
| @@ -315,16 +320,16 @@ class Test(test): | @@ -315,16 +320,16 @@ class Test(test): | ||
| 315 | # Return | 320 | # Return |
| 316 | return | 321 | return |
| 317 | 322 | ||
| 318 | - # Unit Test saving does nothing | ||
| 319 | - def _test_saving_empty_does_nothing(self): | 323 | + # Unit Test save empty does nothing ----------------------------------------------------------------- |
| 324 | + def _test_save_empty_does_nothing(self): | ||
| 320 | """ | 325 | """ |
| 321 | Unit Test saving empty does nothing | 326 | Unit Test saving empty does nothing |
| 322 | 327 | ||
| 323 | """ | 328 | """ |
| 324 | - select = self._setup(outobs='ctselect_py0.fits',logfile='ctselect_py0.log') | 329 | + select = self._setup(outobs='ctselect_py_SaveEmpty.fits',logfile='ctselect_py_SaveEmpty.log') |
| 325 | 330 | ||
| 326 | select.save() | 331 | select.save() |
| 327 | - self.test_assert(not os.path.isfile('ctselect_py0.fits'), | 332 | + self.test_assert(not os.path.isfile('ctselect_py_SaveEmpty.fits'), |
| 328 | 'Check that no event list has been created') | 333 | 'Check that no event list has been created') |
| 329 | 334 | ||
| 330 | self._teardown(select) | 335 | self._teardown(select) |
| @@ -332,29 +337,7 @@ class Test(test): | @@ -332,29 +337,7 @@ class Test(test): | ||
| 332 | # Return | 337 | # Return |
| 333 | return | 338 | return |
| 334 | 339 | ||
| 335 | - # Unit Test with parameters | ||
| 336 | - def _test_with_parameters(self): | ||
| 337 | - """ | ||
| 338 | - Unit Test with parameters | ||
| 339 | - | ||
| 340 | - """ | ||
| 341 | - select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,outobs='ctselect_py21.fits',logfile='ctselect_py21.log') | ||
| 342 | - | ||
| 343 | - # Run ctselect tool | ||
| 344 | - select.logFileOpen() # Make sure we get a log file | ||
| 345 | - select.run() | ||
| 346 | - select.save() | ||
| 347 | - | ||
| 348 | - # Check result file | ||
| 349 | - self._check_result_file('ctselect_py21.fits', 'with parameters') | ||
| 350 | - | ||
| 351 | - | ||
| 352 | - self._teardown(select) | ||
| 353 | - | ||
| 354 | - # Return | ||
| 355 | - return | ||
| 356 | - | ||
| 357 | - # Unit Test time selection function -------------------------------------------- | 340 | + # Unit Test time selection function ----------------------------------------------------------------------- |
| 358 | def _test_time_selection(self): | 341 | def _test_time_selection(self): |
| 359 | """ | 342 | """ |
| 360 | Unit Test time selection | 343 | Unit Test time selection |
| @@ -376,7 +359,7 @@ class Test(test): | @@ -376,7 +359,7 @@ class Test(test): | ||
| 376 | # Return | 359 | # Return |
| 377 | return | 360 | return |
| 378 | 361 | ||
| 379 | - # Unit Test set ebounds function ----------------------------------------------------- | 362 | + # Unit Test set ebounds function -------------------------------------------------------------------------- |
| 380 | def _test_set_ebounds_usetresh_user(self): | 363 | def _test_set_ebounds_usetresh_user(self): |
| 381 | """ | 364 | """ |
| 382 | Unit Test set ebounds with USER usetresh | 365 | Unit Test set ebounds with USER usetresh |
| @@ -450,6 +433,8 @@ class Test(test): | @@ -450,6 +433,8 @@ class Test(test): | ||
| 450 | 433 | ||
| 451 | self._teardown(select) | 434 | self._teardown(select) |
| 452 | 435 | ||
| 436 | + # Return | ||
| 437 | + return | ||
| 453 | 438 | ||
| 454 | # Unit Test for copy --------------------------------------------------------------------------------- | 439 | # Unit Test for copy --------------------------------------------------------------------------------- |
| 455 | def _test_copy(self): | 440 | def _test_copy(self): |
| @@ -472,78 +457,10 @@ class Test(test): | @@ -472,78 +457,10 @@ class Test(test): | ||
| 472 | 457 | ||
| 473 | self._teardown(select) | 458 | self._teardown(select) |
| 474 | 459 | ||
| 475 | - | ||
| 476 | - # Unit Test for ctselect copy | ||
| 477 | - def _test_for_ctselect_copy(self): | ||
| 478 | - """ | ||
| 479 | - Unit Test for ctselect copy | ||
| 480 | - | ||
| 481 | - """ | ||
| 482 | - select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,outobs='ctselect_py1.fits',logfile='ctselect_py1.log') | ||
| 483 | - | ||
| 484 | - # Run ctselect tool | ||
| 485 | - select.logFileOpen() # Make sure we get a log file | ||
| 486 | - select.run() | ||
| 487 | - select.save() | ||
| 488 | - | ||
| 489 | - # Copy ctselect tool | ||
| 490 | - cpy_select = select.copy() | ||
| 491 | - | ||
| 492 | - # Check observation of ctselect copy | ||
| 493 | - self._check_obs(cpy_select.obs(), 'ctselect copy') | ||
| 494 | - | ||
| 495 | - # Execute copy of ctselect tool again, now with a higher chatter | ||
| 496 | - # level than before and without any selection. Since the tools | ||
| 497 | - # still holds the same selected observation container from before | ||
| 498 | - # the number of events will be identical. | ||
| 499 | - cpy_select['ra'] = 'NONE' | ||
| 500 | - cpy_select['dec'] = 'NONE' | ||
| 501 | - cpy_select['rad'] = 'NONE' | ||
| 502 | - cpy_select['tmin'] = 'NONE' | ||
| 503 | - cpy_select['tmax'] = 'NONE' | ||
| 504 | - cpy_select['emin'] = 'NONE' | ||
| 505 | - cpy_select['emax'] = 'NONE' | ||
| 506 | - cpy_select['outobs'] = 'ctselect_py2.fits' | ||
| 507 | - cpy_select['logfile'] = 'ctselect_py2.log' | ||
| 508 | - cpy_select['chatter'] = 3 | ||
| 509 | - cpy_select['publish'] = True | ||
| 510 | - cpy_select.logFileOpen() # Needed to get a new log file | ||
| 511 | - cpy_select.execute() | ||
| 512 | - | ||
| 513 | - # Check result file | ||
| 514 | - self._check_result_file('ctselect_py2.fits','same selected obs container') | ||
| 515 | - | ||
| 516 | - # Execute again the copy of ctselect tool again, now using the pointing | ||
| 517 | - # information in the input observation. We also set the minimum values | ||
| 518 | - # to valid event selections, but since the maximum values are still | ||
| 519 | - # 'NONE', no event selections should occur. | ||
| 520 | - cpy_select['usepnt'] = True | ||
| 521 | - cpy_select['tmin'] = 500.0 | ||
| 522 | - cpy_select['emin'] = 0.2 | ||
| 523 | - cpy_select['usethres'] = 'USER' | ||
| 524 | - cpy_select['outobs'] = 'ctselect_py3.fits' | ||
| 525 | - cpy_select['logfile'] = 'ctselect_py3.log' | ||
| 526 | - cpy_select['chatter'] = 4 | ||
| 527 | - cpy_select.logFileOpen() # Needed to get a new log file | ||
| 528 | - cpy_select.execute() | ||
| 529 | - | ||
| 530 | - # Check result file | ||
| 531 | - self._check_result_file('ctselect_py3.fits', 'max value still none') | ||
| 532 | - | ||
| 533 | - # Now clear copy of ctselect tool | ||
| 534 | - cpy_select.clear() | ||
| 535 | - | ||
| 536 | - # Check that cleared ctselect tool holds no observations and events | ||
| 537 | - self._check_obs(cpy_select.obs(),'cleared ctselect tool', nobs=0) | ||
| 538 | - | ||
| 539 | - | ||
| 540 | - self._teardown(select) | ||
| 541 | - | ||
| 542 | # Return | 460 | # Return |
| 543 | return | 461 | return |
| 544 | - | ||
| 545 | - | ||
| 546 | - # Unit Test check_infile function --------------------------------------------------------------- | 462 | + |
| 463 | + # Unit Test check_infile function ------------------------------------------------------------------------------------ | ||
| 547 | def _test_check_infile_invalid_event_file(self): | 464 | def _test_check_infile_invalid_event_file(self): |
| 548 | """ | 465 | """ |
| 549 | Unit Test check_infile invalid event file | 466 | Unit Test check_infile invalid event file |
| @@ -722,7 +639,7 @@ class Test(test): | @@ -722,7 +639,7 @@ class Test(test): | ||
| 722 | select.save() | 639 | select.save() |
| 723 | 640 | ||
| 724 | # Check result file | 641 | # Check result file |
| 725 | - self._check_result_file('ctselect_py_ExprSelection.fits', 'time selection',nevents=3) | 642 | + self._check_result_file('ctselect_py_ExprSelection.fits', 'time selection',nevents=2) |
| 726 | 643 | ||
| 727 | 644 | ||
| 728 | self._teardown(select) | 645 | self._teardown(select) |
| @@ -842,106 +759,220 @@ class Test(test): | @@ -842,106 +759,220 @@ class Test(test): | ||
| 842 | # Return | 759 | # Return |
| 843 | return | 760 | return |
| 844 | 761 | ||
| 845 | - | ||
| 846 | - # Unit Test invalid phase value or string | ||
| 847 | - def _test_invalid_phase_value_string(self): | 762 | + def _test_phase_invalid_min_negative(self): |
| 848 | """ | 763 | """ |
| 849 | - Unit Test invalid phase value or string | 764 | + Unit Test invalid phase min value |
| 850 | 765 | ||
| 851 | """ | 766 | """ |
| 852 | - select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='0.8:0.3',outobs='ctselect_py12.fits',logfile='ctselect_py12.log') | ||
| 853 | - | ||
| 854 | - # Run ctselect tool | ||
| 855 | - select.logFileOpen() # Make sure we get a log file | ||
| 856 | - select.execute() | 767 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='-0.1:0.3',outobs='ctselect_py_PhaseMinNegative.fits',logfile='ctselect_py_PhaseMinNegative.log') |
| 857 | 768 | ||
| 858 | # Test invalid minimum phase value | 769 | # Test invalid minimum phase value |
| 859 | self.test_try('Test invalid minimum phase value -0.1:0.3') | 770 | self.test_try('Test invalid minimum phase value -0.1:0.3') |
| 860 | try: | 771 | try: |
| 861 | - select['phase'] = '-0.1:0.3' | ||
| 862 | - select['outobs'] = 'ctselect_py13.fits' | ||
| 863 | - select['logfile'] = 'ctselect_py13.log' | ||
| 864 | select.logFileOpen() | 772 | select.logFileOpen() |
| 865 | select.execute() | 773 | select.execute() |
| 866 | self.test_try_failure('Exception not thrown for "-0.1:0.3"') | 774 | self.test_try_failure('Exception not thrown for "-0.1:0.3"') |
| 867 | except ValueError: | 775 | except ValueError: |
| 868 | self.test_try_success() | 776 | self.test_try_success() |
| 777 | + | ||
| 778 | + self._teardown(select) | ||
| 869 | 779 | ||
| 870 | - # Test invalid minimum phase value | ||
| 871 | - self.test_try('Test invalid minimum phase value 1.1:0.3') | ||
| 872 | - try: | ||
| 873 | - select['phase'] = '1.1:0.3' | ||
| 874 | - select['outobs'] = 'ctselect_py14.fits' | ||
| 875 | - select['logfile'] = 'ctselect_py14.log' | ||
| 876 | - select.logFileOpen() | ||
| 877 | - select.execute() | ||
| 878 | - self.test_try_failure('Exception not thrown for "1.1:0.3"') | ||
| 879 | - except ValueError: | ||
| 880 | - self.test_try_success() | 780 | + # Return |
| 781 | + return | ||
| 782 | + | ||
| 783 | + def _test_phase_invalid_max_negative(self): | ||
| 784 | + """ | ||
| 785 | + Unit Test invalid phase max value | ||
| 881 | 786 | ||
| 882 | - # Test invalid maximum phase value | ||
| 883 | - self.test_try('Test invalid maximum phase value 0.1:-0.3') | 787 | + """ |
| 788 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='0.1:-0.3',outobs='ctselect_py_PhaseMaxNegative.fits',logfile='ctselect_py_PhaseMaxNegative.log') | ||
| 789 | + | ||
| 790 | + # Test invalid minimum phase value | ||
| 791 | + self.test_try('Test invalid maximun phase value 0.1:-0.3') | ||
| 884 | try: | 792 | try: |
| 885 | - select['phase'] = '0.1:-0.3' | ||
| 886 | - select['outobs'] = 'ctselect_py15.fits' | ||
| 887 | - select['logfile'] = 'ctselect_py15.log' | ||
| 888 | select.logFileOpen() | 793 | select.logFileOpen() |
| 889 | select.execute() | 794 | select.execute() |
| 890 | self.test_try_failure('Exception not thrown for "0.1:-0.3"') | 795 | self.test_try_failure('Exception not thrown for "0.1:-0.3"') |
| 891 | except ValueError: | 796 | except ValueError: |
| 892 | self.test_try_success() | 797 | self.test_try_success() |
| 798 | + | ||
| 799 | + self._teardown(select) | ||
| 893 | 800 | ||
| 894 | - # Test invalid maximum phase value | ||
| 895 | - self.test_try('Test invalid maximum phase value 0.1:1.1') | 801 | + # Return |
| 802 | + return | ||
| 803 | + | ||
| 804 | + def _test_phase_invalid_minsupmax(self): | ||
| 805 | + """ | ||
| 806 | + Unit Test invalid phase value min sup max | ||
| 807 | + | ||
| 808 | + """ | ||
| 809 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='1.1:0.3',outobs='ctselect_py_PhaseMinSupMax.fits',logfile='ctselect_py_PhaseMinSupMax.log') | ||
| 810 | + | ||
| 811 | + # Test invalid minimum phase value | ||
| 812 | + self.test_try('Test invalid phase value 1.1:0.3') | ||
| 896 | try: | 813 | try: |
| 897 | - select['phase'] = '0.1:1.1' | ||
| 898 | - select['outobs'] = 'ctselect_py16.fits' | ||
| 899 | - select['logfile'] = 'ctselect_py16.log' | ||
| 900 | select.logFileOpen() | 814 | select.logFileOpen() |
| 901 | select.execute() | 815 | select.execute() |
| 902 | - self.test_try_failure('Exception not thrown for "0.1:1.1"') | 816 | + self.test_try_failure('Exception not thrown for "1.1:0.3"') |
| 903 | except ValueError: | 817 | except ValueError: |
| 904 | self.test_try_success() | 818 | self.test_try_success() |
| 819 | + | ||
| 820 | + self._teardown(select) | ||
| 821 | + | ||
| 822 | + # Return | ||
| 823 | + return | ||
| 824 | + | ||
| 825 | + def _test_phase_invalid_missmin(self): | ||
| 826 | + """ | ||
| 827 | + Unit Test invalid phase missing min | ||
| 828 | + | ||
| 829 | + """ | ||
| 830 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='0.1:',outobs='ctselect_py_PhaseMissMin.fits',logfile='ctselect_py_PhaseMissMin.log') | ||
| 905 | 831 | ||
| 906 | - # Test invalid phase string | ||
| 907 | - self.test_try('Test invalid phase string 0.1:') | 832 | + # Test invalid minimum phase value |
| 833 | + self.test_try('Test invalid phase value 0.1:') | ||
| 908 | try: | 834 | try: |
| 909 | - select['phase'] = '0.1:' | ||
| 910 | - select['outobs'] = 'ctselect_py17.fits' | ||
| 911 | - select['logfile'] = 'ctselect_py17.log' | ||
| 912 | select.logFileOpen() | 835 | select.logFileOpen() |
| 913 | select.execute() | 836 | select.execute() |
| 914 | self.test_try_failure('Exception not thrown for "0.1:"') | 837 | self.test_try_failure('Exception not thrown for "0.1:"') |
| 915 | except ValueError: | 838 | except ValueError: |
| 916 | self.test_try_success() | 839 | self.test_try_success() |
| 840 | + | ||
| 841 | + self._teardown(select) | ||
| 842 | + | ||
| 843 | + # Return | ||
| 844 | + return | ||
| 845 | + | ||
| 846 | + def _test_phase_invalid_missmax(self): | ||
| 847 | + """ | ||
| 848 | + Unit Test invalid phase missing max | ||
| 917 | 849 | ||
| 918 | - # Test invalid phase string | ||
| 919 | - self.test_try('Test invalid phase string :1.0') | 850 | + """ |
| 851 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase=':1.0',outobs='ctselect_py_PhaseMissMax.fits',logfile='ctselect_py_PhaseMissMax.log') | ||
| 852 | + | ||
| 853 | + # Test invalid minimum phase value | ||
| 854 | + self.test_try('Test invalid phase value :1.0') | ||
| 920 | try: | 855 | try: |
| 921 | - select['phase'] = ':1.0' | ||
| 922 | - select['outobs'] = 'ctselect_py18.fits' | ||
| 923 | - select['logfile'] = 'ctselect_py18.log' | ||
| 924 | select.logFileOpen() | 856 | select.logFileOpen() |
| 925 | select.execute() | 857 | select.execute() |
| 926 | self.test_try_failure('Exception not thrown for ":1.0"') | 858 | self.test_try_failure('Exception not thrown for ":1.0"') |
| 927 | except ValueError: | 859 | except ValueError: |
| 928 | self.test_try_success() | 860 | self.test_try_success() |
| 861 | + | ||
| 862 | + self._teardown(select) | ||
| 863 | + | ||
| 864 | + # Return | ||
| 865 | + return | ||
| 866 | + | ||
| 867 | + def _test_phase_invalid_syntax(self): | ||
| 868 | + """ | ||
| 869 | + Unit Test invalid phase syntax | ||
| 929 | 870 | ||
| 930 | - # Test invalid phase string | ||
| 931 | - self.test_try('Test invalid phase string 0.1-1.0') | 871 | + """ |
| 872 | + select = self._setup(inobs=self._phased_events,rad=5,tmin='INDEF',tmax='INDEF',phase='0.1-1.0',outobs='ctselect_py_PhaseSyntax.fits',logfile='ctselect_py_PhaseSyntax.log') | ||
| 873 | + | ||
| 874 | + # Test invalid minimum phase value | ||
| 875 | + self.test_try('Test invalid phase syntax :1.0') | ||
| 932 | try: | 876 | try: |
| 933 | - select['phase'] = '0.1-1.0' | ||
| 934 | - select['outobs'] = 'ctselect_py19.fits' | ||
| 935 | - select['logfile'] = 'ctselect_py19.log' | ||
| 936 | select.logFileOpen() | 877 | select.logFileOpen() |
| 937 | select.execute() | 878 | select.execute() |
| 938 | - self.test_try_failure('Exception not thrown for "0.1-1.0"') | 879 | + self.test_try_failure('Exception not thrown for ":1.0"') |
| 939 | except ValueError: | 880 | except ValueError: |
| 940 | self.test_try_success() | 881 | self.test_try_success() |
| 941 | - | 882 | + |
| 942 | self._teardown(select) | 883 | self._teardown(select) |
| 943 | 884 | ||
| 944 | # Return | 885 | # Return |
| 945 | return | 886 | return |
| 946 | 887 | ||
| 888 | + # Functionnal Test for ctselect ------------------------------------------------------------------------------------------------- | ||
| 889 | + def _FuncTest_copy_none(self): | ||
| 890 | + """ | ||
| 891 | + Functionnal Test for ctselect copy and none | ||
| 892 | + | ||
| 893 | + """ | ||
| 894 | + select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,outobs='ctselect_py_CopyNone.fits',logfile='ctselect_py_CopyNone.log') | ||
| 895 | + | ||
| 896 | + # Run ctselect tool | ||
| 897 | + select.logFileOpen() # Make sure we get a log file | ||
| 898 | + select.run() | ||
| 899 | + select.save() | ||
| 900 | + | ||
| 901 | + # Copy ctselect tool | ||
| 902 | + cpy_select = select.copy() | ||
| 903 | + | ||
| 904 | + # Check observation of ctselect copy | ||
| 905 | + self._check_obs(cpy_select.obs(), 'Functionnal Test for ctselect copy and none') | ||
| 906 | + | ||
| 907 | + # Execute copy of ctselect tool again, now with a higher chatter | ||
| 908 | + # level than before and without any selection. Since the tools | ||
| 909 | + # still holds the same selected observation container from before | ||
| 910 | + # the number of events will be identical. | ||
| 911 | + cpy_select['ra'] = 'NONE' | ||
| 912 | + cpy_select['dec'] = 'NONE' | ||
| 913 | + cpy_select['rad'] = 'NONE' | ||
| 914 | + cpy_select['tmin'] = 'NONE' | ||
| 915 | + cpy_select['tmax'] = 'NONE' | ||
| 916 | + cpy_select['emin'] = 'NONE' | ||
| 917 | + cpy_select['emax'] = 'NONE' | ||
| 918 | + cpy_select['outobs'] = 'ctselect_py_SameCont.fits' | ||
| 919 | + cpy_select['logfile'] = 'ctselect_py_SameCont.log' | ||
| 920 | + cpy_select['chatter'] = 3 | ||
| 921 | + cpy_select['publish'] = True | ||
| 922 | + cpy_select.logFileOpen() # Needed to get a new log file | ||
| 923 | + cpy_select.execute() | ||
| 924 | + | ||
| 925 | + # Check result file | ||
| 926 | + self._check_result_file('ctselect_py_SameCont.fits','same selected obs container') | ||
| 927 | + | ||
| 928 | + # Execute again the copy of ctselect tool again, now using the pointing | ||
| 929 | + # information in the input observation. We also set the minimum values | ||
| 930 | + # to valid event selections, but since the maximum values are still | ||
| 931 | + # 'NONE', no event selections should occur. | ||
| 932 | + cpy_select['usepnt'] = True | ||
| 933 | + cpy_select['tmin'] = 500.0 | ||
| 934 | + cpy_select['emin'] = 0.2 | ||
| 935 | + cpy_select['usethres'] = 'USER' | ||
| 936 | + cpy_select['outobs'] = 'ctselect_py_MaxStillNone.fits' | ||
| 937 | + cpy_select['logfile'] = 'ctselect_py_MaxStillNone.log' | ||
| 938 | + cpy_select['chatter'] = 4 | ||
| 939 | + cpy_select.logFileOpen() # Needed to get a new log file | ||
| 940 | + cpy_select.execute() | ||
| 941 | + | ||
| 942 | + # Check result file | ||
| 943 | + self._check_result_file('ctselect_py_MaxStillNone.fits', 'max value still none') | ||
| 944 | + | ||
| 945 | + # Now clear copy of ctselect tool | ||
| 946 | + cpy_select.clear() | ||
| 947 | + | ||
| 948 | + # Check that cleared ctselect tool holds no observations and events | ||
| 949 | + self._check_obs(cpy_select.obs(),'cleared ctselect tool', nobs=0) | ||
| 950 | + | ||
| 951 | + | ||
| 952 | + self._teardown(select) | ||
| 953 | + | ||
| 954 | + # Return | ||
| 955 | + return | ||
| 956 | + | ||
| 957 | + # Functionnal Test with randoms parameters | ||
| 958 | + def _Functest_with_parameters(self): | ||
| 959 | + """ | ||
| 960 | + Unit Test with parameters | ||
| 961 | + | ||
| 962 | + """ | ||
| 963 | + select = self._setup(inobs=self._events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80,outobs='ctselect_py_FuncParam.fits',logfile='ctselect_py_FuncParam.log') | ||
| 964 | + | ||
| 965 | + # Run ctselect tool | ||
| 966 | + select.logFileOpen() # Make sure we get a log file | ||
| 967 | + select.run() | ||
| 968 | + select.save() | ||
| 969 | + | ||
| 970 | + # Check result file | ||
| 971 | + self._check_result_file('ctselect_py_FuncParam.fits', 'with parameters') | ||
| 972 | + | ||
| 973 | + | ||
| 974 | + self._teardown(select) | ||
| 975 | + | ||
| 976 | + # Return | ||
| 977 | + return | ||
| 947 | 978 | ||
| 948 | \ No newline at end of file | 979 | \ No newline at end of file |