Commit 39495ca1f9ba93b54e1946f955bf9e7ded2447f1
1 parent
10445115
test ctselect check_infile add
Showing
1 changed file
with
34 additions
and
41 deletions
test/test_ctselect.py
| ... | ... | @@ -62,7 +62,9 @@ class Test(test): |
| 62 | 62 | self.append(self._test_time_selection,'CTSELECT - Test time_selection') |
| 63 | 63 | self.append(self._test_for_ctselect_copy,'CTSELECT - Test ctselect copy') |
| 64 | 64 | self.append(self._test_set_emin_emax, 'CTSELECT - Test set emin emax') |
| 65 | - self.append(self._test_invalid_event_file, 'CTSELECT - Test invalid event file') | |
| 65 | + self.append(self._test_check_infile_invalid_event_file, 'CTSELECT - Test Check_Infile invalid event file') | |
| 66 | + self.append(self._test_check_infile_event_list_with_extension, 'CTSELECT - Test Check_Infile event file extension') | |
| 67 | + self.append(self._test_invalid_extension_name, 'CTSELECT - Test Check_Infile invalid extension name') | |
| 66 | 68 | self.append(self._test_event_list_with_extension_name, 'CTSELECT - Test event list with extension name') |
| 67 | 69 | self.append(self._test_energy_selection_emin_below,'CTSELECT - Test Energy_Selection emin below file value') |
| 68 | 70 | self.append(self._test_energy_selection_emax_above,'CTSELECT - Test Energy_Selection emax above file value') |
| ... | ... | @@ -494,73 +496,64 @@ class Test(test): |
| 494 | 496 | # Return |
| 495 | 497 | return |
| 496 | 498 | |
| 497 | - # Unit Test energy range beyond energies covered | |
| 498 | - def _test_energy_range_beyond_covered(self): | |
| 499 | - """ | |
| 500 | - Unit Test energy range beyond energies covered | |
| 501 | 499 | |
| 500 | + # Unit Test check_infile function --------------------------------------------------------------- | |
| 501 | + def _test_check_infile_invalid_event_file(self): | |
| 502 | 502 | """ |
| 503 | - # Get mixed observation container | |
| 504 | - obs = self._obs_mixed() | |
| 503 | + Unit Test check_infile invalid event file | |
| 505 | 504 | |
| 506 | - # Attach response function to first observation which is the | |
| 507 | - # event list. This is necessary to run the ctselect tool with | |
| 508 | - # "DEFAULT" thresholds. | |
| 509 | - obs[0].response('South_0.5h', gammalib.GCaldb('cta', 'prod2')) | |
| 510 | - | |
| 511 | - # Setup ctselect tool from observation container. An energy range | |
| 512 | - # beyond the energies covered in the event file is specified, hence | |
| 513 | - # an empty event list will be saved. | |
| 514 | - select = self._setup(tmin=500.0,tmax=1000.0,emin=120,emax=130,expr='DETX == 0',usethres='DEFAULT',outobs='ctselect_py4.fits',logfile='ctselect_py4.log',chatter=3, obs=obs) | |
| 515 | - | |
| 516 | - # Execute tool | |
| 517 | - select.logFileOpen() # Needed to get a new log file | |
| 518 | - select.execute() | |
| 519 | - | |
| 520 | - # Check result file | |
| 521 | - self._check_result_file('ctselect_py4.fits','energy range beyond energies covered', nevents=0) | |
| 522 | - | |
| 523 | - self._teardown(select) | |
| 524 | - | |
| 525 | - # Return | |
| 526 | - return | |
| 527 | - | |
| 528 | - # Unit Test invalid event file | |
| 529 | - def _test_invalid_event_file(self): | |
| 530 | 505 | """ |
| 531 | - Unit Test invalid event file | |
| 532 | - | |
| 533 | - """ | |
| 534 | - select = self._setup(inobs=self._invalid_events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_py5.fits',logfile='ctselect_py5.log',chatter=3) | |
| 506 | + select = self._setup(inobs=self._invalid_events,tmin=500.0,tmax=1000.0,emin=0.2,emax=80.0,outobs='ctselect_py_InvalidEventFile.fits',logfile='ctselect_py_InvalidEventFile.log',chatter=3) | |
| 535 | 507 | |
| 536 | 508 | # Execute tool |
| 537 | 509 | select.logFileOpen() # Needed to get a new log file |
| 538 | - self.test_try('Test invalid event file') | |
| 510 | + self.test_try('Test check_infile invalid event file') | |
| 539 | 511 | try: |
| 540 | 512 | select.execute() |
| 541 | 513 | self.test_try_failure('Exception not thrown') |
| 542 | 514 | except ValueError: |
| 543 | 515 | self.test_try_success() |
| 516 | + | |
| 544 | 517 | self._teardown(select) |
| 545 | 518 | |
| 546 | 519 | # Return |
| 547 | 520 | return |
| 548 | 521 | |
| 549 | 522 | # Unit Test event list with extension name |
| 550 | - def _test_event_list_with_extension_name(self): | |
| 523 | + def _test_check_infile_event_list_with_extension(self): | |
| 551 | 524 | """ |
| 552 | - Unit Test event list with extension name | |
| 525 | + Unit Test check_infile event list with extension name | |
| 553 | 526 | |
| 554 | 527 | """ |
| 555 | - select = self._setup(inobs=self._events+'[EVENTS]',tmin=500.0,tmax=1000.0,emin=0.2,emax=0.0,outobs='ctselect_py6.fits',logfile='ctselect_py6.log',chatter=3) | |
| 528 | + select = self._setup(inobs=self._events+'[EVENTS]',tmin=500.0,tmax=1000.0,emin=0.2,emax=0.0,outobs='ctselect_py_EventListExt.fits',logfile='ctselect_py_EventListExt.log',chatter=3) | |
| 556 | 529 | |
| 557 | 530 | # Execute tool |
| 558 | 531 | select.logFileOpen() # Needed to get a new log file |
| 559 | 532 | select.execute() |
| 560 | 533 | |
| 561 | 534 | # Check result file |
| 562 | - self._check_result_file('ctselect_py6.fits','event list with extension name', nevents=595) | |
| 535 | + self._check_result_file('ctselect_py_EventListExt.fits','event list with extension name', nevents=595) | |
| 536 | + | |
| 537 | + self._teardown(select) | |
| 538 | + | |
| 539 | + # Return | |
| 540 | + return | |
| 541 | + | |
| 542 | + def _test_invalid_extension_name(self): | |
| 543 | + """ | |
| 544 | + Unit Test invalid event extension | |
| 545 | + | |
| 546 | + """ | |
| 547 | + select = self._setup(inobs=self._events+'[EVENTSXXX]',tmin=500.0,tmax=1000.0,emin=0.2,emax=0.0,outobs='ctselect_py_EventListInvExt.fits',logfile='ctselect_py_EventListInvExt.log',chatter=3) | |
| 563 | 548 | |
| 549 | + # Execute tool | |
| 550 | + select.logFileOpen() # Needed to get a new log file | |
| 551 | + self.test_try('Test check_infile invalid event file') | |
| 552 | + try: | |
| 553 | + select.execute() | |
| 554 | + self.test_try_failure('Exception not thrown') | |
| 555 | + except ValueError: | |
| 556 | + self.test_try_success() | |
| 564 | 557 | self._teardown(select) |
| 565 | 558 | |
| 566 | 559 | # Return |
| ... | ... | @@ -568,7 +561,7 @@ class Test(test): |
| 568 | 561 | |
| 569 | 562 | |
| 570 | 563 | |
| 571 | - # Unit Test energy selection function and set eminemax -------------------------------------------------- | |
| 564 | + # Unit Test energy selection function and set eminemax --------------------------------------------------------------------------- | |
| 572 | 565 | def _test_energy_selection_emin_below(self): |
| 573 | 566 | """ |
| 574 | 567 | Unit Test energy selection emin below | ... | ... |