Commit 2124dfc09ee9af4cfca911318e7968a51613ed04

Authored by Luigi Tibaldo
1 parent 7a89f7f1

testing for csphasecrv including On/Off analysis

test/data/crab_offaxis1.fits.gz
No preview for this file type
test/test_csphasecrv.py
@@ -44,6 +44,8 @@ class Test(test): @@ -44,6 +44,8 @@ class Test(test):
44 44
45 # Set test data 45 # Set test data
46 self._phased_events = self._datadir + '/phased_events.fits' 46 self._phased_events = self._datadir + '/phased_events.fits'
  47 + self._offaxis_events = self._datadir + '/crab_offaxis1.fits'
  48 + self._model_onoff = self._datadir + '/crab_onoff.xml'
47 49
48 # Return 50 # Return
49 return 51 return
@@ -207,7 +209,7 @@ class Test(test): @@ -207,7 +209,7 @@ class Test(test):
207 # Check phase curve 209 # Check phase curve
208 self._check_phase_curve('csphasecrv_py3.fits', 5) 210 self._check_phase_curve('csphasecrv_py3.fits', 5)
209 211
210 - # Finally we set-up a binned csphasecrv 212 + # Binned csphasecrv
211 pcrv = cscripts.csphasecrv() 213 pcrv = cscripts.csphasecrv()
212 pcrv['inobs'] = self._phased_events 214 pcrv['inobs'] = self._phased_events
213 pcrv['inmodel'] = self._model 215 pcrv['inmodel'] = self._model
@@ -238,6 +240,35 @@ class Test(test): @@ -238,6 +240,35 @@ class Test(test):
238 # Check phase curve 240 # Check phase curve
239 self._check_phase_curve('csphasecrv_py4.fits', 2) 241 self._check_phase_curve('csphasecrv_py4.fits', 2)
240 242
  243 + # On/Off csphasecrv
  244 + pcrv = cscripts.csphasecrv()
  245 + pcrv['inobs'] = self._offaxis_events
  246 + pcrv['inmodel'] = self._model_onoff
  247 + pcrv['srcname'] = 'Crab'
  248 + pcrv['caldb'] = self._caldb
  249 + pcrv['irf'] = self._irf
  250 + pcrv['phbinalg'] = 'LIN'
  251 + pcrv['phbins'] = 2
  252 + pcrv['method'] = 'ONOFF'
  253 + pcrv['statistic'] = 'WSTAT'
  254 + pcrv['emin'] = 0.1
  255 + pcrv['emax'] = 100.0
  256 + pcrv['enumbins'] = 10
  257 + pcrv['coordsys'] = 'CEL'
  258 + pcrv['xref'] = 83.63
  259 + pcrv['yref'] = 22.01
  260 + pcrv['rad'] = 0.2
  261 + pcrv['outfile'] = 'csphasecrv_py5.fits'
  262 + pcrv['logfile'] = 'csphasecrv_py5.log'
  263 + pcrv['chatter'] = 4
  264 +
  265 + # Execute csphasecrv script
  266 + pcrv.logFileOpen() # Make sure we get a log file
  267 + pcrv.execute()
  268 +
  269 + # Check phase curve
  270 + self._check_phase_curve('csphasecrv_py5.fits', 2)
  271 +
241 # Return 272 # Return
242 return 273 return
243 274
@@ -271,6 +302,12 @@ class Test(test): @@ -271,6 +302,12 @@ class Test(test):
271 self.test_assert(table.contains(col), 302 self.test_assert(table.contains(col),
272 'FITS file contains "'+col+'" column') 303 'FITS file contains "'+col+'" column')
273 304
  305 + # Check that table has been filled
  306 + # Prefactor has right order of magnitude
  307 + for s in range(table.nrows()):
  308 + self.test_value(table['Prefactor'][s], 4.e-16, 3.e-16,
  309 + 'Check prefactor value')
  310 +
274 # Close FITS file 311 # Close FITS file
275 fits.close() 312 fits.close()
276 313