Commit 2e9636446cddf85352586a8f1fe042461cb17320

Authored by Jürgen Knödlseder
1 parent 6543a156

Update ctools unit tests.

.gitignore
... ... @@ -79,6 +79,7 @@ test/*.dat
79 79 test/*.xml
80 80 test/*.reg
81 81 test/*.trs
  82 +test/*.txt
82 83 test/test_cscripts.sh
83 84 test/reports/*.xml
84 85 test/butterfly.txt
... ...
ChangeLog
... ... @@ -3,7 +3,7 @@
3 3 * Version 1.1.0 released
4 4 ========================
5 5  
6   - Add cscript unit tests.
  6 + Add ctools and cscripts unit tests.
7 7 Add "bgdoversample" and "bgdinfill" parameters to csroot2caldb
8 8 Add csobsdef.pntdef() method (#1771)
9 9 Add ctmapcube tool (#1760)
... ...
test/test_cscaldb.py
... ... @@ -51,11 +51,11 @@ class Test(gammalib.GPythonTestSuite):
51 51 Set all test functions.
52 52 """
53 53 # Set test name
54   - self.name("cscaldb")
  54 + self.name('cscaldb')
55 55  
56 56 # Append tests
57   - self.append(self._test_cmd, "Test cscaldb on command line")
58   - self.append(self._test_python, "Test cscaldb from Python")
  57 + self.append(self._test_cmd, 'Test cscaldb on command line')
  58 + self.append(self._test_python, 'Test cscaldb from Python')
59 59  
60 60 # Return
61 61 return
... ... @@ -66,23 +66,23 @@ class Test(gammalib.GPythonTestSuite):
66 66 Test cscaldb on the command line.
67 67 """
68 68 # Kluge to set the command (installed version has no README file)
69   - if os.path.isfile("README"):
70   - cscaldb = "../cscripts/cscaldb.py"
  69 + if os.path.isfile('README'):
  70 + cscaldb = '../cscripts/cscaldb.py'
71 71 else:
72   - cscaldb = "cscaldb"
  72 + cscaldb = 'cscaldb'
73 73  
74 74 # Setup cscaldb command
75 75 cmd = cscaldb+' logfile="cscaldb_cmd1.log" chatter=1'
76 76  
77 77 # Execute cscaldb, make sure we catch any exception
78 78 try:
79   - rc = os.system(cmd+" >/dev/null 2>&1")
  79 + rc = os.system(cmd+' >/dev/null 2>&1')
80 80 except:
81 81 pass
82 82  
83 83 # Check if execution was successful
84 84 self.test_assert(rc == 0,
85   - "Successful cscaldb execution on command line")
  85 + 'Successful cscaldb execution on command line')
86 86  
87 87 # Return
88 88 return
... ... @@ -94,8 +94,8 @@ class Test(gammalib.GPythonTestSuite):
94 94 """
95 95 # Set-up cscaldb
96 96 caldb = cscripts.cscaldb()
97   - caldb["logfile"] = "cscaldb_py1.log"
98   - caldb["chatter"] = 2
  97 + caldb['logfile'] = 'cscaldb_py1.log'
  98 + caldb['chatter'] = 2
99 99  
100 100 # Run script
101 101 caldb.logFileOpen() # Make sure we get a log file
... ...
test/test_csfindobs.py
... ... @@ -51,11 +51,11 @@ class Test(gammalib.GPythonTestSuite):
51 51 Set all test functions.
52 52 """
53 53 # Set test name
54   - self.name("csfindobs")
  54 + self.name('csfindobs')
55 55  
56 56 # Append tests
57   - self.append(self._test_cmd, "Test csfindobs on command line")
58   - self.append(self._test_python, "Test csfindobs from Python")
  57 + self.append(self._test_cmd, 'Test csfindobs on command line')
  58 + self.append(self._test_python, 'Test csfindobs from Python')
59 59  
60 60 # Return
61 61 return
... ... @@ -66,10 +66,10 @@ class Test(gammalib.GPythonTestSuite):
66 66 Test csfindobs on the command line.
67 67 """
68 68 # Kluge to set the command (installed version has no README file)
69   - if os.path.isfile("README"):
70   - csfindobs = "../cscripts/csfindobs.py"
  69 + if os.path.isfile('README'):
  70 + csfindobs = '../cscripts/csfindobs.py'
71 71 else:
72   - csfindobs = "csfindobs"
  72 + csfindobs = 'csfindobs'
73 73  
74 74 # Setup csfindobs command
75 75 cmd = csfindobs+' datapath="iactdata/"'+ \
... ... @@ -80,16 +80,16 @@ class Test(gammalib.GPythonTestSuite):
80 80  
81 81 # Execute csfindobs, make sure we catch any exception
82 82 try:
83   - rc = os.system(cmd+" >/dev/null 2>&1")
  83 + rc = os.system(cmd+' >/dev/null 2>&1')
84 84 except:
85 85 pass
86 86  
87 87 # Check if execution was successful
88 88 self.test_assert(rc == 0,
89   - "Successful csfindobs execution on command line")
  89 + 'Successful csfindobs execution on command line')
90 90  
91 91 # Check run list
92   - self._check_runlist("runlist_cmd1.dat")
  92 + self._check_runlist('runlist_cmd1.dat')
93 93  
94 94 # Setup csfindobs command
95 95 cmd = csfindobs+' datapath="path_that_does_not_exist"'+ \
... ... @@ -100,13 +100,13 @@ class Test(gammalib.GPythonTestSuite):
100 100  
101 101 # Execute csfindobs, make sure we catch any exception
102 102 try:
103   - rc = os.system(cmd+" >/dev/null 2>&1")
  103 + rc = os.system(cmd+' >/dev/null 2>&1')
104 104 except:
105 105 pass
106 106  
107 107 # Check if execution failed
108 108 self.test_assert(rc != 0,
109   - "Failure of csfindobs execution on command line")
  109 + 'Failure of csfindobs execution on command line')
110 110  
111 111 # Return
112 112 return
... ... @@ -118,14 +118,14 @@ class Test(gammalib.GPythonTestSuite):
118 118 """
119 119 # Set-up csfindobs
120 120 findobs = cscripts.csfindobs()
121   - findobs["datapath"] = "iactdata/"
122   - findobs["prodname"] = "unit-test"
123   - findobs["outfile"] = "runlist_py1.dat"
124   - findobs["ra"] = 83.63
125   - findobs["dec"] = 22.01
126   - findobs["rad"] = 1.0
127   - findobs["logfile"] = "csfindobs_py1.log"
128   - findobs["chatter"] = 2
  121 + findobs['datapath'] = 'iactdata/'
  122 + findobs['prodname'] = 'unit-test'
  123 + findobs['outfile'] = 'runlist_py1.dat'
  124 + findobs['ra'] = 83.63
  125 + findobs['dec'] = 22.01
  126 + findobs['rad'] = 1.0
  127 + findobs['logfile'] = 'csfindobs_py1.log'
  128 + findobs['chatter'] = 2
129 129  
130 130 # Run csfindobs script and save run list
131 131 findobs.logFileOpen() # Make sure we get a log file
... ... @@ -133,7 +133,7 @@ class Test(gammalib.GPythonTestSuite):
133 133 findobs.save()
134 134  
135 135 # Check run list
136   - self._check_runlist("runlist_py1.dat")
  136 + self._check_runlist('runlist_py1.dat')
137 137  
138 138 # Return
139 139 return
... ...
test/test_ctbkgcube.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,12 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.bkg_model = "data/crab.xml"
43   - self.caldb = "irf"
44   - self.irf = "cta_dummy_irf"
45   -
46 41 # Return
47 42 return
48 43  
... ... @@ -52,61 +47,125 @@ class Test(gammalib.GPythonTestSuite):
52 47 Set all test functions.
53 48 """
54 49 # Set test name
55   - self.name("ctbkgcube")
  50 + self.name('ctbkgcube')
56 51  
57 52 # Append tests
58   - self.append(self.test_functional, "Test ctbkgcube functionality")
  53 + self.append(self._test_cmd, 'Test ctbkgcube on command line')
  54 + self.append(self._test_python, 'Test ctbkgcube from Python')
59 55  
60 56 # Return
61 57 return
62 58  
63   - # Test ctbkgcube functionnality
64   - def test_functional(self):
  59 + # Test ctbkgcube on command line
  60 + def _test_cmd(self):
65 61 """
66   - Test ctbkgcube functionnality.
  62 + Test ctbkgcube on the command line.
67 63 """
68   - # Set-up ctbkgcube
69   - bkgcube = ctools.ctbkgcube()
70   - bkgcube["inobs"] = self.events_name
71   - bkgcube["inmodel"] = self.bkg_model
72   - bkgcube["incube"] = "NONE"
73   - bkgcube["outcube"] = "bkgcube.fits"
74   - bkgcube["outmodel"] = "bkgcube.xml"
75   - bkgcube["caldb"] = self.caldb
76   - bkgcube["irf"] = self.irf
77   - bkgcube["ebinalg"] = "LOG"
78   - bkgcube["emin"] = 0.1
79   - bkgcube["emax"] = 100
80   - bkgcube["enumbins"] = 20
81   - bkgcube["nxpix"] = 10
82   - bkgcube["nypix"] = 10
83   - bkgcube["binsz"] = 0.4
84   - bkgcube["coordsys"] = "CEL"
85   - bkgcube["proj"] = "CAR"
86   - bkgcube["xref"] = 83.63
87   - bkgcube["yref"] = 22.01
88   -
89   - # Run tool
90   - self.test_try("Run ctbkgcube")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctbkgcube = '../src/ctbkgcube/ctbkgcube'
  67 + else:
  68 + ctbkgcube = 'ctbkgcube'
  69 +
  70 + # Setup ctbkgcube command
  71 + cmd = ctbkgcube+' inobs="data/crab_events.fits"'+ \
  72 + ' inmodel="data/crab.xml"'+ \
  73 + ' incube="NONE"'+ \
  74 + ' outcube="ctbkgcube_cmd1.fits"'+ \
  75 + ' outmodel="ctbkgcube_cmd1.xml"'+ \
  76 + ' caldb="prod2" irf="South_0.5h"'+ \
  77 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  78 + ' nxpix=10 nypix=10 binsz=0.4'+ \
  79 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  80 + ' logfile="ctbkgcube_cmd1.log" chatter=1'
  81 +
  82 + # Execute ctbkgcube, make sure we catch any exception
91 83 try:
92   - bkgcube.run()
93   - self.test_try_success()
94   - #except Exception as e:
95   - # msg = "Exception occured in ctbkgcube: %s." % (e,)
  84 + rc = os.system(cmd+' >/dev/null 2>&1')
96 85 except:
97   - msg = "Exception occured in ctbkgcube."
98   - self.test_try_failure(msg)
  86 + pass
  87 +
  88 + # Check if execution was successful
  89 + self.test_assert(rc == 0,
  90 + 'Successful ctbkgcube execution on command line')
  91 +
  92 + # Check result file
  93 + self._check_result_file('ctbkgcube_cmd1.fits')
99 94  
100   - # Save background cube
101   - self.test_try("Save background cube")
  95 + # Setup ctbkgcube command
  96 + cmd = ctbkgcube+' inobs="event_file_that_does_not_exist.fits"'+ \
  97 + ' inmodel="data/crab.xml"'+ \
  98 + ' incube="NONE"'+ \
  99 + ' outcube="ctbkgcube_cmd2.fits"'+ \
  100 + ' outmodel="ctbkgcube_cmd2.xml"'+ \
  101 + ' caldb="prod2" irf="South_0.5h"'+ \
  102 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  103 + ' nxpix=10 nypix=10 binsz=0.4'+ \
  104 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  105 + ' logfile="ctbkgcube_cmd2.log" chatter=1'
  106 +
  107 + # Execute ctbkgcube, make sure we catch any exception
102 108 try:
103   - bkgcube.save()
104   - self.test_try_success()
105   - #except Exception as e:
106   - # msg = "Exception occured in saving background cube: %s." % (e,)
  109 + rc = os.system(cmd+' >/dev/null 2>&1')
107 110 except:
108   - msg = "Exception occured in saving background cube."
109   - self.test_try_failure(msg)
  111 + pass
  112 +
  113 + # Check if execution failed
  114 + self.test_assert(rc != 0,
  115 + 'Failure of ctbkgcube execution on command line')
  116 +
  117 + # Return
  118 + return
  119 +
  120 + # Test ctbkgcube from Python
  121 + def _test_python(self):
  122 + """
  123 + Test ctbkgcube from Python.
  124 + """
  125 + # Set-up ctbkgcube
  126 + bkgcube = ctools.ctbkgcube()
  127 + bkgcube['inobs'] = 'data/crab_events.fits'
  128 + bkgcube['inmodel'] = 'data/crab.xml'
  129 + bkgcube['incube'] = 'NONE'
  130 + bkgcube['outcube'] = 'ctbkgcube_py1.fits'
  131 + bkgcube['outmodel'] = 'ctbkgcube_py1.xml'
  132 + bkgcube['caldb'] = 'prod2'
  133 + bkgcube['irf'] = 'South_0.5h'
  134 + bkgcube['ebinalg'] = 'LOG'
  135 + bkgcube['emin'] = 0.1
  136 + bkgcube['emax'] = 100
  137 + bkgcube['enumbins'] = 20
  138 + bkgcube['nxpix'] = 10
  139 + bkgcube['nypix'] = 10
  140 + bkgcube['binsz'] = 0.4
  141 + bkgcube['coordsys'] = 'CEL'
  142 + bkgcube['proj'] = 'CAR'
  143 + bkgcube['xref'] = 83.63
  144 + bkgcube['yref'] = 22.01
  145 + bkgcube['logfile'] = 'ctbkgcube_py1.log'
  146 + bkgcube['chatter'] = 2
  147 +
  148 + # Run ctbkgcube tool
  149 + bkgcube.logFileOpen() # Make sure we get a log file
  150 + bkgcube.run()
  151 + bkgcube.save()
  152 +
  153 + # Check result file
  154 + self._check_result_file('ctbkgcube_py1.fits')
  155 +
  156 + # Return
  157 + return
  158 +
  159 + # Check result file
  160 + def _check_result_file(self, filename):
  161 + """
  162 + Check result file.
  163 + """
  164 + # Open result file
  165 + result = gammalib.GCTACubeBackground(filename)
  166 +
  167 + # Check dimensions
  168 + self.test_value(len(result.elogmeans()), 20, 'Check for 20 energy bins')
110 169  
111 170 # Return
112 171 return
... ...
test/test_ctbutterfly.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,12 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.model_name = "data/crab.xml"
43   - self.caldb = "irf"
44   - self.irf = "cta_dummy_irf"
45   -
46 41 # Return
47 42 return
48 43  
... ... @@ -52,51 +47,108 @@ class Test(gammalib.GPythonTestSuite):
52 47 Set all test functions.
53 48 """
54 49 # Set test name
55   - self.name("ctbutterfly")
  50 + self.name('ctbutterfly')
56 51  
57 52 # Append tests
58   - self.append(self.test_functional, "Test ctbutterfly functionality")
  53 + self.append(self._test_cmd, 'Test ctbutterfly on command line')
  54 + self.append(self._test_python, 'Test ctbutterfly from Python')
59 55  
60 56 # Return
61 57 return
62 58  
63   - # Test ctbutterfly functionnality
64   - def test_functional(self):
  59 + # Test ctbutterfly on command line
  60 + def _test_cmd(self):
65 61 """
66   - Test ctbutterfly functionnality.
  62 + Test ctbutterfly on the command line.
67 63 """
68   - # Set-up ctbutterfly
69   - butterfly = ctools.ctbutterfly()
70   - butterfly["inobs"] = self.events_name
71   - butterfly["inmodel"] = self.model_name
72   - butterfly["srcname"] = "Crab"
73   - butterfly["caldb"] = self.caldb
74   - butterfly["irf"] = self.irf
75   - butterfly["emin"] = 0.1
76   - butterfly["emax"] = 100
77   - butterfly["outfile"] = "butterfly.txt"
78   -
79   - # Run tool
80   - self.test_try("Run ctbutterfly")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctbutterfly = '../src/ctbutterfly/ctbutterfly'
  67 + else:
  68 + ctbutterfly = 'ctbutterfly'
  69 +
  70 + # Setup ctbutterfly command
  71 + cmd = ctbutterfly+' inobs="data/crab_events.fits"'+\
  72 + ' outfile="ctbutterfly_cmd1.txt"'+ \
  73 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  74 + ' caldb="prod2" irf="South_0.5h"'+ \
  75 + ' emin=0.1 emax=100.0'+ \
  76 + ' logfile="ctbutterfly_cmd1.log" chatter=1'
  77 +
  78 + # Execute ctbutterfly, make sure we catch any exception
81 79 try:
82   - butterfly.run()
83   - self.test_try_success()
84   - #except Exception as e:
85   - # msg = "Exception occured in ctbutterfly: %s." % (e,)
  80 + rc = os.system(cmd+' >/dev/null 2>&1')
86 81 except:
87   - msg = "Exception occured in ctbutterfly."
88   - self.test_try_failure(msg)
  82 + pass
  83 +
  84 + # Check if execution was successful
  85 + self.test_assert(rc == 0,
  86 + 'Successful ctbutterfly execution on command line')
  87 +
  88 + # Check result file
  89 + self._check_result_file('ctbutterfly_cmd1.txt')
89 90  
90   - # Save results
91   - self.test_try("Save results")
  91 + # Setup ctbutterfly command
  92 + cmd = ctbutterfly+' inobs="event_file_that_does_not_exist.fits"'+\
  93 + ' outfile="ctbutterfly_cmd2.txt"'+ \
  94 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  95 + ' caldb="prod2" irf="South_0.5h"'+ \
  96 + ' emin=0.1 emax=100.0'+ \
  97 + ' logfile="ctbutterfly_cmd2.log" chatter=1'
  98 +
  99 + # Execute ctbutterfly, make sure we catch any exception
92 100 try:
93   - butterfly.save()
94   - self.test_try_success()
95   - #except Exception as e:
96   - # msg = "Exception occured in saving butterfly diagram: %s." % (e,)
  101 + rc = os.system(cmd+' >/dev/null 2>&1')
97 102 except:
98   - msg = "Exception occured in saving butterfly diagram."
99   - self.test_try_failure(msg)
  103 + pass
  104 +
  105 + # Check if execution failed
  106 + self.test_assert(rc != 0,
  107 + 'Failure of ctbutterfly execution on command line')
  108 +
  109 + # Return
  110 + return
  111 +
  112 + # Test ctbutterfly from Python
  113 + def _test_python(self):
  114 + """
  115 + Test ctbutterfly from Python.
  116 + """
  117 + # Set-up ctbutterfly
  118 + butterfly = ctools.ctbutterfly()
  119 + butterfly['inobs'] = 'data/crab_events.fits'
  120 + butterfly['inmodel'] = 'data/crab.xml'
  121 + butterfly['srcname'] = 'Crab'
  122 + butterfly['caldb'] = 'prod2'
  123 + butterfly['irf'] = 'South_0.5h'
  124 + butterfly['emin'] = 0.1
  125 + butterfly['emax'] = 100.0
  126 + butterfly['outfile'] = 'ctbutterfly_py1.txt'
  127 + butterfly['logfile'] = 'ctbutterfly_py1.log'
  128 + butterfly['chatter'] = 2
  129 +
  130 + # Run ctbutterfly tool
  131 + butterfly.logFileOpen() # Make sure we get a log file
  132 + butterfly.run()
  133 + butterfly.save()
  134 +
  135 + # Check result file
  136 + self._check_result_file('ctbutterfly_py1.txt')
  137 +
  138 + # Return
  139 + return
  140 +
  141 + # Check result file
  142 + def _check_result_file(self, filename):
  143 + """
  144 + Check result file.
  145 + """
  146 + # Open result file as CSV file
  147 + results = gammalib.GCsv(filename)
  148 +
  149 + # Check dimensions
  150 + self.test_value(results.nrows(), 100, 'Check for 100 rows in butterfly file')
  151 + self.test_value(results.ncols(), 4, 'Check for 4 columns in butterfly file')
100 152  
101 153 # Return
102 154 return
... ...
test/test_ctcubemask.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,10 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.cntmap_name = "data/crab_cntmap.fits"
42   - self.regfile = "data/exclusion.reg"
43   -
44 41 # Return
45 42 return
46 43  
... ... @@ -50,51 +47,108 @@ class Test(gammalib.GPythonTestSuite):
50 47 Set all test functions.
51 48 """
52 49 # Set test name
53   - self.name("ctcubemask")
  50 + self.name('ctcubemask')
54 51  
55 52 # Append tests
56   - self.append(self.test_functional, "Test ctcubemask functionality")
  53 + self.append(self._test_cmd, 'Test ctcubemask on command line')
  54 + self.append(self._test_python, 'Test ctcubemask from Python')
57 55  
58 56 # Return
59 57 return
60 58  
61   - # Test ctcubemask functionnality
62   - def test_functional(self):
  59 + # Test ctcubemask on command line
  60 + def _test_cmd(self):
63 61 """
64   - Test ctcubemask functionnality.
  62 + Test ctcubemask on the command line.
65 63 """
66   - # Set-up ctcubemask
67   - mask = ctools.ctcubemask()
68   - mask["inobs"] = self.cntmap_name
69   - mask["regfile"] = self.regfile
70   - mask["outcube"] = "filtered_cntmap.fits"
71   - mask["ra"] = 83.63
72   - mask["dec"] = 22.01
73   - mask["rad"] = 2.0
74   - mask["emin"] = 0.1
75   - mask["emax"] = 100
76   -
77   - # Run tool
78   - self.test_try("Run ctcubemask")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctcubemask = '../src/ctcubemask/ctcubemask'
  67 + else:
  68 + ctcubemask = 'ctcubemask'
  69 +
  70 + # Setup ctcubemask command
  71 + cmd = ctcubemask+' inobs="data/crab_cntmap.fits"'+ \
  72 + ' regfile="data/exclusion.reg"'+ \
  73 + ' outcube="ctcubemask_cmd1.fits"'+ \
  74 + ' ra=83.63 dec=22.01 rad=2.0'+ \
  75 + ' emin=0.1 emax=100.0'+ \
  76 + ' logfile="ctcubemask_cmd1.log" chatter=1'
  77 +
  78 + # Execute ctcubemask, make sure we catch any exception
79 79 try:
80   - mask.run()
81   - self.test_try_success()
82   - #except Exception as e:
83   - # msg = "Exception occured in ctcubemask: %s." % (e,)
  80 + rc = os.system(cmd+' >/dev/null 2>&1')
84 81 except:
85   - msg = "Exception occured in ctcubemask."
86   - self.test_try_failure(msg)
  82 + pass
  83 +
  84 + # Check if execution was successful
  85 + self.test_assert(rc == 0,
  86 + 'Successful ctcubemask execution on command line')
  87 +
  88 + # Check result file
  89 + self._check_result_file('ctcubemask_cmd1.fits')
87 90  
88   - # Save counts cube
89   - self.test_try("Save counts cube")
  91 + # Setup ctcubemask command
  92 + cmd = ctcubemask+' inobs="counts_cube_that_does_not_exist.fits"'+ \
  93 + ' regfile="data/exclusion.reg"'+ \
  94 + ' outcube="ctcubemask_cmd2.fits"'+ \
  95 + ' ra=83.63 dec=22.01 rad=2.0'+ \
  96 + ' emin=0.1 emax=100.0'+ \
  97 + ' logfile="ctcubemask_cmd2.log" chatter=2'
  98 +
  99 + # Execute ctcubemask, make sure we catch any exception
90 100 try:
91   - mask.save()
92   - self.test_try_success()
93   - #except Exception as e:
94   - # msg = "Exception occured in saving counts cube: %s." % (e,)
  101 + rc = os.system(cmd+' >/dev/null 2>&1')
95 102 except:
96   - msg = "Exception occured in saving counts cube."
97   - self.test_try_failure(msg)
  103 + pass
  104 +
  105 + # Check if execution failed
  106 + self.test_assert(rc != 0,
  107 + 'Failure of ctcubemask execution on command line')
  108 +
  109 + # Return
  110 + return
  111 +
  112 + # Test ctcubemask from Python
  113 + def _test_python(self):
  114 + """
  115 + Test ctcubemask from Python.
  116 + """
  117 + # Set-up ctcubemask
  118 + mask = ctools.ctcubemask()
  119 + mask['inobs'] = 'data/crab_cntmap.fits'
  120 + mask['regfile'] = 'data/exclusion.reg'
  121 + mask['outcube'] = 'ctcubemask_py1.fits'
  122 + mask['ra'] = 83.63
  123 + mask['dec'] = 22.01
  124 + mask['rad'] = 2.0
  125 + mask['emin'] = 0.1
  126 + mask['emax'] = 100.0
  127 + mask['logfile'] = 'ctcubemask_py1.log'
  128 + mask['chatter'] = 2
  129 +
  130 + # Run ctcubemask tool
  131 + mask.logFileOpen() # Make sure we get a log file
  132 + mask.run()
  133 + mask.save()
  134 +
  135 + # Check result file
  136 + self._check_result_file('ctcubemask_py1.fits')
  137 +
  138 + # Return
  139 + return
  140 +
  141 + # Check result file
  142 + def _check_result_file(self, filename):
  143 + """
  144 + Check result file.
  145 + """
  146 + # Load counts cube
  147 + cube = gammalib.GCTAEventCube(filename)
  148 +
  149 + # Check counts cube
  150 + self.test_value(cube.size(), 800000, 'Check for 800000 cube bins')
  151 + self.test_value(cube.number(), 4921, 'Check for 4921 events')
98 152  
99 153 # Return
100 154 return
... ...
test/test_ctedispcube.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,11 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.caldb = "irf"
43   - self.irf = "cta_dummy_irf"
44   -
45 41 # Return
46 42 return
47 43  
... ... @@ -51,61 +47,124 @@ class Test(gammalib.GPythonTestSuite):
51 47 Set all test functions.
52 48 """
53 49 # Set test name
54   - self.name("ctedispcube")
  50 + self.name('ctedispcube')
55 51  
56 52 # Append tests
57   - self.append(self.test_functional, "Test ctedispcube functionality")
  53 + self.append(self._test_cmd, 'Test ctedispcube on command line')
  54 + self.append(self._test_python, 'Test ctedispcube from Python')
58 55  
59 56 # Return
60 57 return
61 58  
62   - # Test ctedispcube functionnality
63   - def test_functional(self):
  59 + # Test ctedispcube on command line
  60 + def _test_cmd(self):
64 61 """
65   - Test ctedispcube functionnality.
  62 + Test ctedispcube on the command line.
66 63 """
67   - # Set-up ctedispcube
68   - edispcube = ctools.ctedispcube()
69   - edispcube["inobs"] = self.events_name
70   - edispcube["incube"] = "NONE"
71   - edispcube["outcube"] = "edispcube.fits"
72   - edispcube["caldb"] = self.caldb
73   - edispcube["irf"] = self.irf
74   - edispcube["ebinalg"] = "LOG"
75   - edispcube["emin"] = 0.1
76   - edispcube["emax"] = 100
77   - edispcube["enumbins"] = 20
78   - edispcube["nxpix"] = 10
79   - edispcube["nypix"] = 10
80   - edispcube["binsz"] = 0.4
81   - edispcube["coordsys"] = "CEL"
82   - edispcube["proj"] = "CAR"
83   - edispcube["xref"] = 83.63
84   - edispcube["yref"] = 22.01
85   - edispcube["migramax"] = 2.0
86   - edispcube["migrabins"] = 10
87   -
88   - # Run tool
89   - self.test_try("Run ctedispcube")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctedispcube = '../src/ctedispcube/ctedispcube'
  67 + else:
  68 + ctedispcube = 'ctedispcube'
  69 +
  70 + # Setup ctedispcube command
  71 + cmd = ctedispcube+' inobs="data/crab_events.fits"'+ \
  72 + ' incube="NONE"'+ \
  73 + ' outcube="ctedispcube_cmd1.fits"'+ \
  74 + ' caldb="prod2" irf="South_0.5h"'+ \
  75 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  76 + ' nxpix=10 nypix=10 binsz=0.4'+ \
  77 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  78 + ' migramax=2.0 migrabins=10'+ \
  79 + ' logfile="ctedispcube_cmd1.log" chatter=1'
  80 +
  81 + # Execute ctedispcube, make sure we catch any exception
90 82 try:
91   - edispcube.run()
92   - self.test_try_success()
93   - #except Exception as e:
94   - # msg = "Exception occured in ctedispcube: %s." % (e,)
  83 + rc = os.system(cmd+' >/dev/null 2>&1')
95 84 except:
96   - msg = "Exception occured in ctedispcube."
97   - self.test_try_failure(msg)
  85 + pass
  86 +
  87 + # Check if execution was successful
  88 + self.test_assert(rc == 0,
  89 + 'Successful ctedispcube execution on command line')
  90 +
  91 + # Check result file
  92 + self._check_result_file('ctedispcube_cmd1.fits')
98 93  
99   - # Save EDISP cube
100   - self.test_try("Save EDISP cube")
  94 + # Setup ctedispcube command
  95 + cmd = ctedispcube+' inobs="events_that_do_not_exist.fits"'+ \
  96 + ' incube="NONE"'+ \
  97 + ' outcube="ctedispcube_cmd2.fits"'+ \
  98 + ' caldb="prod2" irf="South_0.5h"'+ \
  99 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  100 + ' nxpix=10 nypix=10 binsz=0.4'+ \
  101 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  102 + ' migramax=2.0 migrabins=10'+ \
  103 + ' logfile="ctedispcube_cmd2.log" chatter=2'
  104 +
  105 + # Execute ctedispcube, make sure we catch any exception
101 106 try:
102   - edispcube.save()
103   - self.test_try_success()
104   - #except Exception as e:
105   - # msg = "Exception occured in saving EDISP cube: %s." % (e,)
  107 + rc = os.system(cmd+' >/dev/null 2>&1')
106 108 except:
107   - msg = "Exception occured in saving EDISP cubes."
108   - self.test_try_failure(msg)
  109 + pass
  110 +
  111 + # Check if execution failed
  112 + self.test_assert(rc != 0,
  113 + 'Failure of ctedispcube execution on command line')
  114 +
  115 + # Return
  116 + return
  117 +
  118 + # Test ctedispcube from Python
  119 + def _test_python(self):
  120 + """
  121 + Test ctedispcube from Python.
  122 + """
  123 + # Set-up ctedispcube
  124 + edispcube = ctools.ctedispcube()
  125 + edispcube['inobs'] = 'data/crab_events.fits'
  126 + edispcube['incube'] = 'NONE'
  127 + edispcube['outcube'] = 'ctedispcube_py1.fits'
  128 + edispcube['caldb'] = 'prod2'
  129 + edispcube['irf'] = 'South_0.5h'
  130 + edispcube['ebinalg'] = 'LOG'
  131 + edispcube['emin'] = 0.1
  132 + edispcube['emax'] = 100
  133 + edispcube['enumbins'] = 20
  134 + edispcube['nxpix'] = 10
  135 + edispcube['nypix'] = 10
  136 + edispcube['binsz'] = 0.4
  137 + edispcube['coordsys'] = 'CEL'
  138 + edispcube['proj'] = 'CAR'
  139 + edispcube['xref'] = 83.63
  140 + edispcube['yref'] = 22.01
  141 + edispcube['migramax'] = 2.0
  142 + edispcube['migrabins'] = 10
  143 + edispcube['logfile'] = 'ctedispcube_py1.log'
  144 + edispcube['chatter'] = 2
  145 +
  146 + # Run ctedispcube tool
  147 + edispcube.logFileOpen() # Make sure we get a log file
  148 + edispcube.run()
  149 + edispcube.save()
  150 +
  151 + # Check result file
  152 + self._check_result_file('ctedispcube_py1.fits')
  153 +
  154 + # Return
  155 + return
  156 +
  157 + # Check result file
  158 + def _check_result_file(self, filename):
  159 + """
  160 + Check result file.
  161 + """
  162 + # Open result file
  163 + result = gammalib.GCTACubeEdisp(filename)
  164 +
  165 + # Check dimensions
  166 + self.test_value(len(result.energies()), 21, 'Check for 21 energy maps')
  167 + self.test_value(len(result.migras()), 10, 'Check for 10 migration bins')
109 168  
110 169 # Return
111 170 return
... ...
test/test_cterror.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -53,49 +54,122 @@ class Test(gammalib.GPythonTestSuite):
53 54 Set all test functions.
54 55 """
55 56 # Set test name
56   - self.name("cterror")
  57 + self.name('cterror')
57 58  
58 59 # Append tests
59   - self.append(self.test_functional, "Test cterror functionality")
  60 + self.append(self._test_cmd, 'Test cterror on command line')
  61 + self.append(self._test_python, 'Test cterror from Python')
60 62  
61 63 # Return
62 64 return
63 65  
64   - # Test cttsmap functionnality
65   - def test_functional(self):
  66 + # Test cterror on command line
  67 + def _test_cmd(self):
66 68 """
67   - Test cterror functionnality.
  69 + Test cterror on the command line.
68 70 """
69   - # Set-up cterror
70   - error = ctools.cterror()
71   - error["inobs"] = self.events_name
72   - error["inmodel"] = self.model_name
73   - error["outmodel"] = self.result_name
74   - error["srcname"] = "Crab"
75   - error["caldb"] = self.caldb
76   - error["irf"] = self.irf
77   -
78   - # Run tool
79   - self.test_try("Run cterror")
  71 + # Kluge to set the command (installed version has no README file)
  72 + if os.path.isfile('README'):
  73 + cterror = '../src/cterror/cterror'
  74 + else:
  75 + cterror = 'cterror'
  76 +
  77 + # Setup cterror command
  78 + cmd = cterror+' inobs="data/crab_events.fits"'+ \
  79 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  80 + ' caldb="prod2" irf="South_0.5h"'+ \
  81 + ' outmodel="cterror_cmd1.xml"'+ \
  82 + ' logfile="cterror_cmd1.log" chatter=1'
  83 +
  84 + # Execute cterror, make sure we catch any exception
80 85 try:
81   - error.run()
82   - self.test_try_success()
83   - #except Exception as e:
84   - # msg = "Exception occured in cterror: %s." % (e,)
  86 + rc = os.system(cmd+' >/dev/null 2>&1')
85 87 except:
86   - msg = "Exception occured in cterror."
87   - self.test_try_failure(msg)
  88 + pass
  89 +
  90 + # Check if execution was successful
  91 + self.test_assert(rc == 0,
  92 + 'Successful cterror execution on command line')
  93 +
  94 + # Check result file
  95 + self._check_result_file('cterror_cmd1.xml')
  96 +
  97 + # Setup cterror command
  98 + cmd = cterror+' inobs="event_file_that_does_not_exist.fits"'+ \
  99 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  100 + ' caldb="prod2" irf="South_0.5h"'+ \
  101 + ' outmodel="cterror_cmd2.xml"'+ \
  102 + ' logfile="cterror_cmd2.log" chatter=1'
88 103  
89   - # Save results
90   - self.test_try("Save results")
  104 + # Execute cterror, make sure we catch any exception
91 105 try:
92   - error.save()
93   - self.test_try_success()
94   - #except Exception as e:
95   - # msg = "Exception occured in saving results: %s." % (e,)
  106 + rc = os.system(cmd+' >/dev/null 2>&1')
96 107 except:
97   - msg = "Exception occured in saving results."
98   - self.test_try_failure(msg)
  108 + pass
  109 +
  110 + # Check if execution failed
  111 + self.test_assert(rc != 0,
  112 + 'Failure of cterror execution on command line')
  113 +
  114 + # Return
  115 + return
  116 +
  117 + # Test cterror from Python
  118 + def _test_python(self):
  119 + """
  120 + Test cterror from Python.
  121 + """
  122 + # Set-up cterror
  123 + error = ctools.cterror()
  124 + error['inobs'] = 'data/crab_events.fits'
  125 + error['inmodel'] = 'data/crab.xml'
  126 + error['outmodel'] = 'cterror_py1.xml'
  127 + error['srcname'] = 'Crab'
  128 + error['caldb'] = 'prod2'
  129 + error['irf'] = 'South_0.5h'
  130 + error['logfile'] = 'cterror_py1.log'
  131 + error['chatter'] = 2
  132 +
  133 + # Run cterror tool
  134 + error.logFileOpen() # Make sure we get a log file
  135 + error.run()
  136 + error.save()
  137 +
  138 + # Check result file
  139 + self._check_result_file('cterror_py1.xml')
  140 +
  141 + # Return
  142 + return
  143 +
  144 + # Check result file
  145 + def _check_result_file(self, filename):
  146 + """
  147 + Check result file.
  148 + """
  149 + # Open result file
  150 + result = gammalib.GModels(filename)
  151 +
  152 + # Check results
  153 + self.test_value(result['Crab']['Prefactor'].value(), 1.58907e-16,
  154 + 1.0e-3, 'Check fitted Crab Prefactor')
  155 + self.test_value(result['Crab']['Prefactor'].error(), 0.0529105e-16,
  156 + 1.0e-3, 'Check Crab Prefactor error')
  157 + self.test_value(result['Crab']['Index'].value(), -2.43549,
  158 + 1.0e-3, 'Check fitted Crab Index')
  159 + self.test_value(result['Crab']['Index'].error(), 0.027804,
  160 + 1.0e-3, 'Check Crab Index error')
  161 + self.test_value(result['Background']['Prefactor'].value(), 61.6919e-6,
  162 + 1.0e-3, 'Check fitted background Prefactor')
  163 + self.test_value(result['Background']['Prefactor'].error(), 1.49438e-6,
  164 + 1.0e-3, 'Check background Prefactor error')
  165 + self.test_value(result['Background']['Index'].value(), -2.20535,
  166 + 1.0e-3, 'Check fitted background Index')
  167 + self.test_value(result['Background']['Index'].error(), 0.0113269,
  168 + 1.0e-3, 'Check background Index error')
  169 + self.test_value(result['Background']['Sigma'].value(), 3.04252,
  170 + 1.0e-3, 'Check fitted background Sigma')
  171 + self.test_value(result['Background']['Sigma'].error(), 0.0307008,
  172 + 1.0e-3, 'Check background Sigma error')
99 173  
100 174 # Return
101 175 return
... ...
test/test_ctexpcube.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,11 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.caldb = "irf"
43   - self.irf = "cta_dummy_irf"
44   -
45 41 # Return
46 42 return
47 43  
... ... @@ -51,59 +47,119 @@ class Test(gammalib.GPythonTestSuite):
51 47 Set all test functions.
52 48 """
53 49 # Set test name
54   - self.name("ctexpcube")
  50 + self.name('ctexpcube')
55 51  
56 52 # Append tests
57   - self.append(self.test_functional, "Test ctexpcube functionality")
  53 + self.append(self._test_cmd, 'Test ctexpcube on command line')
  54 + self.append(self._test_python, 'Test ctexpcube from Python')
58 55  
59 56 # Return
60 57 return
61 58  
62   - # Test ctexpcube functionnality
63   - def test_functional(self):
  59 + # Test ctexpcube on command line
  60 + def _test_cmd(self):
64 61 """
65   - Test ctexpcube functionnality.
  62 + Test ctexpcube on the command line.
66 63 """
67   - # Set-up ctexpcube
68   - expcube = ctools.ctexpcube()
69   - expcube["inobs"] = self.events_name
70   - expcube["incube"] = "NONE"
71   - expcube["outcube"] = "expcube.fits"
72   - expcube["caldb"] = self.caldb
73   - expcube["irf"] = self.irf
74   - expcube["ebinalg"] = "LOG"
75   - expcube["emin"] = 0.1
76   - expcube["emax"] = 100
77   - expcube["enumbins"] = 20
78   - expcube["nxpix"] = 200
79   - expcube["nypix"] = 200
80   - expcube["binsz"] = 0.02
81   - expcube["coordsys"] = "CEL"
82   - expcube["proj"] = "CAR"
83   - expcube["xref"] = 83.63
84   - expcube["yref"] = 22.01
85   -
86   - # Run tool
87   - self.test_try("Run ctexpcube")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctexpcube = '../src/ctexpcube/ctexpcube'
  67 + else:
  68 + ctexpcube = 'ctexpcube'
  69 +
  70 + # Setup ctexpcube command
  71 + cmd = ctexpcube+' inobs="data/crab_events.fits"'+ \
  72 + ' incube="NONE"'+ \
  73 + ' outcube="ctexpcube_cmd1.fits"'+ \
  74 + ' caldb="prod2" irf="South_0.5h"'+ \
  75 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  76 + ' nxpix=200 nypix=200 binsz=0.02'+ \
  77 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  78 + ' logfile="ctexpcube_cmd1.log" chatter=1'
  79 +
  80 + # Execute ctexpcube, make sure we catch any exception
88 81 try:
89   - expcube.run()
90   - self.test_try_success()
91   - #except Exception as e:
92   - # msg = "Exception occured in ctexpcube: %s." % (e,)
  82 + rc = os.system(cmd+' >/dev/null 2>&1')
93 83 except:
94   - msg = "Exception occured in ctexpcube."
95   - self.test_try_failure(msg)
  84 + pass
  85 +
  86 + # Check if execution was successful
  87 + self.test_assert(rc == 0,
  88 + 'Successful ctexpcube execution on command line')
  89 +
  90 + # Check result file
  91 + self._check_result_file('ctexpcube_cmd1.fits')
96 92  
97   - # Save exposure cube
98   - self.test_try("Save exposure cube")
  93 + # Setup ctexpcube command
  94 + cmd = ctexpcube+' inobs="event_file_that_does_not_exist.fits"'+ \
  95 + ' incube="NONE"'+ \
  96 + ' outcube="ctexpcube_cmd2.fits"'+ \
  97 + ' caldb="prod2" irf="South_0.5h"'+ \
  98 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  99 + ' nxpix=200 nypix=200 binsz=0.02'+ \
  100 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  101 + ' logfile="ctexpcube_cmd2.log" chatter=1'
  102 +
  103 + # Execute ctexpcube, make sure we catch any exception
99 104 try:
100   - expcube.save()
101   - self.test_try_success()
102   - #except Exception as e:
103   - # msg = "Exception occured in saving exposure cube: %s." % (e,)
  105 + rc = os.system(cmd+' >/dev/null 2>&1')
104 106 except:
105   - msg = "Exception occured in saving exposure cube."
106   - self.test_try_failure(msg)
  107 + pass
  108 +
  109 + # Check if execution failed
  110 + self.test_assert(rc != 0,
  111 + 'Failure of ctexpcube execution on command line')
  112 +
  113 + # Return
  114 + return
  115 +
  116 + # Test ctexpcube from Python
  117 + def _test_python(self):
  118 + """
  119 + Test ctexpcube from Python.
  120 + """
  121 + # Set-up ctexpcube
  122 + expcube = ctools.ctexpcube()
  123 + expcube['inobs'] = 'data/crab_events.fits'
  124 + expcube['incube'] = 'NONE'
  125 + expcube['outcube'] = 'ctexpcube_py1.fits'
  126 + expcube['caldb'] = 'prod2'
  127 + expcube['irf'] = 'South_0.5h'
  128 + expcube['ebinalg'] = 'LOG'
  129 + expcube['emin'] = 0.1
  130 + expcube['emax'] = 100
  131 + expcube['enumbins'] = 20
  132 + expcube['nxpix'] = 200
  133 + expcube['nypix'] = 200
  134 + expcube['binsz'] = 0.02
  135 + expcube['coordsys'] = 'CEL'
  136 + expcube['proj'] = 'CAR'
  137 + expcube['xref'] = 83.63
  138 + expcube['yref'] = 22.01
  139 + expcube['logfile'] = 'ctexpcube_py1.log'
  140 + expcube['chatter'] = 2
  141 +
  142 + # Run ctexpcube tool
  143 + expcube.logFileOpen() # Make sure we get a log file
  144 + expcube.run()
  145 + expcube.save()
  146 +
  147 + # Check result file
  148 + self._check_result_file('ctexpcube_py1.fits')
  149 +
  150 + # Return
  151 + return
  152 +
  153 + # Check result file
  154 + def _check_result_file(self, filename):
  155 + """
  156 + Check result file.
  157 + """
  158 + # Open result file
  159 + result = gammalib.GCTACubeExposure(filename)
  160 +
  161 + # Check dimensions
  162 + self.test_value(len(result.elogmeans()), 20, 'Check for 20 energy bins')
107 163  
108 164 # Return
109 165 return
... ...
test/test_ctlike.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,12 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.model_name = "data/crab.xml"
43   - self.caldb = "irf"
44   - self.irf = "cta_dummy_irf"
45   -
46 41 # Return
47 42 return
48 43  
... ... @@ -52,48 +47,121 @@ class Test(gammalib.GPythonTestSuite):
52 47 Set all test functions.
53 48 """
54 49 # Set test name
55   - self.name("ctlike")
  50 + self.name('ctlike')
56 51  
57 52 # Append tests
58   - self.append(self.test_functional, "Test ctlike functionality")
  53 + self.append(self._test_cmd, 'Test ctlike on command line')
  54 + self.append(self._test_python, 'Test ctlike from Python')
59 55  
60 56 # Return
61 57 return
62 58  
63   - # Test ctlike functionnality
64   - def test_functional(self):
  59 + # Test ctlike on command line
  60 + def _test_cmd(self):
65 61 """
66   - Test ctlike functionnality.
  62 + Test ctlike on the command line.
67 63 """
68   - # Set-up ctlike
69   - like = ctools.ctlike()
70   - like["inobs"] = self.events_name
71   - like["inmodel"] = self.model_name
72   - like["caldb"] = self.caldb
73   - like["irf"] = self.irf
74   - like["outmodel"] = "result.xml"
75   -
76   - # Run tool
77   - self.test_try("Run ctlike")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctlike = '../src/ctlike/ctlike'
  67 + else:
  68 + ctlike = 'ctlike'
  69 +
  70 + # Setup ctlike command
  71 + cmd = ctlike+' inobs="data/crab_events.fits"'+ \
  72 + ' inmodel="data/crab.xml"'+ \
  73 + ' caldb="prod2" irf="South_0.5h"'+ \
  74 + ' outmodel="ctlike_cmd1.xml"'+ \
  75 + ' logfile="ctlike_cmd1.log" chatter=1'
  76 +
  77 + # Execute ctlike, make sure we catch any exception
78 78 try:
79   - like.run()
80   - self.test_try_success()
81   - #except Exception as e:
82   - # msg = "Exception occured in ctlike: %s." % (e,)
  79 + rc = os.system(cmd+' >/dev/null 2>&1')
83 80 except:
84   - msg = "Exception occured in ctlike."
85   - self.test_try_failure(msg)
  81 + pass
  82 +
  83 + # Check if execution was successful
  84 + self.test_assert(rc == 0,
  85 + 'Successful ctlike execution on command line')
  86 +
  87 + # Check result file
  88 + self._check_result_file('ctlike_cmd1.xml')
86 89  
87   - # Save results
88   - self.test_try("Save results")
  90 + # Setup ctlike command
  91 + cmd = ctlike+' inobs="event_file_that_does_not_exist.fits"'+ \
  92 + ' inmodel="data/crab.xml"'+ \
  93 + ' caldb="prod2" irf="South_0.5h"'+ \
  94 + ' outmodel="ctlike_cmd2.xml"'+ \
  95 + ' logfile="ctlike_cmd2.log" chatter=1'
  96 +
  97 + # Execute ctlike, make sure we catch any exception
89 98 try:
90   - like.save()
91   - self.test_try_success()
92   - #except Exception as e:
93   - # msg = "Exception occured in saving results: %s." % (e,)
  99 + rc = os.system(cmd+' >/dev/null 2>&1')
94 100 except:
95   - msg = "Exception occured in saving results."
96   - self.test_try_failure(msg)
  101 + pass
  102 +
  103 + # Check if execution failed
  104 + self.test_assert(rc != 0,
  105 + 'Failure of ctlike execution on command line')
  106 +
  107 + # Return
  108 + return
  109 +
  110 + # Test ctlike from Python
  111 + def _test_python(self):
  112 + """
  113 + Test ctlike from Python.
  114 + """
  115 + # Set-up ctlike
  116 + like = ctools.ctlike()
  117 + like['inobs'] = 'data/crab_events.fits'
  118 + like['inmodel'] = 'data/crab.xml'
  119 + like['caldb'] = 'prod2'
  120 + like['irf'] = 'South_0.5h'
  121 + like['outmodel'] = 'ctlike_py1.xml'
  122 + like['logfile'] = 'ctlike_py1.log'
  123 + like['chatter'] = 2
  124 +
  125 + # Run ctlike tool
  126 + like.logFileOpen() # Make sure we get a log file
  127 + like.run()
  128 + like.save()
  129 +
  130 + # Check result file
  131 + self._check_result_file('ctlike_py1.xml')
  132 +
  133 + # Return
  134 + return
  135 +
  136 + # Check result file
  137 + def _check_result_file(self, filename):
  138 + """
  139 + Check result file.
  140 + """
  141 + # Open result file
  142 + result = gammalib.GModels(filename)
  143 +
  144 + # Check results
  145 + self.test_value(result['Crab']['Prefactor'].value(), 1.58907e-16,
  146 + 1.0e-3, 'Check fitted Crab Prefactor')
  147 + self.test_value(result['Crab']['Prefactor'].error(), 0.0526982e-16,
  148 + 1.0e-3, 'Check Crab Prefactor error')
  149 + self.test_value(result['Crab']['Index'].value(), -2.43549,
  150 + 1.0e-3, 'Check fitted Crab Index')
  151 + self.test_value(result['Crab']['Index'].error(), 0.0248116,
  152 + 1.0e-3, 'Check Crab Index error')
  153 + self.test_value(result['Background']['Prefactor'].value(), 61.6919e-6,
  154 + 1.0e-3, 'Check fitted background Prefactor')
  155 + self.test_value(result['Background']['Prefactor'].error(), 1.49438e-6,
  156 + 1.0e-3, 'Check background Prefactor error')
  157 + self.test_value(result['Background']['Index'].value(), -2.20535,
  158 + 1.0e-3, 'Check fitted background Index')
  159 + self.test_value(result['Background']['Index'].error(), 0.0113269,
  160 + 1.0e-3, 'Check background Index error')
  161 + self.test_value(result['Background']['Sigma'].value(), 3.04252,
  162 + 1.0e-3, 'Check fitted background Sigma')
  163 + self.test_value(result['Background']['Sigma'].error(), 0.0307008,
  164 + 1.0e-3, 'Check background Sigma error')
97 165  
98 166 # Return
99 167 return
... ...
test/test_ctmodel.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,11 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.model_name = "data/crab.xml"
42   - self.caldb = "irf"
43   - self.irf = "cta_dummy_irf"
44   -
45 41 # Return
46 42 return
47 43  
... ... @@ -51,67 +47,139 @@ class Test(gammalib.GPythonTestSuite):
51 47 Set all test functions.
52 48 """
53 49 # Set test name
54   - self.name("ctmodel")
  50 + self.name('ctmodel')
55 51  
56 52 # Append tests
57   - self.append(self.test_functional, "Test ctmodel functionality")
  53 + self.append(self._test_cmd, 'Test ctmodel on command line')
  54 + self.append(self._test_python, 'Test ctmodel from Python')
58 55  
59 56 # Return
60 57 return
61 58  
62   - # Test ctmodel functionnality
63   - def test_functional(self):
  59 + # Test ctmodel on command line
  60 + def _test_cmd(self):
64 61 """
65   - Test ctmodel functionnality.
  62 + Test ctmodel on the command line.
66 63 """
67   - # Set-up ctmodel from scratch
68   - model = ctools.ctmodel()
69   - model["incube"] = "NONE"
70   - model["outcube"] = "modmap.fits"
71   - model["inmodel"] = self.model_name
72   - model["inobs"] = "NONE"
73   - model["expcube"] = "NONE"
74   - model["psfcube"] = "NONE"
75   - model["bkgcube"] = "NONE"
76   - model["caldb"] = self.caldb
77   - model["irf"] = self.irf
78   - model["rad"] = 5
79   - model["ra"] = 83.63
80   - model["dec"] = 22.01
81   - model["tmin"] = 0
82   - model["tmax"] = 1800
83   - model["emin"] = 0.1
84   - model["emax"] = 100
85   - model["enumbins"] = 20
86   - model["nxpix"] = 200
87   - model["nypix"] = 200
88   - model["binsz"] = 0.02
89   - model["coordsys"] = "CEL"
90   - model["proj"] = "CAR"
91   - model["xref"] = 83.63
92   - model["yref"] = 22.01
93   -
94   - # Run tool
95   - self.test_try("Run ctmodel")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctmodel = '../src/ctmodel/ctmodel'
  67 + else:
  68 + ctmodel = 'ctmodel'
  69 +
  70 + # Setup ctmodel command
  71 + cmd = ctmodel+' incube="NONE" inobs="NONE" expcube="NONE"'+\
  72 + ' psfcube="NONE" bkgcube="NONE"'+ \
  73 + ' outcube="ctmodel_cmd1.fits"'+ \
  74 + ' inmodel="data/crab.xml"'+ \
  75 + ' caldb="prod2" irf="South_0.5h"'+ \
  76 + ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \
  77 + ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \
  78 + ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
  79 + ' xref=83.63 yref=22.01'+ \
  80 + ' logfile="ctmodel_cmd1.log" chatter=1'
  81 +
  82 + # Execute ctmodel, make sure we catch any exception
96 83 try:
97   - model.run()
98   - self.test_try_success()
99   - #except Exception as e:
100   - # msg = "Exception occured in ctmodel: %s." % (e,)
  84 + rc = os.system(cmd+' >/dev/null 2>&1')
101 85 except:
102   - msg = "Exception occured in ctmodel."
103   - self.test_try_failure(msg)
  86 + pass
  87 +
  88 + # Check if execution was successful
  89 + self.test_assert(rc == 0,
  90 + 'Successful ctmodel execution on command line')
  91 +
  92 + # Check result file
  93 + self._check_result_file('ctmodel_cmd1.fits')
104 94  
105   - # Save counts cube
106   - self.test_try("Save model cube")
  95 + # Setup ctmodel command
  96 + cmd = ctmodel+' incube="NONE" inobs="NONE" expcube="NONE"'+\
  97 + ' psfcube="NONE" bkgcube="NONE"'+ \
  98 + ' outcube="ctmodel_cmd2.fits"'+ \
  99 + ' inmodel="model_that_does_not_exist.xml"'+ \
  100 + ' caldb="prod2" irf="South_0.5h"'+ \
  101 + ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \
  102 + ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \
  103 + ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
  104 + ' xref=83.63 yref=22.01'+ \
  105 + ' logfile="ctmodel_cmd2.log" chatter=1'
  106 +
  107 + # Execute ctmodel, make sure we catch any exception
107 108 try:
108   - model.save()
109   - self.test_try_success()
110   - #except Exception as e:
111   - # msg = "Exception occured in saving model cube: %s." % (e,)
  109 + rc = os.system(cmd+' >/dev/null 2>&1')
112 110 except:
113   - msg = "Exception occured in saving model cube."
114   - self.test_try_failure(msg)
  111 + pass
  112 +
  113 + # Check if execution failed
  114 + self.test_assert(rc != 0,
  115 + 'Failure of ctmodel execution on command line')
  116 +
  117 + # Return
  118 + return
  119 +
  120 + # Test ctmodel from Python
  121 + def _test_python(self):
  122 + """
  123 + Test ctmodel from Python.
  124 + """
  125 + # Set-up ctmodel from scratch
  126 + model = ctools.ctmodel()
  127 + model['incube'] = 'NONE'
  128 + model['outcube'] = 'ctmodel_py1.fits'
  129 + model['inmodel'] = 'data/crab.xml'
  130 + model['inobs'] = 'NONE'
  131 + model['expcube'] = 'NONE'
  132 + model['psfcube'] = 'NONE'
  133 + model['bkgcube'] = 'NONE'
  134 + model['caldb'] = 'prod2'
  135 + model['irf'] = 'South_0.5h'
  136 + model['rad'] = 5
  137 + model['ra'] = 83.63
  138 + model['dec'] = 22.01
  139 + model['tmin'] = 0
  140 + model['tmax'] = 1800
  141 + model['emin'] = 0.1
  142 + model['emax'] = 100
  143 + model['enumbins'] = 20
  144 + model['nxpix'] = 200
  145 + model['nypix'] = 200
  146 + model['binsz'] = 0.02
  147 + model['coordsys'] = 'CEL'
  148 + model['proj'] = 'CAR'
  149 + model['xref'] = 83.63
  150 + model['yref'] = 22.01
  151 + model['logfile'] = 'ctmodel_py1.log'
  152 + model['chatter'] = 2
  153 +
  154 + # Run ctmodel tool
  155 + model.logFileOpen() # Make sure we get a log file
  156 + model.run()
  157 + model.save()
  158 +
  159 + # Check result file
  160 + self._check_result_file('ctmodel_py1.fits')
  161 +
  162 + # Return
  163 + return
  164 +
  165 + # Check result file
  166 + def _check_result_file(self, filename):
  167 + """
  168 + Check result file.
  169 + """
  170 + # Open result file
  171 + fits = gammalib.GFits(filename)
  172 +
  173 + # Get HDUs
  174 + cube = fits['Primary']
  175 + ebounds = fits['EBOUNDS']
  176 + gti = fits['GTI']
  177 +
  178 + # Check dimensions
  179 + self.test_value(cube.naxis(), 3, 'Check for 3 cube dimensions')
  180 + self.test_value(cube.naxes(0), 200, 'Check for 200 pixels in X')
  181 + self.test_value(cube.naxes(1), 200, 'Check for 200 pixels in Y')
  182 + self.test_value(cube.naxes(2), 20, 'Check for 20 pixels in Z')
115 183  
116 184 # Return
117 185 return
... ...
test/test_ctpsfcube.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,11 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.caldb = "irf"
43   - self.irf = "cta_dummy_irf"
44   -
45 41 # Return
46 42 return
47 43  
... ... @@ -51,61 +47,123 @@ class Test(gammalib.GPythonTestSuite):
51 47 Set all test functions.
52 48 """
53 49 # Set test name
54   - self.name("ctpsfcube")
  50 + self.name('ctpsfcube')
55 51  
56 52 # Append tests
57   - self.append(self.test_functional, "Test ctpsfcube functionality")
  53 + self.append(self._test_cmd, 'Test ctpsfcube on command line')
  54 + self.append(self._test_python, 'Test ctpsfcube from Python')
58 55  
59 56 # Return
60 57 return
61 58  
62   - # Test ctpsfcube functionnality
63   - def test_functional(self):
  59 + # Test ctpsfcube on command line
  60 + def _test_cmd(self):
64 61 """
65   - Test ctpsfcube functionnality.
  62 + Test ctpsfcube on the command line.
66 63 """
67   - # Set-up ctpsfcube
68   - psfcube = ctools.ctpsfcube()
69   - psfcube["inobs"] = self.events_name
70   - psfcube["incube"] = "NONE"
71   - psfcube["outcube"] = "psfcube.fits"
72   - psfcube["caldb"] = self.caldb
73   - psfcube["irf"] = self.irf
74   - psfcube["ebinalg"] = "LOG"
75   - psfcube["emin"] = 0.1
76   - psfcube["emax"] = 100
77   - psfcube["enumbins"] = 20
78   - psfcube["nxpix"] = 10
79   - psfcube["nypix"] = 10
80   - psfcube["binsz"] = 0.4
81   - psfcube["coordsys"] = "CEL"
82   - psfcube["proj"] = "CAR"
83   - psfcube["xref"] = 83.63
84   - psfcube["yref"] = 22.01
85   - psfcube["amax"] = 0.3
86   - psfcube["anumbins"] = 10
87   -
88   - # Run tool
89   - self.test_try("Run ctpsfcube")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctpsfcube = '../src/ctpsfcube/ctpsfcube'
  67 + else:
  68 + ctpsfcube = 'ctpsfcube'
  69 +
  70 + # Setup ctpsfcube command
  71 + cmd = ctpsfcube+' inobs="data/crab_events.fits"'+ \
  72 + ' incube="NONE"'+ \
  73 + ' outcube="ctpsfcube_cmd1.fits"'+ \
  74 + ' caldb="prod2" irf="South_0.5h"'+ \
  75 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  76 + ' nxpix=200 nypix=200 binsz=0.02'+ \
  77 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  78 + ' amax=0.3 anumbins=10'+ \
  79 + ' logfile="ctpsfcube_cmd1.log" chatter=1'
  80 +
  81 + # Execute ctpsfcube, make sure we catch any exception
90 82 try:
91   - psfcube.run()
92   - self.test_try_success()
93   - #except Exception as e:
94   - # msg = "Exception occured in ctpsfcube: %s." % (e,)
  83 + rc = os.system(cmd+' >/dev/null 2>&1')
95 84 except:
96   - msg = "Exception occured in ctpsfcube."
97   - self.test_try_failure(msg)
  85 + pass
  86 +
  87 + # Check if execution was successful
  88 + self.test_assert(rc == 0,
  89 + 'Successful ctpsfcube execution on command line')
  90 +
  91 + # Check result file
  92 + self._check_result_file('ctpsfcube_cmd1.fits')
98 93  
99   - # Save PSF cube
100   - self.test_try("Save PSF cube")
  94 + # Setup ctpsfcube command
  95 + cmd = ctpsfcube+' inobs="event_file_that_does_not_exist.fits"'+ \
  96 + ' incube="NONE"'+ \
  97 + ' outcube="ctpsfcube_cmd2.fits"'+ \
  98 + ' caldb="prod2" irf="South_0.5h"'+ \
  99 + ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
  100 + ' nxpix=200 nypix=200 binsz=0.02'+ \
  101 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  102 + ' amax=0.3 anumbins=10'+ \
  103 + ' logfile="ctpsfcube_cmd2.log" chatter=1'
  104 +
  105 + # Execute ctpsfcube, make sure we catch any exception
101 106 try:
102   - psfcube.save()
103   - self.test_try_success()
104   - #except Exception as e:
105   - # msg = "Exception occured in saving PSF cube: %s." % (e,)
  107 + rc = os.system(cmd+' >/dev/null 2>&1')
106 108 except:
107   - msg = "Exception occured in saving PSF cubes."
108   - self.test_try_failure(msg)
  109 + pass
  110 +
  111 + # Check if execution failed
  112 + self.test_assert(rc != 0,
  113 + 'Failure of ctpsfcube execution on command line')
  114 +
  115 + # Return
  116 + return
  117 +
  118 + # Test ctpsfcube from Python
  119 + def _test_python(self):
  120 + """
  121 + Test ctpsfcube from Python.
  122 + """
  123 + # Set-up ctpsfcube
  124 + psfcube = ctools.ctpsfcube()
  125 + psfcube['inobs'] = 'data/crab_events.fits'
  126 + psfcube['incube'] = 'NONE'
  127 + psfcube['outcube'] = 'ctpsfcube_py1.fits'
  128 + psfcube['caldb'] = 'prod2'
  129 + psfcube['irf'] = 'South_0.5h'
  130 + psfcube['ebinalg'] = 'LOG'
  131 + psfcube['emin'] = 0.1
  132 + psfcube['emax'] = 100
  133 + psfcube['enumbins'] = 20
  134 + psfcube['nxpix'] = 10
  135 + psfcube['nypix'] = 10
  136 + psfcube['binsz'] = 0.4
  137 + psfcube['coordsys'] = 'CEL'
  138 + psfcube['proj'] = 'CAR'
  139 + psfcube['xref'] = 83.63
  140 + psfcube['yref'] = 22.01
  141 + psfcube['amax'] = 0.3
  142 + psfcube['anumbins'] = 10
  143 + psfcube['logfile'] = 'ctpsfcube_py1.log'
  144 + psfcube['chatter'] = 2
  145 +
  146 + # Run ctpsfcube tool
  147 + psfcube.logFileOpen() # Make sure we get a log file
  148 + psfcube.run()
  149 + psfcube.save()
  150 +
  151 + # Check result file
  152 + self._check_result_file('ctpsfcube_py1.fits')
  153 +
  154 + # Return
  155 + return
  156 +
  157 + # Check result file
  158 + def _check_result_file(self, filename):
  159 + """
  160 + Check result file.
  161 + """
  162 + # Open result file
  163 + result = gammalib.GCTACubePsf(filename)
  164 +
  165 + # Check dimensions
  166 + self.test_value(len(result.elogmeans()), 20, 'Check for 20 energy bins')
109 167  
110 168 # Return
111 169 return
... ...
test/test_ctselect.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,9 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   -
43 41 # Return
44 42 return
45 43  
... ... @@ -49,52 +47,114 @@ class Test(gammalib.GPythonTestSuite):
49 47 Set all test functions.
50 48 """
51 49 # Set test name
52   - self.name("ctselect")
  50 + self.name('ctselect')
53 51  
54 52 # Append tests
55   - self.append(self.test_functional, "Test ctselect functionality")
  53 + self.append(self._test_cmd, 'Test ctselect on command line')
  54 + self.append(self._test_python, 'Test ctselect from Python')
56 55  
57 56 # Return
58 57 return
59 58  
60   - # Test ctselect functionnality
61   - def test_functional(self):
  59 + # Test ctselect on command line
  60 + def _test_cmd(self):
62 61 """
63   - Test ctselect functionnality.
  62 + Test ctselect on the command line.
64 63 """
65   - # Set-up ctselect
66   - select = ctools.ctselect()
67   - select["inobs"] = self.events_name
68   - select["outobs"] = "selected_events.fits"
69   - select["ra"] = 83.63
70   - select["dec"] = 22.01
71   - select["rad"] = 3
72   - select["tmin"] = 0
73   - select["tmax"] = 1800
74   - select["emin"] = 0.1
75   - select["emax"] = 100
76   -
77   - # Run tool
78   - self.test_try("Run ctselect")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctselect = '../src/ctselect/ctselect'
  67 + else:
  68 + ctselect = 'ctselect'
  69 +
  70 + # Setup ctselect command
  71 + cmd = ctselect+' inobs="data/crab_events.fits"'+ \
  72 + ' outobs="ctselect_cmd1.fits"'+ \
  73 + ' ra=83.63 dec=22.01 rad=3.0'+ \
  74 + ' tmin=0.0 tmax=1800.0'+ \
  75 + ' emin=0.1 emax=100.0'+ \
  76 + ' logfile="ctselect_cmd1.log" chatter=1'
  77 +
  78 + # Execute ctselect, make sure we catch any exception
79 79 try:
80   - select.run()
81   - self.test_try_success()
82   - #except Exception as e:
83   - # msg = "Exception occured in ctselect: %s." % (e,)
  80 + rc = os.system(cmd+' >/dev/null 2>&1')
84 81 except:
85   - msg = "Exception occured in ctselect."
86   - self.test_try_failure(msg)
  82 + pass
  83 +
  84 + # Check if execution was successful
  85 + self.test_assert(rc == 0,
  86 + 'Successful ctselect execution on command line')
  87 +
  88 + # Check result file
  89 + self._check_result_file('ctselect_cmd1.fits')
87 90  
88   - # Save events
89   - self.test_try("Save events")
  91 + # Setup ctselect command
  92 + cmd = ctselect+' inobs="event_file_that_does_not_exist.fits"'+ \
  93 + ' outobs="ctselect_cmd2.fits"'+ \
  94 + ' ra=83.63 dec=22.01 rad=3.0'+ \
  95 + ' tmin=0.0 tmax=1800.0'+ \
  96 + ' emin=0.1 emax=100.0'+ \
  97 + ' logfile="ctselect_cmd2.log" chatter=1'
  98 +
  99 + # Execute ctselect, make sure we catch any exception
90 100 try:
91   - select.save()
92   - self.test_try_success()
93   - #except Exception as e:
94   - # msg = "Exception occured in saving events: %s." % (e,)
  101 + rc = os.system(cmd+' >/dev/null 2>&1')
95 102 except:
96   - msg = "Exception occured in saving events."
97   - self.test_try_failure(msg)
  103 + pass
  104 +
  105 + # Check if execution failed
  106 + self.test_assert(rc != 0,
  107 + 'Failure of ctselect execution on command line')
  108 +
  109 + # Return
  110 + return
  111 +
  112 + # Test ctselect from Python
  113 + def _test_python(self):
  114 + """
  115 + Test ctselect from Python.
  116 + """
  117 + # Set-up ctselect
  118 + select = ctools.ctselect()
  119 + select['inobs'] = 'data/crab_events.fits'
  120 + select['outobs'] = 'ctselect_py1.fits'
  121 + select['ra'] = 83.63
  122 + select['dec'] = 22.01
  123 + select['rad'] = 3
  124 + select['tmin'] = 0
  125 + select['tmax'] = 1800
  126 + select['emin'] = 0.1
  127 + select['emax'] = 100
  128 + select['logfile'] = 'ctselect_py1.log'
  129 + select['chatter'] = 2
  130 +
  131 + # Run ctselect tool
  132 + select.logFileOpen() # Make sure we get a log file
  133 + select.run()
  134 + select.save()
  135 +
  136 + # Check result file
  137 + self._check_result_file('ctselect_py1.fits')
  138 +
  139 + # Return
  140 + return
  141 +
  142 + # Check result file
  143 + def _check_result_file(self, filename):
  144 + """
  145 + Check result file.
  146 + """
  147 + # Open result file
  148 + result = gammalib.GCTAEventList(filename)
  149 +
  150 + # Check file
  151 + self.test_value(result.size(), 6127, 'Check for 6127 events')
  152 + self.test_value(result.roi().centre().dir().ra_deg(), 83.63, 1.0e-6,
  153 + 'Check for ROI Right Ascension')
  154 + self.test_value(result.roi().centre().dir().dec_deg(), 22.01, 1.0e-6,
  155 + 'Check for ROI Declination')
  156 + self.test_value(result.roi().radius(), 3.0, 1.0e-6,
  157 + 'Check for ROI Radius')
98 158  
99 159 # Return
100 160 return
... ...
test/test_ctskymap.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,9 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   -
43 41 # Return
44 42 return
45 43  
... ... @@ -49,54 +47,112 @@ class Test(gammalib.GPythonTestSuite):
49 47 Set all test functions.
50 48 """
51 49 # Set test name
52   - self.name("ctskymap")
  50 + self.name('ctskymap')
53 51  
54 52 # Append tests
55   - self.append(self.test_functional, "Test ctskymap functionality")
  53 + self.append(self._test_cmd, 'Test ctskymap on command line')
  54 + self.append(self._test_python, 'Test ctskymap from Python')
56 55  
57 56 # Return
58 57 return
59 58  
60   - # Test ctskymap functionnality
61   - def test_functional(self):
  59 + # Test ctskymap on command line
  60 + def _test_cmd(self):
62 61 """
63   - Test ctskymap functionnality.
  62 + Test ctskymap on the command line.
64 63 """
65   - # Set-up ctskymap
66   - skymap = ctools.ctskymap()
67   - skymap["inobs"] = self.events_name
68   - skymap["outmap"] = "skymap.fits"
69   - skymap["emin"] = 0.1
70   - skymap["emax"] = 100
71   - skymap["nxpix"] = 200
72   - skymap["nypix"] = 200
73   - skymap["binsz"] = 0.02
74   - skymap["coordsys"] = "CEL"
75   - skymap["proj"] = "CAR"
76   - skymap["xref"] = 83.63
77   - skymap["yref"] = 22.01
78   -
79   - # Run tool
80   - self.test_try("Run ctskymap")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctskymap = '../src/ctskymap/ctskymap'
  67 + else:
  68 + ctskymap = 'ctskymap'
  69 +
  70 + # Setup ctskymap command
  71 + cmd = ctskymap+' inobs="data/crab_events.fits"'+\
  72 + ' outmap="ctskymap_cmd1.fits"'+ \
  73 + ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \
  74 + ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
  75 + ' xref=83.63 yref=22.01'+ \
  76 + ' logfile="ctskymap_cmd1.log" chatter=1'
  77 +
  78 + # Execute ctskymap, make sure we catch any exception
81 79 try:
82   - skymap.run()
83   - self.test_try_success()
84   - #except Exception as e:
85   - # msg = "Exception occured in ctskymap: %s." % (e,)
  80 + rc = os.system(cmd+' >/dev/null 2>&1')
86 81 except:
87   - msg = "Exception occured in ctskymap."
88   - self.test_try_failure(msg)
  82 + pass
  83 +
  84 + # Check if execution was successful
  85 + self.test_assert(rc == 0,
  86 + 'Successful ctskymap execution on command line')
  87 +
  88 + # Check result file
  89 + self._check_result_file('ctskymap_cmd1.fits')
89 90  
90   - # Save counts cube
91   - self.test_try("Save sky map")
  91 + # Setup ctskymap command
  92 + cmd = ctskymap+' inobs="event_file_that_does_not_exist.fits"'+\
  93 + ' outmap="ctskymap_cmd2.fits"'+ \
  94 + ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \
  95 + ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
  96 + ' xref=83.63 yref=22.01'+ \
  97 + ' logfile="ctskymap_cmd2.log" chatter=2'
  98 +
  99 + # Execute ctskymap, make sure we catch any exception
92 100 try:
93   - skymap.save()
94   - self.test_try_success()
95   - #except Exception as e:
96   - # msg = "Exception occured in saving sky map: %s." % (e,)
  101 + rc = os.system(cmd+' >/dev/null 2>&1')
97 102 except:
98   - msg = "Exception occured in saving sky map."
99   - self.test_try_failure(msg)
  103 + pass
  104 +
  105 + # Check if execution failed
  106 + self.test_assert(rc != 0,
  107 + 'Failure of ctskymap execution on command line')
  108 +
  109 + # Return
  110 + return
  111 +
  112 + # Test ctskymap from Python
  113 + def _test_python(self):
  114 + """
  115 + Test ctskymap from Python.
  116 + """
  117 + # Set-up ctskymap
  118 + skymap = ctools.ctskymap()
  119 + skymap['inobs'] = 'data/crab_events.fits'
  120 + skymap['outmap'] = 'ctskymap_py1.fits'
  121 + skymap['emin'] = 0.1
  122 + skymap['emax'] = 100
  123 + skymap['nxpix'] = 200
  124 + skymap['nypix'] = 200
  125 + skymap['binsz'] = 0.02
  126 + skymap['coordsys'] = 'CEL'
  127 + skymap['proj'] = 'CAR'
  128 + skymap['xref'] = 83.63
  129 + skymap['yref'] = 22.01
  130 + skymap['logfile'] = 'ctskymap_py1.log'
  131 + skymap['chatter'] = 2
  132 +
  133 + # Run ctskymap tool
  134 + skymap.logFileOpen() # Make sure we get a log file
  135 + skymap.run()
  136 + skymap.save()
  137 +
  138 + # Check result file
  139 + self._check_result_file('ctskymap_py1.fits')
  140 +
  141 + # Return
  142 + return
  143 +
  144 + # Check result file
  145 + def _check_result_file(self, filename):
  146 + """
  147 + Check result file.
  148 + """
  149 + # Open result file
  150 + result = gammalib.GSkyMap(filename)
  151 +
  152 + # Check dimensions
  153 + self.test_value(result.nmaps(), 1, 'Check for one map')
  154 + self.test_value(result.nx(), 200, 'Check for 200 pixels in X')
  155 + self.test_value(result.ny(), 200, 'Check for 200 pixels in Y')
100 156  
101 157 # Return
102 158 return
... ...
test/test_cttsmap.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,12 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.model_name = "data/crab.xml"
43   - self.caldb = "irf"
44   - self.irf = "cta_dummy_irf"
45   -
46 41 # Return
47 42 return
48 43  
... ... @@ -52,56 +47,127 @@ class Test(gammalib.GPythonTestSuite):
52 47 Set all test functions.
53 48 """
54 49 # Set test name
55   - self.name("cttsmap")
  50 + self.name('cttsmap')
56 51  
57 52 # Append tests
58   - self.append(self.test_functional, "Test cttsmap functionality")
  53 + self.append(self._test_cmd, 'Test cttsmap on command line')
  54 + self.append(self._test_python, 'Test cttsmap from Python')
59 55  
60 56 # Return
61 57 return
62 58  
63   - # Test cttsmap functionnality
64   - def test_functional(self):
  59 + # Test cttsmap on command line
  60 + def _test_cmd(self):
65 61 """
66   - Test cttsmap functionality.
  62 + Test cttsmap on the command line.
67 63 """
68   - # Set-up cttsmap
69   - tsmap = ctools.cttsmap()
70   - tsmap["inobs"] = self.events_name
71   - tsmap["inmodel"] = self.model_name
72   - tsmap["srcname"] = "Crab"
73   - tsmap["caldb"] = self.caldb
74   - tsmap["irf"] = self.irf
75   - tsmap["outmap"] = "tsmap.fits"
76   - tsmap["nxpix"] = 5
77   - tsmap["nypix"] = 5
78   - tsmap["binsz"] = 0.02
79   - tsmap["coordsys"] = "CEL"
80   - tsmap["proj"] = "CAR"
81   - tsmap["xref"] = 83.63
82   - tsmap["yref"] = 22.01
83   -
84   - # Run tool
85   - self.test_try("Run cttsmap")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + cttsmap = '../src/cttsmap/cttsmap'
  67 + else:
  68 + cttsmap = 'cttsmap'
  69 +
  70 + # Setup cttsmap command
  71 + cmd = cttsmap+' inobs="data/crab_events.fits"'+ \
  72 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  73 + ' caldb="prod2" irf="South_0.5h"'+ \
  74 + ' outmap="cttsmap_cmd1.fits"'+ \
  75 + ' nxpix=5 nypix=5 binsz=0.02'+ \
  76 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  77 + ' logfile="cttsmap_cmd1.log" chatter=1'
  78 +
  79 + # Execute cttsmap, make sure we catch any exception
86 80 try:
87   - tsmap.run()
88   - self.test_try_success()
89   - #except Exception as e:
90   - # msg = "Exception occured in cttsmap: %s." % (e,)
  81 + rc = os.system(cmd+' >/dev/null 2>&1')
91 82 except:
92   - msg = "Exception occured in cttsmap."
93   - self.test_try_failure(msg)
  83 + pass
  84 +
  85 + # Check if execution was successful
  86 + self.test_assert(rc == 0,
  87 + 'Successful cttsmap execution on command line')
  88 +
  89 + # Check result file
  90 + self._check_result_file('cttsmap_cmd1.fits')
94 91  
95   - # Save results
96   - self.test_try("Save results")
  92 + # Setup cttsmap command
  93 + cmd = cttsmap+' inobs="event_file_that_does_not_exist.fits"'+ \
  94 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  95 + ' caldb="prod2" irf="South_0.5h"'+ \
  96 + ' outmap="cttsmap_cmd2.fits"'+ \
  97 + ' nxpix=5 nypix=5 binsz=0.02'+ \
  98 + ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
  99 + ' logfile="cttsmap_cmd2.log" chatter=2'
  100 +
  101 + # Execute cttsmap, make sure we catch any exception
97 102 try:
98   - tsmap.save()
99   - self.test_try_success()
100   - #except Exception as e:
101   - # msg = "Exception occured in saving results: %s." % (e,)
  103 + rc = os.system(cmd+' >/dev/null 2>&1')
102 104 except:
103   - msg = "Exception occured in saving results."
104   - self.test_try_failure(msg)
  105 + pass
  106 +
  107 + # Check if execution failed
  108 + self.test_assert(rc != 0,
  109 + 'Failure of cttsmap execution on command line')
  110 +
  111 + # Return
  112 + return
  113 +
  114 + # Test cttsmap from Python
  115 + def _test_python(self):
  116 + """
  117 + Test cttsmap from Python.
  118 + """
  119 + # Set-up cttsmap
  120 + tsmap = ctools.cttsmap()
  121 + tsmap['inobs'] = 'data/crab_events.fits'
  122 + tsmap['inmodel'] = 'data/crab.xml'
  123 + tsmap['srcname'] = 'Crab'
  124 + tsmap['caldb'] = 'prod2'
  125 + tsmap['irf'] = 'South_0.5h'
  126 + tsmap['outmap'] = 'cttsmap_py1.fits'
  127 + tsmap['nxpix'] = 5
  128 + tsmap['nypix'] = 5
  129 + tsmap['binsz'] = 0.02
  130 + tsmap['coordsys'] = 'CEL'
  131 + tsmap['proj'] = 'CAR'
  132 + tsmap['xref'] = 83.63
  133 + tsmap['yref'] = 22.01
  134 + tsmap['logfile'] = 'cttsmap_py1.log'
  135 + tsmap['chatter'] = 2
  136 +
  137 + # Run cttsmap tool
  138 + tsmap.logFileOpen() # Make sure we get a log file
  139 + tsmap.run()
  140 + tsmap.save()
  141 +
  142 + # Check result file
  143 + self._check_result_file('cttsmap_py1.fits')
  144 +
  145 + # Return
  146 + return
  147 +
  148 + # Check result file
  149 + def _check_result_file(self, filename):
  150 + """
  151 + Check result file.
  152 + """
  153 + # Open result file
  154 + fits = gammalib.GFits(filename)
  155 +
  156 + # Get HDUs
  157 + ts = fits['Primary']
  158 + prefactor = fits['Prefactor']
  159 + index = fits['Index']
  160 +
  161 + # Check dimensions
  162 + self.test_value(ts.naxis(), 2, 'Check for 2 dimensions')
  163 + self.test_value(ts.naxes(0), 5, 'Check for 5 pixels in X')
  164 + self.test_value(ts.naxes(1), 5, 'Check for 5 pixels in Y')
  165 + self.test_value(prefactor.naxis(), 2, 'Check for 2 dimensions')
  166 + self.test_value(prefactor.naxes(0), 5, 'Check for 5 pixels in X')
  167 + self.test_value(prefactor.naxes(1), 5, 'Check for 5 pixels in Y')
  168 + self.test_value(index.naxis(), 2, 'Check for 2 dimensions')
  169 + self.test_value(index.naxes(0), 5, 'Check for 5 pixels in X')
  170 + self.test_value(index.naxes(1), 5, 'Check for 5 pixels in Y')
105 171  
106 172 # Return
107 173 return
... ...
test/test_ctulimit.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -37,12 +38,6 @@ class Test(gammalib.GPythonTestSuite):
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
40   - # Set members
41   - self.events_name = "data/crab_events.fits"
42   - self.model_name = "data/crab.xml"
43   - self.caldb = "irf"
44   - self.irf = "cta_dummy_irf"
45   -
46 41 # Return
47 42 return
48 43  
... ... @@ -52,48 +47,94 @@ class Test(gammalib.GPythonTestSuite):
52 47 Set all test functions.
53 48 """
54 49 # Set test name
55   - self.name("ctulimit")
  50 + self.name('ctulimit')
56 51  
57 52 # Append tests
58   - self.append(self.test_functional, "Test ctulimit functionality")
  53 + self.append(self._test_cmd, 'Test ctulimit on command line')
  54 + self.append(self._test_python, 'Test ctulimit from Python')
59 55  
60 56 # Return
61 57 return
62 58  
63   - # Test cttsmap functionnality
64   - def test_functional(self):
  59 + # Test ctulimit on command line
  60 + def _test_cmd(self):
65 61 """
66   - Test ctulimit functionnality.
  62 + Test ctulimit on the command line.
67 63 """
68   - # Set-up cttsmap
69   - ulimit = ctools.ctulimit()
70   - ulimit["inobs"] = self.events_name
71   - ulimit["inmodel"] = self.model_name
72   - ulimit["srcname"] = "Crab"
73   - ulimit["caldb"] = self.caldb
74   - ulimit["irf"] = self.irf
75   -
76   - # Run tool
77   - self.test_try("Run ctulimit")
  64 + # Kluge to set the command (installed version has no README file)
  65 + if os.path.isfile('README'):
  66 + ctulimit = '../src/ctulimit/ctulimit'
  67 + else:
  68 + ctulimit = 'ctulimit'
  69 +
  70 + # Setup ctulimit command
  71 + cmd = ctulimit+' inobs="data/crab_events.fits"'+ \
  72 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  73 + ' caldb="prod2" irf="South_0.5h"'+ \
  74 + ' logfile="ctulimit_cmd1.log" chatter=1'
  75 +
  76 + # Execute ctulimit, make sure we catch any exception
78 77 try:
79   - ulimit.run()
80   - self.test_try_success()
81   - #except Exception as e:
82   - # msg = "Exception occured in ctulimit: %s." % (e,)
  78 + rc = os.system(cmd+' >/dev/null 2>&1')
83 79 except:
84   - msg = "Exception occured in ctulimit."
85   - self.test_try_failure(msg)
  80 + pass
  81 +
  82 + # Check if execution was successful
  83 + self.test_assert(rc == 0,
  84 + 'Successful ctulimit execution on command line')
  85 +
  86 + # Check result file
  87 + self._check_result_file('ctulimit_cmd1.log')
86 88  
87   - # Save results
88   - self.test_try("Save results")
  89 + # Setup ctulimit command
  90 + cmd = ctulimit+' inobs="event_file_that_does_not_exist.fits"'+ \
  91 + ' inmodel="data/crab.xml" srcname="Crab"'+ \
  92 + ' caldb="prod2" irf="South_0.5h"'+ \
  93 + ' logfile="ctulimit_cmd2.log" chatter=1'
  94 +
  95 + # Execute ctulimit, make sure we catch any exception
89 96 try:
90   - ulimit.save()
91   - self.test_try_success()
92   - #except Exception as e:
93   - # msg = "Exception occured in saving results: %s." % (e,)
  97 + rc = os.system(cmd+' >/dev/null 2>&1')
94 98 except:
95   - msg = "Exception occured in saving results."
96   - self.test_try_failure(msg)
  99 + pass
  100 +
  101 + # Check if execution failed
  102 + self.test_assert(rc != 0,
  103 + 'Failure of ctulimit execution on command line')
  104 +
  105 + # Return
  106 + return
97 107  
  108 + # Test ctulimit from Python
  109 + def _test_python(self):
  110 + """
  111 + Test ctulimit from Python.
  112 + """
  113 + # Set-up ctulimit
  114 + ulimit = ctools.ctulimit()
  115 + ulimit['inobs'] = 'data/crab_events.fits'
  116 + ulimit['inmodel'] = 'data/crab.xml'
  117 + ulimit['srcname'] = 'Crab'
  118 + ulimit['caldb'] = 'prod2'
  119 + ulimit['irf'] = 'South_0.5h'
  120 + ulimit['logfile'] = 'ctulimit_py1.log'
  121 + ulimit['chatter'] = 2
  122 +
  123 + # Run ctulimit tool
  124 + ulimit.logFileOpen() # Make sure we get a log file
  125 + ulimit.run()
  126 + ulimit.save()
  127 +
  128 + # Check result file
  129 + self._check_result_file('ctulimit_py1.log')
  130 +
  131 + # Return
  132 + return
  133 +
  134 + # Check result file
  135 + def _check_result_file(self, filename):
  136 + """
  137 + Check result file.
  138 + """
98 139 # Return
99 140 return
... ...
test/test_python_cscripts.py
... ... @@ -50,6 +50,13 @@ import test_csiactobs
50 50 def test(installed=False, debug=False):
51 51 """
52 52 Perform cscripts unit testing.
  53 +
  54 + Parameters
  55 + ----------
  56 + installed : bool, optional
  57 + Flag indicating whether the script has been installed or not
  58 + debug : bool, optional
  59 + Enables debugging
53 60 """
54 61 # If we have an installed version then create a temporary directory and
55 62 # copy over all information that is needed
... ...
test/test_python_ctools.py
... ... @@ -32,6 +32,7 @@ import test_ctmodel
32 32 import test_ctskymap
33 33 import test_ctexpcube
34 34 import test_ctpsfcube
  35 +import test_ctedispcube
35 36 import test_ctbkgcube
36 37 import test_ctmapcube
37 38 import test_ctcubemask
... ... @@ -47,9 +48,14 @@ import test_pipelines
47 48 def test(installed=False):
48 49 """
49 50 Perform unit testing for ctools.
  51 +
  52 + Parameters
  53 + ----------
  54 + installed : bool, optional
  55 + Flag indicating whether the script has been installed or not
50 56 """
51 57 # Allocate test suite container
52   - suites = gammalib.GTestSuites("ctools unit testing")
  58 + suites = gammalib.GTestSuites('ctools unit testing')
53 59  
54 60 # Allocate test suites and append them to the container
55 61 suite_ctobssim = test_ctobssim.Test()
... ... @@ -61,6 +67,7 @@ def test(installed=False):
61 67 suite_ctskymap = test_ctskymap.Test()
62 68 suite_ctexpcube = test_ctexpcube.Test()
63 69 suite_ctpsfcube = test_ctpsfcube.Test()
  70 + suite_ctedispcube = test_ctedispcube.Test()
64 71 suite_ctbkgcube = test_ctbkgcube.Test()
65 72 suite_ctmapcube = test_ctmapcube.Test()
66 73 suite_ctcubemask = test_ctcubemask.Test()
... ... @@ -79,6 +86,7 @@ def test(installed=False):
79 86 suite_ctskymap.set()
80 87 suite_ctexpcube.set()
81 88 suite_ctpsfcube.set()
  89 + suite_ctedispcube.set()
82 90 suite_ctbkgcube.set()
83 91 suite_ctmapcube.set()
84 92 suite_ctcubemask.set()
... ... @@ -97,6 +105,7 @@ def test(installed=False):
97 105 suites.append(suite_ctskymap)
98 106 suites.append(suite_ctexpcube)
99 107 suites.append(suite_ctpsfcube)
  108 + suites.append(suite_ctedispcube)
100 109 suites.append(suite_ctbkgcube)
101 110 suites.append(suite_ctmapcube)
102 111 suites.append(suite_ctcubemask)
... ... @@ -120,28 +129,28 @@ def test(installed=False):
120 129 dirname = os.path.dirname(testdir)
121 130  
122 131 # Copy over test data and irf
123   - os.system("cp -r %s %s" % (dirname+"/data", "data"))
124   - os.system("cp -r %s %s" % (dirname+"/irf", "irf"))
  132 + os.system('cp -r %s %s' % (dirname+'/data', 'data'))
  133 + os.system('cp -r %s %s' % (dirname+'/irf', 'irf'))
125 134  
126 135 # Set PFILES environment variable
127 136 try:
128   - os.mkdir("pfiles")
  137 + os.mkdir('pfiles')
129 138 except:
130 139 pass
131   - os.environ['PFILES'] = "pfiles"
  140 + os.environ['PFILES'] = 'pfiles'
132 141  
133 142 # Copy over pfiles
134 143 if not installed:
135   - os.system("cp -r ../src/*/*.par pfiles/")
  144 + os.system('cp -r ../src/*/*.par pfiles/')
136 145 else:
137   - os.system("cp -r %s/syspfiles/*.par pfiles/" % (os.environ['CTOOLS']))
  146 + os.system('cp -r %s/syspfiles/*.par pfiles/' % (os.environ['CTOOLS']))
138 147  
139 148 # Run test suite
140 149 success = suites.run()
141 150  
142 151 # If we have a non-installed version then save test results
143 152 if not installed:
144   - suites.save("reports/ctools.xml")
  153 + suites.save('reports/ctools.xml')
145 154  
146 155 # Set return code
147 156 if success:
... ...