Commit 35723bed647d85e965996d00641d201d21a973e5
1 parent
b8a1e552
Add csphagen unit test for CUSTOM method with off regions in CTA observations
Showing
3 changed files
with
36 additions
and
6 deletions
configure.ac
| ... | ... | @@ -32,8 +32,8 @@ AC_INIT([ctools], [1.5.0.dev1], [jurgen.knodlseder@irap.omp.eu], [ctools]) |
| 32 | 32 | AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) |
| 33 | 33 | AC_CONFIG_MACRO_DIR([m4]) |
| 34 | 34 | #AM_INIT_AUTOMAKE([gnu no-dependencies foreign]) |
| 35 | -AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) | |
| 36 | -#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) | |
| 35 | +#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) | |
| 36 | +AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) | |
| 37 | 37 | AC_CONFIG_HEADER([config.h]) |
| 38 | 38 | |
| 39 | 39 | ... | ... |
cscripts/csphagen.py
test/test_csphagen.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the csphagen script. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2017 Luigi Tibaldo | |
| 5 | +# Copyright (C) 2017-2018 Luigi Tibaldo | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -232,8 +232,7 @@ class Test(test): |
| 232 | 232 | self._nreg_mul[s]) |
| 233 | 233 | self._check_outobs('csphagen_py3', 2) |
| 234 | 234 | |
| 235 | - # Setup csphagen for test with multiple input observations and | |
| 236 | - # stacking | |
| 235 | + # Setup csphagen for test with multiple input observations and stacking | |
| 237 | 236 | phagen = cscripts.csphagen(obs) |
| 238 | 237 | phagen['ebinalg'] = 'LOG' |
| 239 | 238 | phagen['emin'] = 0.1 |
| ... | ... | @@ -291,6 +290,38 @@ class Test(test): |
| 291 | 290 | self._check_output('csphagen_py5', self._nbins, self._nreg_bkg_reg) |
| 292 | 291 | self._check_outobs('csphagen_py5', 1) |
| 293 | 292 | |
| 293 | + # Append off regions to observation container | |
| 294 | + for run in obs: | |
| 295 | + run.off_regions(gammalib.GSkyRegions(self._regfile_bkg)) | |
| 296 | + | |
| 297 | + # Setup csphagen for test with multiple input observations and stacking | |
| 298 | + phagen = cscripts.csphagen(obs) | |
| 299 | + phagen['ebinalg'] = 'LOG' | |
| 300 | + phagen['emin'] = 0.1 | |
| 301 | + phagen['emax'] = 100.0 | |
| 302 | + phagen['enumbins'] = self._nbins | |
| 303 | + phagen['coordsys'] = 'CEL' | |
| 304 | + phagen['stack'] = True | |
| 305 | + phagen['inexclusion'] = self._exclusion | |
| 306 | + phagen['bkgmethod'] = 'CUSTOM' | |
| 307 | + phagen['srcregfile'] = self._regfile_src | |
| 308 | + phagen['etruemin'] = 0.05 | |
| 309 | + phagen['etruemax'] = 150.0 | |
| 310 | + phagen['etruebins'] = 5 | |
| 311 | + phagen['outobs'] = 'csphagen_py6.xml' | |
| 312 | + phagen['prefix'] = 'csphagen_py6' | |
| 313 | + phagen['logfile'] = 'csphagen_py6.log' | |
| 314 | + phagen['chatter'] = 4 | |
| 315 | + | |
| 316 | + # Execute script | |
| 317 | + phagen.execute() | |
| 318 | + | |
| 319 | + # Check output | |
| 320 | + for s in range(2): | |
| 321 | + self._check_output('csphagen_py6_stacked', self._nbins, | |
| 322 | + 0, check_regions=False) | |
| 323 | + self._check_outobs('csphagen_py6', 1) | |
| 324 | + | |
| 294 | 325 | # Return |
| 295 | 326 | return |
| 296 | 327 | ... | ... |