Commit 3064f16abb7e414179a4dc2714297865a65e4b38

Authored by Jürgen Knödlseder
1 parent d6fa46a1

Add background model to science verification

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 * Version 1.1.0 released 3 * Version 1.1.0 released
4 ======================== 4 ========================
5 5
  6 + Add background model science verification (#1815)
6 Add cstsmapsplit script (#1797) 7 Add cstsmapsplit script (#1797)
7 Add unit tests for all example scripts 8 Add unit tests for all example scripts
8 Handle zero parameter errors in ctulimit (#1795) 9 Handle zero parameter errors in ctulimit (#1795)
1 New Features and Important Changes in ctools 1.1.0 1 New Features and Important Changes in ctools 1.1.0
2 2
3 -9 July 2016 3 +18 July 2016
4 4
5 5
6 Introduction 6 Introduction
README.md
1 ctools information 1 ctools information
2 ================== 2 ==================
3 -* Version: 1.1.0.dev1 (1 July 2016) 3 +* Version: 1.1.0.dev1 (18 July 2016)
4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) 4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu)
5 * GammaLib dependency: 1.1.0.dev1 5 * GammaLib dependency: 1.1.0.dev1
6 6
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,6 +234,9 @@ class sciver(gammalib.GPythonTestSuite):
234 # Set test name 234 # Set test name
235 self.name('Science Verification') 235 self.name('Science Verification')
236 236
  237 + # Append background model test
  238 + self.append(self.bgd, 'Test background model')
  239 +
237 # Append spectral tests 240 # Append spectral tests
238 self.append(self.spec_plaw, 'Test power law model') 241 self.append(self.spec_plaw, 'Test power law model')
239 self.append(self.spec_plaw_edisp, 'Test power law model with energy dispersion') 242 self.append(self.spec_plaw_edisp, 'Test power law model with energy dispersion')
@@ -262,7 +265,8 @@ class sciver(gammalib.GPythonTestSuite): @@ -262,7 +265,8 @@ class sciver(gammalib.GPythonTestSuite):
262 return 265 return
263 266
264 # Generate and analyse pull distributions 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 edisp=False, debug=False): 270 edisp=False, debug=False):
267 """ 271 """
268 Generate and analyse pull distributions 272 Generate and analyse pull distributions
@@ -273,6 +277,8 @@ class sciver(gammalib.GPythonTestSuite): @@ -273,6 +277,8 @@ class sciver(gammalib.GPythonTestSuite):
273 Model XML filename (without .xml extension) 277 Model XML filename (without .xml extension)
274 trials : int, optional 278 trials : int, optional
275 Number of trials 279 Number of trials
  280 + duration : float, optional
  281 + Observation duration (sec)
276 ra : float, optional 282 ra : float, optional
277 Right Ascension of pointing (deg) 283 Right Ascension of pointing (deg)
278 dec : float, optional 284 dec : float, optional
@@ -286,6 +292,7 @@ class sciver(gammalib.GPythonTestSuite): @@ -286,6 +292,7 @@ class sciver(gammalib.GPythonTestSuite):
286 """ 292 """
287 # Generate pull distribution 293 # Generate pull distribution
288 outfile = generate_pull_distribution(model, trials=trials, 294 outfile = generate_pull_distribution(model, trials=trials,
  295 + duration=duration,
289 ra=ra, dec=dec, rad=rad, 296 ra=ra, dec=dec, rad=rad,
290 edisp=edisp, debug=debug) 297 edisp=edisp, debug=debug)
291 298
@@ -308,18 +315,36 @@ class sciver(gammalib.GPythonTestSuite): @@ -308,18 +315,36 @@ class sciver(gammalib.GPythonTestSuite):
308 # Test mean 315 # Test mean
309 mean = self.results[name]['mean'] 316 mean = self.results[name]['mean']
310 valid = (mean >= -0.40) and (mean <= +0.40) 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 self.test_assert(valid, text) 320 self.test_assert(valid, text)
313 321
314 # Test standard deviation 322 # Test standard deviation
315 std = self.results[name]['std'] 323 std = self.results[name]['std']
316 valid = (std >= 0.80) and (std <= 1.20) 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 self.test_assert(valid, text) 327 self.test_assert(valid, text)
319 328
320 # Return 329 # Return
321 return 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 # Test power law model 348 # Test power law model
324 def spec_plaw(self): 349 def spec_plaw(self):
325 """ 350 """