Commit caceb19aa6674326cc053d6e39fac615e68f8286
1 parent
6540305d
Add "use_irf_bkg" parameter to cslightcrv
Showing
7 changed files
with
82 additions
and
55 deletions
ChangeLog
| 1 | -2018-09-11 | |
| 1 | +2018-09-19 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.6.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Add "use_irf_bkg" parameter to cslightcrv | |
| 6 | 7 | Add "like_accuracy" parameter to likelihood tools and scripts (#2662) |
| 7 | 8 | Do not skip bins with zero counts in csspec (#2671) |
| 8 | 9 | Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in ctools 1.6.0 |
| 2 | 2 | |
| 3 | -11 September 2018 | |
| 3 | +19 September 2018 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -208,6 +208,8 @@ None |
| 208 | 208 | |
| 209 | 209 | cslightcrv - Generate light curve |
| 210 | 210 | --------------------------------- |
| 211 | +Add hidden "use_irf_bkg" parameter for forwarding to csphagen. | |
| 212 | + | |
| 211 | 213 | Add hidden "nthreads" parameter and implement parallelisation of light |
| 212 | 214 | curve computation (#2421). |
| 213 | 215 | ... | ... |
cscripts/cslightcrv.par
| ... | ... | @@ -28,36 +28,37 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file" |
| 28 | 28 | # |
| 29 | 29 | # Script parameters |
| 30 | 30 | #================== |
| 31 | -tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" | |
| 32 | -tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" | |
| 33 | -tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" | |
| 34 | -mjdref, r, h, 51544.5,,, "Reference MJD for MET" | |
| 35 | -tbins, i, a, 5,1,10000, "Number of time bins" | |
| 36 | -tbinfile, f, a, NONE,,, "File defining the time binning" | |
| 37 | -method, s, a, 3D, 3D|ONOFF,, "Analysis method" | |
| 38 | -emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" | |
| 39 | -emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" | |
| 40 | -enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for 3D analysis only)" | |
| 41 | -coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" | |
| 42 | -proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 43 | -xref, r, a, 83.63,0,360, "First coordinate of image/source region center in degrees (RA or galactic l)" | |
| 44 | -yref, r, a, 22.51,-90,90, "Second coordinate of image/source region center in degrees (DEC or galactic b)" | |
| 45 | -nxpix, i, a, 200,,, "Size of the X axis in pixels" | |
| 46 | -nypix, i, a, 200,,, "Size of the Y axis in pixels" | |
| 47 | -binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" | |
| 48 | -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 49 | -rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" | |
| 50 | -bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" | |
| 51 | -bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" | |
| 52 | -maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | |
| 53 | -etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" | |
| 54 | -etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" | |
| 55 | -etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" | |
| 56 | -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" | |
| 57 | -calc_ts, b, h, yes,,, "Compute TS value for each bin?" | |
| 58 | -calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" | |
| 59 | -fix_srcs, b, h, yes,,, "Fix other sky model parameters?" | |
| 60 | -fix_bkg, b, h, no,,, "Fix background model parameters?" | |
| 31 | +tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" | |
| 32 | +tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" | |
| 33 | +tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" | |
| 34 | +mjdref, r, h, 51544.5,,, "Reference MJD for MET" | |
| 35 | +tbins, i, a, 5,1,10000, "Number of time bins" | |
| 36 | +tbinfile, f, a, NONE,,, "File defining the time binning" | |
| 37 | +method, s, a, 3D, 3D|ONOFF,, "Analysis method" | |
| 38 | +emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" | |
| 39 | +emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" | |
| 40 | +enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for 3D analysis only)" | |
| 41 | +coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" | |
| 42 | +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 43 | +xref, r, a, 83.63,0,360, "First coordinate of image/source region center in degrees (RA or galactic l)" | |
| 44 | +yref, r, a, 22.51,-90,90, "Second coordinate of image/source region center in degrees (DEC or galactic b)" | |
| 45 | +nxpix, i, a, 200,,, "Size of the X axis in pixels" | |
| 46 | +nypix, i, a, 200,,, "Size of the Y axis in pixels" | |
| 47 | +binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" | |
| 48 | +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 49 | +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" | |
| 50 | +bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" | |
| 51 | +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" | |
| 52 | +use_irf_bkg, b, h, yes,,, "Use IRF background template?" | |
| 53 | +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | |
| 54 | +etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" | |
| 55 | +etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" | |
| 56 | +etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" | |
| 57 | +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" | |
| 58 | +calc_ts, b, h, yes,,, "Compute TS value for each bin?" | |
| 59 | +calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" | |
| 60 | +fix_srcs, b, h, yes,,, "Fix other sky model parameters?" | |
| 61 | +fix_bkg, b, h, no,,, "Fix background model parameters?" | |
| 61 | 62 | |
| 62 | 63 | # |
| 63 | 64 | # Standard parameters | ... | ... |
cscripts/csphagen.py
| ... | ... | @@ -463,14 +463,14 @@ class csphagen(ctools.csobservation): |
| 463 | 463 | On/Off spectra, background regions, observation id |
| 464 | 464 | """ |
| 465 | 465 | # Retrieve observation from container |
| 466 | - obs = self.obs()[i] | |
| 466 | + onoff = None | |
| 467 | + bkg_reg = None | |
| 468 | + obs = self.obs()[i] | |
| 467 | 469 | |
| 468 | 470 | # Skip non CTA observations |
| 469 | 471 | if obs.classname() != 'GCTAObservation': |
| 470 | 472 | self._log_string(gammalib.NORMAL, 'Skip %s observation "%s"' % \ |
| 471 | 473 | (obs.instrument(), obs.id())) |
| 472 | - onoff = 0 | |
| 473 | - bkg_reg = 0 | |
| 474 | 474 | |
| 475 | 475 | # Otherwise calculate On/Off spectra |
| 476 | 476 | else: |
| ... | ... | @@ -527,15 +527,18 @@ class csphagen(ctools.csobservation): |
| 527 | 527 | outobs : `~gammalib.GObservations` |
| 528 | 528 | Observation container with result appended |
| 529 | 529 | """ |
| 530 | - # If the results contain an On/Off observation | |
| 531 | - if result['onoff'].classname() == 'GCTAOnOffObservation': | |
| 532 | - | |
| 533 | - # Append observation to observation container | |
| 534 | - outobs.append(result['onoff']) | |
| 535 | - | |
| 536 | - # Append background regions | |
| 537 | - self._bkg_regs.append({'regions': result['bkg_reg'], | |
| 538 | - 'id': result['id']}) | |
| 530 | + # Continue only if result is valid | |
| 531 | + if result['onoff'] != None: | |
| 532 | + | |
| 533 | + # If the results contain an On/Off observation | |
| 534 | + if result['onoff'].classname() == 'GCTAOnOffObservation': | |
| 535 | + | |
| 536 | + # Append observation to observation container | |
| 537 | + outobs.append(result['onoff']) | |
| 538 | + | |
| 539 | + # Append background regions | |
| 540 | + self._bkg_regs.append({'regions': result['bkg_reg'], | |
| 541 | + 'id': result['id']}) | |
| 539 | 542 | |
| 540 | 543 | # Return observation container |
| 541 | 544 | return outobs | ... | ... |
cscripts/obsutils.py
| ... | ... | @@ -799,12 +799,13 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 799 | 799 | if cls._logExplicit(): |
| 800 | 800 | cls._log.header3('Creating On/Off observations') |
| 801 | 801 | |
| 802 | - # Initialise inmodel, srcname and inexclusion | |
| 802 | + # Initialise inmodel, srcname, inexclusion and use_irf_bkg | |
| 803 | 803 | inmodel = 'NONE' |
| 804 | 804 | srcname = '' |
| 805 | 805 | inexclusion = 'NONE' |
| 806 | + use_irf_bkg = True | |
| 806 | 807 | |
| 807 | - # Set inmodel, srcname and inexclusion if possible | |
| 808 | + # Set inmodel, srcname, inexclusion and use_irf_bkg if possible | |
| 808 | 809 | if 'inmodel' in cls: |
| 809 | 810 | if cls['inmodel'].is_valid(): |
| 810 | 811 | inmodel = cls['inmodel'].value() |
| ... | ... | @@ -813,6 +814,8 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 813 | 814 | if 'inexclusion' in cls: |
| 814 | 815 | if cls['inexclusion'].is_valid(): |
| 815 | 816 | inexclusion = cls['inexclusion'].value() |
| 817 | + if cls.has_par('use_irf_bkg'): | |
| 818 | + use_irf_bkg = cls['use_irf_bkg'].boolean() | |
| 816 | 819 | |
| 817 | 820 | # Create On/Off observations |
| 818 | 821 | phagen = cscripts.csphagen(obs) |
| ... | ... | @@ -836,15 +839,16 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 836 | 839 | phagen['bkgmethod'] = cls['bkgmethod'].string() |
| 837 | 840 | if cls['bkgmethod'].string() == 'REFLECTED': |
| 838 | 841 | phagen['bkgregmin'] = cls['bkgregmin'].integer() |
| 839 | - phagen['maxoffset'] = cls['maxoffset'].real() | |
| 840 | - phagen['stack'] = True | |
| 841 | - phagen['etruemin'] = cls['etruemin'].real() | |
| 842 | - phagen['etruemax'] = cls['etruemax'].real() | |
| 843 | - phagen['etruebins'] = cls['etruebins'].integer() | |
| 844 | - phagen['chatter'] = cls['chatter'].integer() | |
| 845 | - phagen['clobber'] = cls['clobber'].boolean() | |
| 846 | - phagen['debug'] = cls['debug'].boolean() | |
| 847 | - phagen['nthreads'] = nthreads | |
| 842 | + phagen['use_irf_bkg'] = use_irf_bkg | |
| 843 | + phagen['maxoffset'] = cls['maxoffset'].real() | |
| 844 | + phagen['stack'] = True | |
| 845 | + phagen['etruemin'] = cls['etruemin'].real() | |
| 846 | + phagen['etruemax'] = cls['etruemax'].real() | |
| 847 | + phagen['etruebins'] = cls['etruebins'].integer() | |
| 848 | + phagen['chatter'] = cls['chatter'].integer() | |
| 849 | + phagen['clobber'] = cls['clobber'].boolean() | |
| 850 | + phagen['debug'] = cls['debug'].boolean() | |
| 851 | + phagen['nthreads'] = nthreads | |
| 848 | 852 | phagen.run() |
| 849 | 853 | |
| 850 | 854 | # Clone resulting observation container | ... | ... |
doc/source/admin/release_history/1.6.rst
| ... | ... | @@ -32,6 +32,7 @@ Bug fixes |
| 32 | 32 | Improvements |
| 33 | 33 | ------------ |
| 34 | 34 | |
| 35 | +* Add ``use_irf_bkg`` parameter to :ref:`cslightcrv` | |
| 35 | 36 | * [`2671 <https://cta-redmine.irap.omp.eu/issues/2671>`_] - |
| 36 | 37 | Do not skip bins with zero counts in :ref:`csspec` |
| 37 | 38 | * [`2670 <https://cta-redmine.irap.omp.eu/issues/2670>`_] - | ... | ... |
doc/source/users/reference_manual/cslightcrv.rst
| ... | ... | @@ -144,6 +144,21 @@ General parameters |
| 144 | 144 | ``ONOFF`` analysis. If this number of background regions is not available the |
| 145 | 145 | observation is skipped. |
| 146 | 146 | |
| 147 | +``(use_irf_bkg = yes) [boolean]`` | |
| 148 | + Specifies whether the IRF background template should be used for the | |
| 149 | + computation of the ``alpha`` parameter and the predicted background rate in | |
| 150 | + the Off region that is stored in the ``BACKRESP`` column of the Off spectrum | |
| 151 | + when using the ``ONOFF`` method. | |
| 152 | + | |
| 153 | + If the parameter is set to ``no`` the IRF background template is not used and | |
| 154 | + the background rate is assumed identical within the On and Off regions. This | |
| 155 | + is the classical IACT analysis method that is used when using reflected Off | |
| 156 | + regions. In that case the ``alpha`` parameter becomes independent of energy | |
| 157 | + and only reflects the ratio between the solid angles of the On and Off | |
| 158 | + regions. The ``BACKRESP`` column in the Off spectrum will be filled with zeros. | |
| 159 | + The data need to be fitted with the ``wstat`` statistic, fitting with ``cstat`` | |
| 160 | + will not work. | |
| 161 | + | |
| 147 | 162 | ``(maxoffset = 4.0) [real]`` |
| 148 | 163 | Maximum offset in degrees of source from camera center to accept the |
| 149 | 164 | observation for On/Off analysis. | ... | ... |