From 77f1091b9c2457bd0b93a57fd37cd185cd6e8a80 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Mon, 1 Aug 2016 23:11:55 +0200 Subject: [PATCH] Reduce duration of unit test --- examples/pipeline_binned_disk.py | 3 ++- examples/pipeline_binned_mem.py | 2 +- examples/pipeline_stacked_disk.py | 3 ++- examples/pipeline_stacked_mem.py | 2 +- test/test_cspull.py | 30 +++++++++++++++--------------- test/test_ctmapcube.py | 24 ++++++++++++------------ test/test_cttsmap.py | 20 ++++++++++---------- test/test_examples.py.in | 2 +- 8 files changed, 44 insertions(+), 42 deletions(-) diff --git a/examples/pipeline_binned_disk.py b/examples/pipeline_binned_disk.py index 4bbbca8..a6dffa7 100755 --- a/examples/pipeline_binned_disk.py +++ b/examples/pipeline_binned_disk.py @@ -155,4 +155,5 @@ if __name__ == '__main__': obs.models(gammalib.GModels(datadir+'/crab.xml')) # Run analysis pipeline - run_pipeline(obs, model=datadir+'/crab.xml') + run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, + nypix=40, binsz=0.1) diff --git a/examples/pipeline_binned_mem.py b/examples/pipeline_binned_mem.py index 9abd992..30b0639 100755 --- a/examples/pipeline_binned_mem.py +++ b/examples/pipeline_binned_mem.py @@ -126,4 +126,4 @@ if __name__ == '__main__': obs.models(gammalib.GModels(datadir+'/crab.xml')) # Run analysis pipeline - run_pipeline(obs) + run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) diff --git a/examples/pipeline_stacked_disk.py b/examples/pipeline_stacked_disk.py index 63b8951..008b3cf 100755 --- a/examples/pipeline_stacked_disk.py +++ b/examples/pipeline_stacked_disk.py @@ -205,4 +205,5 @@ if __name__ == '__main__': obs.models(gammalib.GModels(datadir+'/crab.xml')) # Run analysis pipeline - run_pipeline(obs, model=datadir+'/crab.xml') + run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, + nypix=40, binsz=0.1) diff --git a/examples/pipeline_stacked_mem.py b/examples/pipeline_stacked_mem.py index 9e91f5b..083b64e 100755 --- a/examples/pipeline_stacked_mem.py +++ b/examples/pipeline_stacked_mem.py @@ -178,4 +178,4 @@ if __name__ == '__main__': obs.models(gammalib.GModels(datadir+'/crab.xml')) # Run analysis pipeline - run_pipeline(obs) + run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) diff --git a/test/test_cspull.py b/test/test_cspull.py index 66e49b6..2a32961 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -146,7 +146,7 @@ class Test(test): pull = cscripts.cspull() pull['inmodel'] = self._model pull['outfile'] = 'cspull_py2.dat' - pull['ntrials'] = 2 + pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 @@ -157,8 +157,8 @@ class Test(test): pull['tmax'] = 100.0 pull['deadc'] = 0.95 pull['rad'] = 5.0 - pull['npix'] = 100 - pull['binsz'] = 0.02 + pull['npix'] = 20 + pull['binsz'] = 0.2 pull['coordsys'] = 'CEL' pull['proj'] = 'TAN' pull['logfile'] = 'cspull_py2.log' @@ -168,14 +168,14 @@ class Test(test): pull.execute() # Check pull distribution file - self._check_pull_file('cspull_py2.dat') + self._check_pull_file('cspull_py2.dat', rows=2) # Set-up cspull from event list pull = cscripts.cspull() pull['inobs'] = self._events pull['inmodel'] = self._model pull['outfile'] = 'cspull_py3.dat' - pull['ntrials'] = 2 + pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 @@ -186,7 +186,7 @@ class Test(test): pull.execute() # Check pull distribution file - self._check_pull_file('cspull_py3.dat') + self._check_pull_file('cspull_py3.dat', rows=2) # Build observation container with unbinned observation cta = gammalib.GCTAObservation(self._events) @@ -197,7 +197,7 @@ class Test(test): pull = cscripts.cspull(obs) pull['inmodel'] = self._model pull['outfile'] = 'cspull_py4.dat' - pull['ntrials'] = 2 + pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 @@ -208,7 +208,7 @@ class Test(test): pull.execute() # Check pull distribution file - self._check_pull_file('cspull_py4.dat') + self._check_pull_file('cspull_py4.dat', rows=2) # Set-up stacked cspull with one observation where response cubes # are specified in the input observation @@ -216,7 +216,7 @@ class Test(test): pull['inobs'] = self._inobs pull['inmodel'] = self._stacked_model pull['outfile'] = 'cspull_py5.dat' - pull['ntrials'] = 2 + pull['ntrials'] = 1 pull['enumbins'] = 0 pull['logfile'] = 'cspull_py5.log' pull['chatter'] = 4 @@ -225,7 +225,7 @@ class Test(test): pull.execute() # Check pull distribution file - self._check_pull_file('cspull_py5.dat') + self._check_pull_file('cspull_py5.dat', rows=2) # Set-up stacked cspull with two observations from which response # cubes will be computed internally. The IRFs are also specified @@ -235,7 +235,7 @@ class Test(test): pull['inobs'] = self._inobs_two pull['inmodel'] = self._model pull['outfile'] = 'cspull_py6.dat' - pull['ntrials'] = 2 + pull['ntrials'] = 1 pull['emin'] = 0.02 pull['emax'] = 100.0 pull['enumbins'] = 10 @@ -250,13 +250,13 @@ class Test(test): pull.execute() # Check pull distribution file - self._check_pull_file('cspull_py6.dat') + self._check_pull_file('cspull_py6.dat', rows=2) # Return return # Check pull file - def _check_pull_file(self, filename): + def _check_pull_file(self, filename, rows=3): """ Check pull file """ @@ -264,8 +264,8 @@ class Test(test): pulls = gammalib.GCsv(filename) # Check dimensions - self.test_value(pulls.nrows(), 3, - 'Check for 3 rows in pull file') + self.test_value(pulls.nrows(), rows, + 'Check for number of rows in pull file') # Return return diff --git a/test/test_ctmapcube.py b/test/test_ctmapcube.py index 22137ee..e5604db 100644 --- a/test/test_ctmapcube.py +++ b/test/test_ctmapcube.py @@ -71,8 +71,8 @@ class Test(test): # Setup ctmapcube command cmd = ctmapcube+' inmodel="'+self._model+'"'+ \ ' outcube="ctmapcube_cmd1.fits"'+\ - ' emin=0.1 emax=100.0 enumbins=20 ebinalg=LOG'+ \ - ' nxpix=200 nypix=200 binsz=0.02 coordsys=CEL'+ \ + ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ + ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ ' xref=83.63 yref=22.01 proj=CAR'+ \ ' logfile="ctmapcube_cmd1.log" chatter=1' @@ -90,8 +90,8 @@ class Test(test): # Setup ctmapcube command cmd = ctmapcube+' inmodel="events_that_do_not_exist.fits"'+ \ ' outcube="ctmapcube_cmd2.fits"'+\ - ' emin=0.1 emax=100.0 enumbins=20 ebinalg=LOG'+ \ - ' nxpix=200 nypix=200 binsz=0.02 coordsys=CEL'+ \ + ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ + ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ ' xref=83.63 yref=22.01 proj=CAR'+ \ ' logfile="ctmapcube_cmd2.log"' @@ -114,10 +114,10 @@ class Test(test): mapcube['ebinalg'] = 'LOG' mapcube['emin'] = 0.1 mapcube['emax'] = 100.0 - mapcube['enumbins'] = 20 - mapcube['nxpix'] = 200 - mapcube['nypix'] = 200 - mapcube['binsz'] = 0.02 + mapcube['enumbins'] = 10 + mapcube['nxpix'] = 100 + mapcube['nypix'] = 100 + mapcube['binsz'] = 0.04 mapcube['coordsys'] = 'CEL' mapcube['proj'] = 'CAR' mapcube['xref'] = 83.63 @@ -152,12 +152,12 @@ class Test(test): cube = gammalib.GModelSpatialDiffuseCube(filename) # Test map cube - #self.test_value(cube.maps(), 20, "20 maps") - #self.test_value(cube.pixels(), 40000, "40000 map pixels") + #self.test_value(cube.maps(), 10, "10 maps") + #self.test_value(cube.pixels(), 10000, "10000 map pixels") # The map cube is not loaded by default !!!! We should add the method so that # the attributes are known !!!! - self.test_value(cube.maps(), 0, '20 maps') - self.test_value(cube.pixels(), 0, '40000 map pixels') + self.test_value(cube.maps(), 0, '10 maps') + self.test_value(cube.pixels(), 0, '10000 map pixels') # Return return diff --git a/test/test_cttsmap.py b/test/test_cttsmap.py index 925694c..e81ad49 100755 --- a/test/test_cttsmap.py +++ b/test/test_cttsmap.py @@ -69,7 +69,7 @@ class Test(test): ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmap="cttsmap_cmd1.fits"'+ \ - ' nxpix=5 nypix=5 binsz=0.02'+ \ + ' nxpix=3 nypix=3 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ ' logfile="cttsmap_cmd1.log" chatter=1' @@ -89,7 +89,7 @@ class Test(test): ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmap="cttsmap_cmd2.fits"'+ \ - ' nxpix=5 nypix=5 binsz=0.02'+ \ + ' nxpix=3 nypix=3 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ ' logfile="cttsmap_cmd2.log" chatter=2' @@ -113,8 +113,8 @@ class Test(test): tsmap['caldb'] = self._caldb tsmap['irf'] = self._irf tsmap['outmap'] = 'cttsmap_py1.fits' - tsmap['nxpix'] = 5 - tsmap['nypix'] = 5 + tsmap['nxpix'] = 3 + tsmap['nypix'] = 3 tsmap['binsz'] = 0.02 tsmap['coordsys'] = 'CEL' tsmap['proj'] = 'CAR' @@ -149,14 +149,14 @@ class Test(test): # Check dimensions self.test_value(ts.naxis(), 2, 'Check for 2 dimensions') - self.test_value(ts.naxes(0), 5, 'Check for 5 pixels in X') - self.test_value(ts.naxes(1), 5, 'Check for 5 pixels in Y') + self.test_value(ts.naxes(0), 3, 'Check for 3 pixels in X') + self.test_value(ts.naxes(1), 3, 'Check for 3 pixels in Y') self.test_value(prefactor.naxis(), 2, 'Check for 2 dimensions') - self.test_value(prefactor.naxes(0), 5, 'Check for 5 pixels in X') - self.test_value(prefactor.naxes(1), 5, 'Check for 5 pixels in Y') + self.test_value(prefactor.naxes(0), 3, 'Check for 3 pixels in X') + self.test_value(prefactor.naxes(1), 3, 'Check for 3 pixels in Y') self.test_value(index.naxis(), 2, 'Check for 2 dimensions') - self.test_value(index.naxes(0), 5, 'Check for 5 pixels in X') - self.test_value(index.naxes(1), 5, 'Check for 5 pixels in Y') + self.test_value(index.naxes(0), 3, 'Check for 3 pixels in X') + self.test_value(index.naxes(1), 3, 'Check for 3 pixels in Y') # Return return diff --git a/test/test_examples.py.in b/test/test_examples.py.in index 1c2142d..d39aff9 100755 --- a/test/test_examples.py.in +++ b/test/test_examples.py.in @@ -186,7 +186,7 @@ class Test(gammalib.GPythonTestSuite): Test make_ts_distributions """ # Set arguments - args = '-n 2 -e 0 -t 1800 -d %s' % self._datadir + args = '-n 1 -e 0 -t 100 -d %s' % self._datadir # Execute script self._execute_python('make_ts_distributions', args=args) -- libgit2 0.21.4