Commit 42d7a84ca1a64cd0e87facd5716319140c19032e
1 parent
af2b2eb7
Update unit tests after background cube interface changes (#2677)
Showing
3 changed files
with
15 additions
and
15 deletions
test/data/crab_bkgcube.fits.gz
100755 → 100644
No preview for this file type
test/test_ctbkgcube.py
| ... | ... | @@ -116,7 +116,7 @@ class Test(test): |
| 116 | 116 | |
| 117 | 117 | # Check that empty ctbkgcube tool holds a background cube that has |
| 118 | 118 | # no energy bins |
| 119 | - self._check_cube(bkgcube.bkgcube(), nenergies=0) | |
| 119 | + self._check_cube(bkgcube.bkgcube(), nebounds=0) | |
| 120 | 120 | |
| 121 | 121 | # Check that saving does not nothing |
| 122 | 122 | bkgcube['outcube'] = 'ctbkgcube_py0.fits' |
| ... | ... | @@ -209,7 +209,7 @@ class Test(test): |
| 209 | 209 | |
| 210 | 210 | # Check that the cleared copy has also cleared the background cube |
| 211 | 211 | # and model container |
| 212 | - self._check_cube(cpy_bkgcube.bkgcube(), nenergies=0) | |
| 212 | + self._check_cube(cpy_bkgcube.bkgcube(), nebounds=0) | |
| 213 | 213 | self._check_models(cpy_bkgcube.models(), nmodels=0) |
| 214 | 214 | |
| 215 | 215 | # Get mixel observation container |
| ... | ... | @@ -243,13 +243,13 @@ class Test(test): |
| 243 | 243 | bkgcube.execute() |
| 244 | 244 | |
| 245 | 245 | # Check result files |
| 246 | - self._check_result_files('ctbkgcube_py5', nenergies=8) | |
| 246 | + self._check_result_files('ctbkgcube_py5') | |
| 247 | 247 | |
| 248 | 248 | # Return |
| 249 | 249 | return |
| 250 | 250 | |
| 251 | 251 | # Check result files |
| 252 | - def _check_result_files(self, filename, nenergies=6, nmodels=2): | |
| 252 | + def _check_result_files(self, filename, nebounds=5, nmodels=2): | |
| 253 | 253 | """ |
| 254 | 254 | Check result file |
| 255 | 255 | |
| ... | ... | @@ -257,8 +257,8 @@ class Test(test): |
| 257 | 257 | ---------- |
| 258 | 258 | filename : str |
| 259 | 259 | Test file name without extension |
| 260 | - nenergies : int, optional | |
| 261 | - Number of energy bins | |
| 260 | + nebounds : int, optional | |
| 261 | + Number of energy boundaries | |
| 262 | 262 | """ |
| 263 | 263 | # Open background cube |
| 264 | 264 | cube = gammalib.GCTACubeBackground(filename+'.fits') |
| ... | ... | @@ -267,7 +267,7 @@ class Test(test): |
| 267 | 267 | models = gammalib.GModels(filename+'.xml') |
| 268 | 268 | |
| 269 | 269 | # Check cube |
| 270 | - self._check_cube(cube, nenergies=nenergies) | |
| 270 | + self._check_cube(cube, nebounds=nebounds) | |
| 271 | 271 | |
| 272 | 272 | # Check models |
| 273 | 273 | self._check_models(models, nmodels=nmodels) |
| ... | ... | @@ -276,7 +276,7 @@ class Test(test): |
| 276 | 276 | return |
| 277 | 277 | |
| 278 | 278 | # Check background cube |
| 279 | - def _check_cube(self, cube, nenergies=6): | |
| 279 | + def _check_cube(self, cube, nebounds=5): | |
| 280 | 280 | """ |
| 281 | 281 | Check background cube |
| 282 | 282 | |
| ... | ... | @@ -284,11 +284,11 @@ class Test(test): |
| 284 | 284 | ---------- |
| 285 | 285 | cube : `~gammalib.GCTACubeBackground` |
| 286 | 286 | Background cube |
| 287 | - nenergies : int, optional | |
| 288 | - Number of energy bins | |
| 287 | + nebounds : int, optional | |
| 288 | + Number of energy boundaries | |
| 289 | 289 | """ |
| 290 | 290 | # Check dimensions |
| 291 | - self.test_value(len(cube.energies()), nenergies, | |
| 291 | + self.test_value(len(cube.ebounds()), nebounds, | |
| 292 | 292 | 'Check number of energy maps') |
| 293 | 293 | |
| 294 | 294 | # Return | ... | ... |
test/test_obsutils.py
| ... | ... | @@ -478,7 +478,7 @@ class Test(test): |
| 478 | 478 | 'Check number of PSF cube maps') |
| 479 | 479 | self.test_value(res['bkgcube'].cube().npix(), 100, |
| 480 | 480 | 'Check number of background cube pixels') |
| 481 | - self.test_value(res['bkgcube'].cube().nmaps(), 61, | |
| 481 | + self.test_value(res['bkgcube'].cube().nmaps(), 5, | |
| 482 | 482 | 'Check number of background cube maps') |
| 483 | 483 | |
| 484 | 484 | # Get stacked response with None xref/yref |
| ... | ... | @@ -499,7 +499,7 @@ class Test(test): |
| 499 | 499 | 'Check number of PSF cube maps') |
| 500 | 500 | self.test_value(res['bkgcube'].cube().npix(), 100, |
| 501 | 501 | 'Check number of background cube pixels') |
| 502 | - self.test_value(res['bkgcube'].cube().nmaps(), 61, | |
| 502 | + self.test_value(res['bkgcube'].cube().nmaps(), 5, | |
| 503 | 503 | 'Check number of background cube maps') |
| 504 | 504 | |
| 505 | 505 | # Get stacked response with xref/yref set and large number of energy bins |
| ... | ... | @@ -520,7 +520,7 @@ class Test(test): |
| 520 | 520 | 'Check number of PSF cube maps') |
| 521 | 521 | self.test_value(res['bkgcube'].cube().npix(), 100, |
| 522 | 522 | 'Check number of background cube pixels') |
| 523 | - self.test_value(res['bkgcube'].cube().nmaps(), 101, | |
| 523 | + self.test_value(res['bkgcube'].cube().nmaps(), 100, | |
| 524 | 524 | 'Check number of background cube maps') |
| 525 | 525 | |
| 526 | 526 | # Get stacked response with energy dispersion |
| ... | ... | @@ -541,7 +541,7 @@ class Test(test): |
| 541 | 541 | 'Check number of PSF cube maps') |
| 542 | 542 | self.test_value(res['bkgcube'].cube().npix(), 100, |
| 543 | 543 | 'Check number of background cube pixels') |
| 544 | - self.test_value(res['bkgcube'].cube().nmaps(), 61, | |
| 544 | + self.test_value(res['bkgcube'].cube().nmaps(), 5, | |
| 545 | 545 | 'Check number of background cube maps') |
| 546 | 546 | self.test_value(res['edispcube'].cube().npix(), 4, |
| 547 | 547 | 'Check number of energy dispersion cube pixels') | ... | ... |