Commit a32266947a2be83ce22bc7091c57779fb6b411e8
1 parent
016e6222
debugging unit test (cmd line still not working)
Showing
2 changed files
with
13 additions
and
11 deletions
cscripts/__init__.py.in
| ... | ... | @@ -35,6 +35,7 @@ __all__ = [ |
| 35 | 35 | "csobsdef", |
| 36 | 36 | "csobsinfo", |
| 37 | 37 | "csobsselect", |
| 38 | + "csphagen", | |
| 38 | 39 | "csphasecrv", |
| 39 | 40 | "cspull", |
| 40 | 41 | "csresmap", |
| ... | ... | @@ -70,6 +71,7 @@ from cscripts.csobs2caldb import csobs2caldb |
| 70 | 71 | from cscripts.csobsdef import csobsdef |
| 71 | 72 | from cscripts.csobsinfo import csobsinfo |
| 72 | 73 | from cscripts.csobsselect import csobsselect |
| 74 | +from cscripts.csphagen import csphagen | |
| 73 | 75 | from cscripts.csphasecrv import csphasecrv |
| 74 | 76 | from cscripts.cspull import cspull |
| 75 | 77 | from cscripts.csresmap import csresmap | ... | ... |
test/test_csphagen.py
| ... | ... | @@ -79,7 +79,7 @@ class Test(test): |
| 79 | 79 | |
| 80 | 80 | cmd = csphagen + 'inobs="' + self._myevents1 + \ |
| 81 | 81 | '" caldb="' + self._caldb + '" irf="' + self._irf + \ |
| 82 | - '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + nbins + \ | |
| 82 | + '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + str(nbins) + \ | |
| 83 | 83 | '" coordsys=CEL' + ' ra=83.633 dec=22.0145 rad=0.2 stack=no exclusion="' + \ |
| 84 | 84 | self._exclusion + '" outroot=genpha_cmd1' + \ |
| 85 | 85 | ' logfile="csphagen_cmd1.log" chatter=1' |
| ... | ... | @@ -98,7 +98,7 @@ class Test(test): |
| 98 | 98 | |
| 99 | 99 | cmd = csphagen + 'inobs="events_that_do_not_exist.fits"' + \ |
| 100 | 100 | '" caldb="' + self._caldb + '" irf="' + self._irf + \ |
| 101 | - '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + nbins + \ | |
| 101 | + '" ebinalg=LOG emin=0.1 emax=100. enumbins="' + str(nbins) + \ | |
| 102 | 102 | '" coordsys=CEL' + ' ra=83.633 dec=22.0145 rad=0.2 stack=no exclusion="' + \ |
| 103 | 103 | self._exclusion + '" outroot=genpha_cmd2' + \ |
| 104 | 104 | ' logfile="csphagen_cmd2.log" chatter=1' |
| ... | ... | @@ -141,7 +141,7 @@ class Test(test): |
| 141 | 141 | # Run script |
| 142 | 142 | phagen.execute() |
| 143 | 143 | |
| 144 | - # Check outout | |
| 144 | + # Check output | |
| 145 | 145 | self._check_output('genpha_py1_', nbins, self._nreg_with_excl) |
| 146 | 146 | self._check_outobs('genpha_py1', 1) |
| 147 | 147 | |
| ... | ... | @@ -166,7 +166,7 @@ class Test(test): |
| 166 | 166 | # Run script |
| 167 | 167 | phagen.execute() |
| 168 | 168 | |
| 169 | - # Check outout | |
| 169 | + # Check output | |
| 170 | 170 | self._check_output('genpha_py2_', nbins, self._nreg_wo_excl) |
| 171 | 171 | self._check_outobs('genpha_py2', 1) |
| 172 | 172 | |
| ... | ... | @@ -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, self.caldb) | |
| 179 | + run.response(self._irf, gammalib.GCaldb('cta',self._caldb)) | |
| 180 | 180 | obs.append(run) |
| 181 | 181 | |
| 182 | 182 | # Setup csphagen |
| ... | ... | @@ -257,7 +257,7 @@ class Test(test): |
| 257 | 257 | |
| 258 | 258 | # Check SPECTRUM table |
| 259 | 259 | table = fits['EBOUNDS'] |
| 260 | - self._check_ebounds(table, nbins) | |
| 260 | + self._check_ebounds(table, bins) | |
| 261 | 261 | |
| 262 | 262 | # Close FITS file |
| 263 | 263 | fits.close() |
| ... | ... | @@ -333,7 +333,7 @@ class Test(test): |
| 333 | 333 | |
| 334 | 334 | # Check EBOUNDS table |
| 335 | 335 | table = fits['EBOUNDS'] |
| 336 | - self._check_ebounds(table, nbins) | |
| 336 | + self._check_ebounds(table, bins) | |
| 337 | 337 | |
| 338 | 338 | # Close FITS file |
| 339 | 339 | fits.close() |
| ... | ... | @@ -341,7 +341,7 @@ class Test(test): |
| 341 | 341 | # Return |
| 342 | 342 | return |
| 343 | 343 | |
| 344 | - def _check_output(self, filenameroot, bins, nreg, nout): | |
| 344 | + def _check_output(self, filenameroot, bins, nreg): | |
| 345 | 345 | """ |
| 346 | 346 | Check the output from a csphagen run |
| 347 | 347 | """ |
| ... | ... | @@ -358,10 +358,10 @@ class Test(test): |
| 358 | 358 | # Regions |
| 359 | 359 | reg = gammalib.GSkyRegions(filenameroot + "_on.reg") |
| 360 | 360 | self.test_value(reg.size(), 1, 'Check for ' + str( |
| 361 | - number) + ' region in source region file') | |
| 361 | + 1) + ' region in source region file') | |
| 362 | 362 | reg = gammalib.GSkyRegions(filenameroot + "_off.reg") |
| 363 | 363 | self.test_value(reg.size(), nreg, 'Check for ' + str( |
| 364 | - number) + ' region in background region file') | |
| 364 | + nreg) + ' region in background region file') | |
| 365 | 365 | |
| 366 | 366 | return |
| 367 | 367 | |
| ... | ... | @@ -371,6 +371,6 @@ class Test(test): |
| 371 | 371 | """ |
| 372 | 372 | obs = gammalib.GObservations(filenameroot + '.xml') |
| 373 | 373 | self.test_value(obs.size(), nout, 'Check for ' + str( |
| 374 | - number) + ' observations in XML file') | |
| 374 | + nout) + ' observations in XML file') | |
| 375 | 375 | |
| 376 | 376 | return | ... | ... |