Commit 40d2e1527a8761cd246d994343807fba9e2bb7ef
1 parent
a3226694
test unit debugged
Showing
2 changed files
with
25 additions
and
25 deletions
cscripts/csphagen.py
100644 → 100755
test/test_csphagen.py
| ... | ... | @@ -77,12 +77,12 @@ class Test(test): |
| 77 | 77 | csphagen = self._script('csphagen') |
| 78 | 78 | nbins = 120 |
| 79 | 79 | |
| 80 | - cmd = csphagen + 'inobs="' + self._myevents1 + \ | |
| 81 | - '" caldb="' + self._caldb + '" irf="' + self._irf + \ | |
| 82 | - '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + str(nbins) + \ | |
| 83 | - '" coordsys=CEL' + ' ra=83.633 dec=22.0145 rad=0.2 stack=no exclusion="' + \ | |
| 84 | - self._exclusion + '" outroot=genpha_cmd1' + \ | |
| 85 | - ' logfile="csphagen_cmd1.log" chatter=1' | |
| 80 | + cmd = csphagen + ' inobs="' + self._myevents1 + '" caldb="' + \ | |
| 81 | + self._caldb + '" irf="' + self._irf + \ | |
| 82 | + '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ | |
| 83 | + str(nbins) + ' coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 84 | + ' rad=0.2 stack="no" exclusion="' + self._exclusion + \ | |
| 85 | + '" outroot="phagen_cmd1" logfile="csphagen_cmd1.log" chatter=1' | |
| 86 | 86 | |
| 87 | 87 | # Check if execution of wrong command fails |
| 88 | 88 | self.test_assert(self._execute('command_that_does_not_exist') != 0, |
| ... | ... | @@ -93,21 +93,21 @@ class Test(test): |
| 93 | 93 | 'Check successful execution from command line') |
| 94 | 94 | |
| 95 | 95 | # Check output files |
| 96 | - self._check_output('genpha_cmd1_', nbins, self._nreg_with_excl) | |
| 97 | - self._check_outobs('genpha_cmd1', 1) | |
| 96 | + self._check_output('phagen_cmd1_', nbins, self._nreg_with_excl) | |
| 97 | + self._check_outobs('phagen_cmd1', 1) | |
| 98 | 98 | |
| 99 | - cmd = csphagen + 'inobs="events_that_do_not_exist.fits"' + \ | |
| 100 | - '" caldb="' + self._caldb + '" irf="' + self._irf + \ | |
| 101 | - '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + str(nbins) + \ | |
| 102 | - '" coordsys=CEL' + ' ra=83.633 dec=22.0145 rad=0.2 stack=no exclusion="' + \ | |
| 103 | - self._exclusion + '" outroot=genpha_cmd2' + \ | |
| 104 | - ' logfile="csphagen_cmd2.log" chatter=1' | |
| 99 | + cmd = csphagen + ' inobs="events_that_do_not_exist.fits" caldb="' + \ | |
| 100 | + self._caldb + '" irf="' + self._irf + \ | |
| 101 | + '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ | |
| 102 | + str(nbins) + ' coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 103 | + ' rad=0.2 stack="no" exclusion="' + self._exclusion + \ | |
| 104 | + '" outroot="phagen_cmd1" logfile="csphagen_cmd1.log" chatter=1' | |
| 105 | 105 | |
| 106 | 106 | # Check if execution failed |
| 107 | 107 | self.test_assert(self._execute(cmd) != 0, |
| 108 | 108 | 'Check invalid input file when executed from command line') |
| 109 | 109 | |
| 110 | - # Check cslightcrv --help | |
| 110 | + # Check csphagen --help | |
| 111 | 111 | self._check_help(csphagen) |
| 112 | 112 | |
| 113 | 113 | # Return |
| ... | ... | @@ -134,7 +134,7 @@ class Test(test): |
| 134 | 134 | phagen['rad'] = 0.2 |
| 135 | 135 | phagen['stack'] = False |
| 136 | 136 | phagen['exclusion'] = self._exclusion |
| 137 | - phagen['outroot'] = 'genpha_py1' | |
| 137 | + phagen['outroot'] = 'phagen_py1' | |
| 138 | 138 | phagen['logfile'] = 'csphagen_py1.log' |
| 139 | 139 | phagen['chatter'] = 1 |
| 140 | 140 | |
| ... | ... | @@ -142,8 +142,8 @@ class Test(test): |
| 142 | 142 | phagen.execute() |
| 143 | 143 | |
| 144 | 144 | # Check output |
| 145 | - self._check_output('genpha_py1_', nbins, self._nreg_with_excl) | |
| 146 | - self._check_outobs('genpha_py1', 1) | |
| 145 | + self._check_output('phagen_py1_', nbins, self._nreg_with_excl) | |
| 146 | + self._check_outobs('phagen_py1', 1) | |
| 147 | 147 | |
| 148 | 148 | # Now test without exclusion region |
| 149 | 149 | phagen = cscripts.csphagen() |
| ... | ... | @@ -159,7 +159,7 @@ class Test(test): |
| 159 | 159 | phagen['dec'] = 22.0145 |
| 160 | 160 | phagen['rad'] = 0.2 |
| 161 | 161 | phagen['stack'] = False |
| 162 | - phagen['outroot'] = 'genpha_py2' | |
| 162 | + phagen['outroot'] = 'phagen_py2' | |
| 163 | 163 | phagen['logfile'] = 'csphagen_py2.log' |
| 164 | 164 | phagen['chatter'] = 1 |
| 165 | 165 | |
| ... | ... | @@ -167,8 +167,8 @@ class Test(test): |
| 167 | 167 | phagen.execute() |
| 168 | 168 | |
| 169 | 169 | # Check output |
| 170 | - self._check_output('genpha_py2_', nbins, self._nreg_wo_excl) | |
| 171 | - self._check_outobs('genpha_py2', 1) | |
| 170 | + self._check_output('phagen_py2_', nbins, self._nreg_wo_excl) | |
| 171 | + self._check_outobs('phagen_py2', 1) | |
| 172 | 172 | |
| 173 | 173 | # Test with multiple input observations, no stacking |
| 174 | 174 | # Create observation container |
| ... | ... | @@ -176,7 +176,7 @@ class Test(test): |
| 176 | 176 | for s, events in enumerate([self._myevents1, self._myevents2]): |
| 177 | 177 | run = gammalib.GCTAObservation(events) |
| 178 | 178 | run.id(str(s + 1)) |
| 179 | - run.response(self._irf, gammalib.GCaldb('cta',self._caldb)) | |
| 179 | + run.response(self._irf, gammalib.GCaldb('cta', self._caldb)) | |
| 180 | 180 | obs.append(run) |
| 181 | 181 | |
| 182 | 182 | # Setup csphagen |
| ... | ... | @@ -191,7 +191,7 @@ class Test(test): |
| 191 | 191 | phagen['rad'] = 0.2 |
| 192 | 192 | phagen['stack'] = False |
| 193 | 193 | phagen['exclusion'] = self._exclusion |
| 194 | - phagen['outroot'] = 'genpha_py3' | |
| 194 | + phagen['outroot'] = 'phagen_py3' | |
| 195 | 195 | phagen['logfile'] = 'csphagen_py3.log' |
| 196 | 196 | phagen['chatter'] = 1 |
| 197 | 197 | |
| ... | ... | @@ -200,9 +200,9 @@ class Test(test): |
| 200 | 200 | |
| 201 | 201 | # Check outout |
| 202 | 202 | for s in range(2): |
| 203 | - self._check_output('genpha_py3_' + str(s + 1), nbins, | |
| 203 | + self._check_output('phagen_py3_' + str(s + 1), nbins, | |
| 204 | 204 | self._nreg_mul[s]) |
| 205 | - self._check_outobs('genpha_py3', 2) | |
| 205 | + self._check_outobs('phagen_py3', 2) | |
| 206 | 206 | |
| 207 | 207 | return |
| 208 | 208 | ... | ... |