Commit 3064f16abb7e414179a4dc2714297865a65e4b38
1 parent
d6fa46a1
Add background model to science verification
Showing
5 changed files
with
42 additions
and
6 deletions
ChangeLog
| 1 | -2016-07-09 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 1 | +2016-07-18 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 2 | 2 | |
| 3 | 3 | * Version 1.1.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Add background model science verification (#1815) | |
| 6 | 7 | Add cstsmapsplit script (#1797) |
| 7 | 8 | Add unit tests for all example scripts |
| 8 | 9 | Handle zero parameter errors in ctulimit (#1795) | ... | ... |
NEWS
README.md
test/data/sciver/bgd.xml
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?> | |
| 2 | +<source_library title="source library"> | |
| 3 | + <source name="Background" type="CTAIrfBackground" instrument="CTA"> | |
| 4 | + <spectrum type="PowerLaw"> | |
| 5 | + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/> | |
| 6 | + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/> | |
| 7 | + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 8 | + </spectrum> | |
| 9 | + </source> | |
| 10 | +</source_library> | ... | ... |
test/science_verification.py
| ... | ... | @@ -234,6 +234,9 @@ class sciver(gammalib.GPythonTestSuite): |
| 234 | 234 | # Set test name |
| 235 | 235 | self.name('Science Verification') |
| 236 | 236 | |
| 237 | + # Append background model test | |
| 238 | + self.append(self.bgd, 'Test background model') | |
| 239 | + | |
| 237 | 240 | # Append spectral tests |
| 238 | 241 | self.append(self.spec_plaw, 'Test power law model') |
| 239 | 242 | self.append(self.spec_plaw_edisp, 'Test power law model with energy dispersion') |
| ... | ... | @@ -262,7 +265,8 @@ class sciver(gammalib.GPythonTestSuite): |
| 262 | 265 | return |
| 263 | 266 | |
| 264 | 267 | # Generate and analyse pull distributions |
| 265 | - def pull(self, model, trials=100, ra=83.63, dec=22.01, rad=5.0, | |
| 268 | + def pull(self, model, trials=100, duration=1800.0, | |
| 269 | + ra=83.63, dec=22.01, rad=5.0, | |
| 266 | 270 | edisp=False, debug=False): |
| 267 | 271 | """ |
| 268 | 272 | Generate and analyse pull distributions |
| ... | ... | @@ -273,6 +277,8 @@ class sciver(gammalib.GPythonTestSuite): |
| 273 | 277 | Model XML filename (without .xml extension) |
| 274 | 278 | trials : int, optional |
| 275 | 279 | Number of trials |
| 280 | + duration : float, optional | |
| 281 | + Observation duration (sec) | |
| 276 | 282 | ra : float, optional |
| 277 | 283 | Right Ascension of pointing (deg) |
| 278 | 284 | dec : float, optional |
| ... | ... | @@ -286,6 +292,7 @@ class sciver(gammalib.GPythonTestSuite): |
| 286 | 292 | """ |
| 287 | 293 | # Generate pull distribution |
| 288 | 294 | outfile = generate_pull_distribution(model, trials=trials, |
| 295 | + duration=duration, | |
| 289 | 296 | ra=ra, dec=dec, rad=rad, |
| 290 | 297 | edisp=edisp, debug=debug) |
| 291 | 298 | |
| ... | ... | @@ -308,18 +315,36 @@ class sciver(gammalib.GPythonTestSuite): |
| 308 | 315 | # Test mean |
| 309 | 316 | mean = self.results[name]['mean'] |
| 310 | 317 | valid = (mean >= -0.40) and (mean <= +0.40) |
| 311 | - text = 'Mean %.5f of %s should be within [-0.4,0.4] range' % (mean, name) | |
| 318 | + text = 'Mean %.5f of %s should be within [-0.4,0.4] range' % \ | |
| 319 | + (mean, name) | |
| 312 | 320 | self.test_assert(valid, text) |
| 313 | 321 | |
| 314 | 322 | # Test standard deviation |
| 315 | 323 | std = self.results[name]['std'] |
| 316 | 324 | valid = (std >= 0.80) and (std <= 1.20) |
| 317 | - text = 'Standard deviation %.5f of %s should be within [0.8,1.2] range' % (std, name) | |
| 325 | + text = 'Standard deviation %.5f of %s should be within [0.8,1.2]' \ | |
| 326 | + ' range' % (std, name) | |
| 318 | 327 | self.test_assert(valid, text) |
| 319 | 328 | |
| 320 | 329 | # Return |
| 321 | 330 | return |
| 322 | 331 | |
| 332 | + # Test background model | |
| 333 | + def bgd(self): | |
| 334 | + """ | |
| 335 | + Test background model | |
| 336 | + | |
| 337 | + The standard background model is tested for an observation duration | |
| 338 | + of 50 hours to verify the numerical accuracy of the background model | |
| 339 | + at sufficiently good precision. Most analysis relies on the numerical | |
| 340 | + accuracy of the background model, hence it's important to assure that | |
| 341 | + the model is indeed accurate. | |
| 342 | + """ | |
| 343 | + self.pull('data/sciver/bgd', duration=180000.0) | |
| 344 | + self.test('Pull_Background_Prefactor') | |
| 345 | + self.test('Pull_Background_Index') | |
| 346 | + return | |
| 347 | + | |
| 323 | 348 | # Test power law model |
| 324 | 349 | def spec_plaw(self): |
| 325 | 350 | """ | ... | ... |