Commit ffcaa39fd72ca8c567bd21bb70a8ecfab0823036
1 parent
9644a959
bug fixes to address order param query
Showing
4 changed files
with
69 additions
and
9 deletions
cscripts/cslightcrv.par
| ... | ... | @@ -16,12 +16,13 @@ |
| 16 | 16 | # |
| 17 | 17 | # Input and output parameters |
| 18 | 18 | #============================ |
| 19 | -inobs, f, a, events.fits,,, "Input event list or observation definition XML file" | |
| 20 | -inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file" | |
| 21 | -srcname, s, a, Crab,,, "Source name" | |
| 22 | -caldb, s, a, prod2,,, "Calibration database" | |
| 23 | -irf, s, a, South_0.5h,,, "Instrument response function" | |
| 24 | -edisp, b, h, no,,, "Apply energy dispersion?" | |
| 19 | +inobs, f, a, events.fits,,, "Input event list or observation definition XML file" | |
| 20 | +inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file" | |
| 21 | +srcname, s, a, Crab,,, "Source name" | |
| 22 | +caldb, s, a, prod2,,, "Calibration database" | |
| 23 | +irf, s, a, South_0.5h,,, "Instrument response function" | |
| 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, lightcurve.fits,,, "Output light curve file" |
| 26 | 27 | |
| 27 | 28 | # |
| ... | ... | @@ -32,9 +33,10 @@ tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or ME |
| 32 | 33 | tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" |
| 33 | 34 | tbins, i, a, 5,1,10000, "Number of time bins" |
| 34 | 35 | tbinfile, f, a, NONE,,, "File defining the time binning" |
| 36 | +method, s, a, CUBE, CUBE|ONOFF,, "Analysis method" | |
| 35 | 37 | emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" |
| 36 | 38 | emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" |
| 37 | -enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned)" | |
| 39 | +enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for Cube analysis only)" | |
| 38 | 40 | coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" |
| 39 | 41 | proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" |
| 40 | 42 | xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)" |
| ... | ... | @@ -42,6 +44,14 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE |
| 42 | 44 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 43 | 45 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 44 | 46 | binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" |
| 47 | +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 48 | +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" | |
| 49 | +bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" | |
| 50 | +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" | |
| 51 | +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | |
| 52 | +etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" | |
| 53 | +etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" | |
| 54 | +etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" | |
| 45 | 55 | statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" |
| 46 | 56 | calc_ts, b, h, yes,,, "Compute TS value for each bin?" |
| 47 | 57 | calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" | ... | ... |
cscripts/cslightcrv.py
| ... | ... | @@ -75,6 +75,7 @@ class cslightcrv(ctools.csobservation): |
| 75 | 75 | self._srcname = '' |
| 76 | 76 | self._tbins = gammalib.GGti() |
| 77 | 77 | self._stacked = False |
| 78 | + self._onoff = False | |
| 78 | 79 | self._fits = gammalib.GFits() |
| 79 | 80 | |
| 80 | 81 | # Return |
| ... | ... | @@ -103,8 +104,14 @@ class cslightcrv(ctools.csobservation): |
| 103 | 104 | # Get time boundaries |
| 104 | 105 | self._tbins = self._create_tbounds() |
| 105 | 106 | |
| 107 | + # Set On/Off analysis flag and query relevant user parameters | |
| 108 | + self._onoff = self._is_onoff() | |
| 109 | + | |
| 110 | + # If cube analysis is selected | |
| 106 | 111 | # Set stacked analysis flag and query relevant user parameters |
| 107 | - self._stacked = self._is_stacked() | |
| 112 | + if not self._onoff: | |
| 113 | + self._stacked = self._is_stacked() | |
| 114 | + | |
| 108 | 115 | |
| 109 | 116 | # Query the hidden parameters, just in case |
| 110 | 117 | self['edisp'].boolean() |
| ... | ... | @@ -390,6 +397,39 @@ class cslightcrv(ctools.csobservation): |
| 390 | 397 | # Return new oberservation container |
| 391 | 398 | return new_obs |
| 392 | 399 | |
| 400 | + def _gen_onoff(self, obs): | |
| 401 | + """ | |
| 402 | + Create On/Off observations if On/Off analysis was requested | |
| 403 | + | |
| 404 | + Parameters | |
| 405 | + ---------- | |
| 406 | + obs : `~gammalib.GObservations` | |
| 407 | + Observation container | |
| 408 | + | |
| 409 | + Returns | |
| 410 | + ------- | |
| 411 | + obs : `~gammalib.GObservations` | |
| 412 | + Observation container with On/Off observations | |
| 413 | + """ | |
| 414 | + # Get new observation container with binned observation | |
| 415 | + new_obs = obsutils.get_onoff_obs(self, obs) | |
| 416 | + | |
| 417 | + # Extract models | |
| 418 | + models = new_obs.models() | |
| 419 | + | |
| 420 | + # Fix background models if required | |
| 421 | + if self['fix_bkg'].boolean(): | |
| 422 | + for model in models: | |
| 423 | + if model.classname() != 'GModelSky': | |
| 424 | + for par in model: | |
| 425 | + par.fix() | |
| 426 | + | |
| 427 | + # Put back models | |
| 428 | + new_obs.models(models) | |
| 429 | + | |
| 430 | + # Return new oberservation container | |
| 431 | + return new_obs | |
| 432 | + | |
| 393 | 433 | |
| 394 | 434 | # Public methods |
| 395 | 435 | def run(self): |
| ... | ... | @@ -488,6 +528,10 @@ class cslightcrv(ctools.csobservation): |
| 488 | 528 | # an observation container with a single stacked observation. |
| 489 | 529 | if self._stacked: |
| 490 | 530 | obs = self._bin_observation(obs) |
| 531 | + # Otherwise if On/Off analysis is requested generate | |
| 532 | + # the On/Off observations and response | |
| 533 | + if self._onoff: | |
| 534 | + obs = self._gen_onoff(obs) | |
| 491 | 535 | |
| 492 | 536 | # Header |
| 493 | 537 | self._log_header3(gammalib.EXPLICIT, 'Fitting the data') | ... | ... |
cscripts/obsutils.py
src/support/ctool.cpp
| ... | ... | @@ -1216,6 +1216,12 @@ bool ctool::is_onoff(void) |
| 1216 | 1216 | onoff = true; |
| 1217 | 1217 | //query csphagen parameters |
| 1218 | 1218 | (*this)["inexclusion"].filename(); |
| 1219 | + (*this)["emin"].real(); | |
| 1220 | + (*this)["emax"].real(); | |
| 1221 | + (*this)["enumbins"].integer(); | |
| 1222 | + (*this)["coordsys"].string(); | |
| 1223 | + (*this)["xref"].real(); | |
| 1224 | + (*this)["yref"].real(); | |
| 1219 | 1225 | if ((*this)["srcshape"].string() == "CIRCLE"){ |
| 1220 | 1226 | (*this)["rad"].real(); |
| 1221 | 1227 | } | ... | ... |