Commit e0aa6658892705687b35d28708cb377f2595a6de

Authored by Luigi Tibaldo
1 parent 5e827cf5

first crack at csphasecrv

cscripts/cslightcrv.py
... ... @@ -74,8 +74,8 @@ class cslightcrv(ctools.csobservation):
74 74 # Initialise some members
75 75 self._srcname = ''
76 76 self._tbins = gammalib.GGti()
  77 + self._onoff = False
77 78 self._stacked = False
78   - self._onoff = False
79 79 self._fits = gammalib.GFits()
80 80  
81 81 # Return
... ...
cscripts/csphasecrv.par
... ... @@ -21,7 +21,8 @@ inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML fi
21 21 srcname, s, a, Crab,,, "Source name"
22 22 caldb, s, a, prod2,,, "Calibration database"
23 23 irf, s, a, South_0.5h,,, "Instrument response function"
24   -edisp, b, h, no,,, "Apply energy dispersion?"
  24 +inexclusion, f, h, NONE,,, "Sky map of exclusion regions for On/Off analysis"
  25 +edisp, b, h, no,,, "Apply energy dispersion in Cube analysis?"
25 26 outfile, f, a, phasecrv.fits,,, "Output fits file name."
26 27  
27 28 #
... ... @@ -30,9 +31,10 @@ outfile, f, a, phasecrv.fits,,, "Output fits file name."
30 31 phbinalg, s, a, LIN,LIN|FILE,, "Algorithm for defining phase bins"
31 32 phbins, i, a, 5,1,10000, "Number of phase bins"
32 33 phbinfile, f, a, NONE,,, "File defining the phase binning"
  34 +method, s, a, CUBE, CUBE|ONOFF,, "Analysis method"
33 35 emin, r, a, 0.1,,, "Lower energy limit of events (TeV)"
34 36 emax, r, a, 100.0,,, "Upper energy limit of events (TeV)"
35   -enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned)"
  37 +enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for Cube analysis only))"
36 38 coordsys, s, a, CEL,CEL|GAL,, "Coordinate System"
37 39 proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method"
38 40 xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)"
... ... @@ -40,6 +42,14 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE
40 42 nxpix, i, a, 200,,, "Size of the X axis in pixels"
41 43 nypix, i, a, 200,,, "Size of the Y axis in pixels"
42 44 binsz, r, a, 0.02,,, "Pixel size (deg/pixel)"
  45 +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region"
  46 +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)"
  47 +bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation"
  48 +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions"
  49 +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation"
  50 +etruemin, r, h, 0.01,,, "Minimum true energy (TeV)"
  51 +etruemax, r, h, 300.0,,, "Maximum true energy (TeV)"
  52 +etruebins, i, h, 30,,, "Number of bins per decade for true energy bins"
43 53 statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
44 54  
45 55 #
... ...
cscripts/csphasecrv.py
... ... @@ -63,6 +63,7 @@ class csphasecrv(ctools.csobservation):
63 63 # [[ph1min,ph1max], [ph2min,ph2max],..]
64 64 self._srcname = ''
65 65 self._phbins = [[0.0,1.0]]
  66 + self._onoff = False
66 67 self._stacked = False
67 68 self._fits = gammalib.GFits()
68 69 self._fitmodels = {}
... ... @@ -92,8 +93,13 @@ class csphasecrv(ctools.csobservation):
92 93 # Get phase boundaries
93 94 self._phbins = self._create_tbounds()
94 95  
  96 + # Set On/Off analysis flag and query relevant user parameters
  97 + self._onoff = self._is_onoff()
  98 +
  99 + # If cube analysis is selected
95 100 # Set stacked analysis flag and query relevant user parameters
96   - self._stacked = self._is_stacked()
  101 + if not self._onoff:
  102 + self._stacked = self._is_stacked()
97 103  
98 104 # Query the hidden parameters, just in case
99 105 self['edisp'].boolean()
... ... @@ -355,10 +361,13 @@ class csphasecrv(ctools.csobservation):
355 361 select.obs()[i].id(oldid+'_'+str(phbin[0])+'-'+str(phbin[1]))
356 362 obs = select.obs()
357 363  
358   - # If a stacked analysis is requested then bin the events
  364 + # If an On/Off analysis is requested generate the On/Off observations
  365 + if self._onoff:
  366 + obs = obsutils.get_onoff_obs(self, select.obs())
  367 + # Otherwise, if stacked analysis is requested then bin the events
359 368 # and compute the stacked response functions and setup
360 369 # an observation container with a single stacked observation.
361   - if self._stacked:
  370 + elif self._stacked:
362 371 obs = obsutils.get_stacked_obs(self, select.obs())
363 372  
364 373 # Header
... ...