Commit 79814b0de764e52cc8094879c594e0d72b6606aa
1 parent
474ea1c6
developing test
Showing
3 changed files
with
34 additions
and
16 deletions
cscripts/obsutils.py
test/data/crab_onoff.xml
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?> | |
| 2 | +<source_library title="source library"> | |
| 3 | + <source name="Crab" type="PointSource"> | |
| 4 | + <spectrum type="PowerLaw"> | |
| 5 | + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 6 | + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 7 | + <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 8 | + </spectrum> | |
| 9 | + <spatialModel type="PointSource"> | |
| 10 | + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/> | |
| 11 | + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/> | |
| 12 | + </spatialModel> | |
| 13 | + </source> | |
| 14 | + <source name="Background" type="RadialAcceptance" instrument="CTAOnOff"> | |
| 15 | + <spectrum type="PowerLaw"> | |
| 16 | + <parameter name="Prefactor" scale="1e-6" value="61.8" min="0.0" max="1000.0" free="1"/> | |
| 17 | + <parameter name="Index" scale="-1" value="1.85" min="0.0" max="+5.0" free="1"/> | |
| 18 | + <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 19 | + </spectrum> | |
| 20 | + <radialModel type="Gaussian"> | |
| 21 | + <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/> | |
| 22 | + </radialModel> | |
| 23 | + </source> | |
| 24 | +</source_library> | ... | ... |
test/test_cslightcrv.py
| ... | ... | @@ -43,7 +43,8 @@ class Test(test): |
| 43 | 43 | test.__init__(self) |
| 44 | 44 | |
| 45 | 45 | # Add off-axis events for classical analysis |
| 46 | - self._myevents1 = self._datadir + '/crab_offaxis1.fits' | |
| 46 | + self._offaxis_events = self._datadir + '/crab_offaxis1.fits' | |
| 47 | + self._model_onoff = self._datadir + '/crab_onoff.xml' | |
| 47 | 48 | |
| 48 | 49 | # Return |
| 49 | 50 | return |
| ... | ... | @@ -240,24 +241,15 @@ class Test(test): |
| 240 | 241 | self._check_light_curve('cslightcrv_py4.fits', 2) |
| 241 | 242 | |
| 242 | 243 | # 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 | 244 | lcrv = cscripts.cslightcrv() |
| 256 | - lcrv['inobs'] = obs | |
| 245 | + lcrv['inobs'] = self._offaxis_events | |
| 246 | + lcrv['inmodel'] = self._model_onoff | |
| 257 | 247 | lcrv['srcname'] = 'Crab' |
| 248 | + lcrv['caldb'] = self._caldb | |
| 249 | + lcrv['irf'] = self._irf | |
| 258 | 250 | lcrv['tbinalg'] = 'LIN' |
| 259 | - lcrv['tmin'] = 6.3110887e8 | |
| 260 | - lcrv['tmax'] = 6.3110977e8 | |
| 251 | + lcrv['tmin'] = 'MJD 58849.0008' | |
| 252 | + lcrv['tmax'] = 'MJD 58849.0112' | |
| 261 | 253 | lcrv['tbins'] = 2 |
| 262 | 254 | lcrv['method'] = 'ONOFF' |
| 263 | 255 | lcrv['emin'] = 0.1 | ... | ... |