Commit dbc6961d7639eb4d259cf267abfccafea32dd748

Authored by Jürgen Knödlseder
1 parent e30a4704

Adapt unit test to new PSFs and add GCTAPsfKing class tests.

Showing 1 changed file with 36 additions and 7 deletions
inst/cta/test/test_CTA.py
1 1 # ==========================================================================
2 2 # This module performs unit tests for the GammaLib CTA module.
3 3 #
4   -# Copyright (C) 2012-2013 Juergen Knoedlseder
  4 +# Copyright (C) 2012-2014 Juergen Knoedlseder
5 5 #
6 6 # This program is free software: you can redistribute it and/or modify
7 7 # it under the terms of the GNU General Public License as published by
... ... @@ -64,7 +64,10 @@ class Test(GPythonTestSuite):
64 64 # Load 2D Aeff
65 65 self.test_try("Test GCTAAeff2D file constructor")
66 66 try:
67   - aeff = GCTAAeff2D("../inst/cta/caldb/data/cta/e/bcf/000001/irf_test.fits")
  67 + db = GCaldb("../inst/cta/caldb")
  68 + db.open("cta", "e")
  69 + filename = db.filename("","","EFF_AREA","","","NAME(IFAE20120510_50h)")
  70 + aeff = GCTAAeff2D(filename)
68 71 self.test_try_success()
69 72 except:
70 73 self.test_try_failure("Unable to allocate GCTAAeff2D from file.")
... ... @@ -78,7 +81,8 @@ class Test(GPythonTestSuite):
78 81 # Load performance file
79 82 self.test_try("Test GCTAAeffPerfTable file constructor")
80 83 try:
81   - aeff = GCTAAeffPerfTable("../inst/cta/caldb/kb_E_50h_v3.dat")
  84 + filename = "../inst/cta/caldb/cta_dummy_irf.dat"
  85 + aeff = GCTAAeffPerfTable(filename)
82 86 self.test_try_success()
83 87 except:
84 88 self.test_try_failure("Unable to allocate GCTAAeffPerfTable from file.")
... ... @@ -92,7 +96,8 @@ class Test(GPythonTestSuite):
92 96 # Load 1DC ARF response file
93 97 self.test_try("Test GCTAAeffArf file constructor")
94 98 try:
95   - aeff = GCTAAeffArf("../inst/cta/test/caldb/dc1/arf.fits")
  99 + filename = "../inst/cta/test/caldb/dc1/arf.fits"
  100 + aeff = GCTAAeffArf(filename)
96 101 self.test_try_success()
97 102 except:
98 103 self.test_try_failure("Unable to allocate GCTAAeffArf from file.")
... ... @@ -114,7 +119,10 @@ class Test(GPythonTestSuite):
114 119 # Load 2D PSF
115 120 self.test_try("Test GCTAPsf2D file constructor")
116 121 try:
117   - psf = GCTAPsf2D("../inst/cta/caldb/data/cta/e/bcf/000001/irf_test.fits")
  122 + db = GCaldb("../inst/cta/caldb")
  123 + db.open("cta", "e")
  124 + filename = db.filename("","","RPSF","","","NAME(IFAE20120510_50h)")
  125 + psf = GCTAPsf2D(filename)
118 126 self.test_try_success()
119 127 except:
120 128 self.test_try_failure("Unable to allocate GCTAPsf2D from file.")
... ... @@ -127,10 +135,30 @@ class Test(GPythonTestSuite):
127 135 self.test_value(psf(0.0, 1.0, 0.01745), 190115.769257, 1.0e-6)
128 136 self.test_value(psf(0.001, 1.0, 0.01745), 104623.364268, 1.0e-6)
129 137  
  138 + # Load King profile PSF
  139 + self.test_try("Test GCTAPsfKing file constructor")
  140 + try:
  141 + db = GCaldb("../inst/cta/caldb")
  142 + db.open("cta", "e")
  143 + filename = db.filename("","","RPSF","","","NAME(IFAE20120510_50h_King)")
  144 + psf = GCTAPsfKing(filename)
  145 + self.test_try_success()
  146 + except:
  147 + self.test_try_failure("Unable to allocate GCTAPsfKing from file.")
  148 +
  149 + # Test PSF values
  150 + self.test_value(psf(0.0, 0.0, 0.0), 213666.253408, 1.0e-6)
  151 + self.test_value(psf(0.001, 0.0, 0.0), 90939.5585827, 1.0e-6)
  152 + self.test_value(psf(0.0, 1.0, 0.0), 1127688.29309, 1.0e-5)
  153 + self.test_value(psf(0.001, 1.0, 0.0), 54916.6796886, 1.0e-6)
  154 + self.test_value(psf(0.0, 1.0, 0.01745), 660973.856068, 1.0e-6)
  155 + self.test_value(psf(0.001, 1.0, 0.01745), 80272.5530008, 1.0e-6)
  156 +
130 157 # Load performance file
131 158 self.test_try("Test GCTAPsfPerfTable file constructor")
132 159 try:
133   - psf = GCTAPsfPerfTable("../inst/cta/caldb/kb_E_50h_v3.dat")
  160 + filename = "../inst/cta/caldb/cta_dummy_irf.dat"
  161 + psf = GCTAPsfPerfTable(filename)
134 162 self.test_try_success()
135 163 except:
136 164 self.test_try_failure("Unable to allocate GCTAPsfPerfTable from file.")
... ... @@ -146,7 +174,8 @@ class Test(GPythonTestSuite):
146 174 # Load 1DC PSF file
147 175 self.test_try("Test GCTAPsfVector file constructor")
148 176 try:
149   - psf = GCTAPsfVector("../inst/cta/test/caldb/dc1/psf_magic.fits")
  177 + filename = "../inst/cta/test/caldb/dc1/psf_magic.fits"
  178 + psf = GCTAPsfVector(filename)
150 179 self.test_try_success()
151 180 except:
152 181 self.test_try_failure("Unable to allocate GCTAPsfVector from file.")
... ...