Commit 474ea1c6fc9693b8ea927165eaa51ad2f66f9098

Authored by Luigi Tibaldo
1 parent 2aab75b7

added test script

cscripts/obsutils.py
... ... @@ -808,6 +808,9 @@ def get_onoff_obs(cls, obs):
808 808 phagen['etruemin'] = cls['etruemin'].real()
809 809 phagen['etruemax'] = cls['etruemax'].real()
810 810 phagen['etruebins'] = cls['etruebins'].integer()
  811 + phagen['chatter'] = cls['chatter'].integer()
  812 + phagen['clobber'] = cls['clobber'].boolean()
  813 + phagen['debug'] = cls['debug'].boolean()
811 814 phagen.run()
812 815  
813 816 onoff_obs = phagen.obs().copy()
... ...
test/test_cslightcrv.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Add off-axis events for classical analysis
  46 + self._myevents1 = self._datadir + '/crab_offaxis1.fits'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -73,7 +76,7 @@ class Test(test):
73 76 ' inmodel="'+self._model+'" srcname="Crab"'+ \
74 77 ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
75 78 ' tbinalg="LIN" tmin="MJD 51544.50" tmax="MJD 51544.53"'+ \
76   - ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \
  79 + ' tbins=3 method="CUBE" enumbins=0 emin=0.1 emax=100.0'+ \
77 80 ' outfile="lightcurve_cmd1.fits"'+ \
78 81 ' logfile="cslightcrv_cmd1.log" chatter=1'
79 82  
... ... @@ -93,7 +96,7 @@ class Test(test):
93 96 ' inmodel="'+self._model+'" srcname="Crab"'+ \
94 97 ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
95 98 ' tbinalg="LIN" tmin="MJD 51544.50" tmax="MJD 51544.53"'+ \
96   - ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \
  99 + ' tbins=3 method="CUBE" enumbins=0 emin=0.1 emax=100.0'+ \
97 100 ' outfile="lightcurve_cmd1.fits"'+ \
98 101 ' logfile="cslightcrv_cmd2.log" debug=yes'
99 102  
... ... @@ -123,6 +126,7 @@ class Test(test):
123 126 lcrv['tmin'] = 'MJD 51544.50'
124 127 lcrv['tmax'] = 'MJD 51544.53'
125 128 lcrv['tbins'] = 3
  129 + lcrv['method'] = 'CUBE'
126 130 lcrv['enumbins'] = 0
127 131 lcrv['emin'] = 0.1
128 132 lcrv['emax'] = 100.0
... ... @@ -159,6 +163,7 @@ class Test(test):
159 163 lcrv['irf'] = self._irf
160 164 lcrv['tbinalg'] = 'FILE'
161 165 lcrv['tbinfile'] = 'cslightcrv_py2.dat'
  166 + lcrv['method'] = 'CUBE'
162 167 lcrv['enumbins'] = 0
163 168 lcrv['emin'] = 0.1
164 169 lcrv['emax'] = 100.0
... ... @@ -188,6 +193,7 @@ class Test(test):
188 193 lcrv['caldb'] = self._caldb
189 194 lcrv['irf'] = self._irf
190 195 lcrv['tbinalg'] = 'GTI'
  196 + lcrv['method'] = 'CUBE'
191 197 lcrv['enumbins'] = 0
192 198 lcrv['emin'] = 0.1
193 199 lcrv['emax'] = 100.0
... ... @@ -201,7 +207,7 @@ class Test(test):
201 207 # Check light curve
202 208 self._check_light_curve('cslightcrv_py3.fits', 1)
203 209  
204   - # Finally we set-up a binned cslightcrv
  210 + # Binned cslightcrv
205 211 lcrv = cscripts.cslightcrv()
206 212 lcrv['inobs'] = self._events
207 213 lcrv['inmodel'] = self._model
... ... @@ -212,6 +218,7 @@ class Test(test):
212 218 lcrv['tmin'] = 'MJD 51544.50'
213 219 lcrv['tmax'] = 'MJD 51544.53'
214 220 lcrv['tbins'] = 2
  221 + lcrv['method'] = 'CUBE'
215 222 lcrv['emin'] = 0.1
216 223 lcrv['emax'] = 100.0
217 224 lcrv['enumbins'] = 10
... ... @@ -232,6 +239,45 @@ class Test(test):
232 239 # Check light curve
233 240 self._check_light_curve('cslightcrv_py4.fits', 2)
234 241  
  242 + # cslightcrv with classical analysis
  243 +
  244 + # first we build an observation container to pass the model
  245 + # to csphagen that will change the background to OnOff
  246 + obs = gammalib.GObservations()
  247 + for s, events in enumerate([self._myevents1]):
  248 + run = gammalib.GCTAObservation(events)
  249 + run.id(str(s + 1))
  250 + run.response(self._irf, gammalib.GCaldb('cta', self._caldb))
  251 + run.model(gammalib.GModels(self._model))
  252 + obs.append(run)
  253 +
  254 + # set up cslightcrv
  255 + lcrv = cscripts.cslightcrv()
  256 + lcrv['inobs'] = obs
  257 + lcrv['srcname'] = 'Crab'
  258 + lcrv['tbinalg'] = 'LIN'
  259 + lcrv['tmin'] = 6.3110887e8
  260 + lcrv['tmax'] = 6.3110977e8
  261 + lcrv['tbins'] = 2
  262 + lcrv['method'] = 'ONOFF'
  263 + lcrv['emin'] = 0.1
  264 + lcrv['emax'] = 100.0
  265 + lcrv['enumbins'] = 10
  266 + lcrv['coordsys'] = 'CEL'
  267 + lcrv['xref'] = 83.63
  268 + lcrv['yref'] = 22.01
  269 + lcrv['rad'] = 0.2
  270 + lcrv['statistic'] = 'WSTAT'
  271 + lcrv['outfile'] = 'cslightcrv_py5.fits'
  272 + lcrv['logfile'] = 'cslightcrv_py5.log'
  273 + lcrv['chatter'] = 4
  274 +
  275 + # Execute cslightcrv script
  276 + lcrv.execute()
  277 +
  278 + # Check light curve
  279 + self._check_light_curve('cslightcrv_py5.fits', 2)
  280 +
235 281 # Return
236 282 return
237 283  
... ...