diff --git a/ChangeLog b/ChangeLog index 7d45c53..449d256 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Apply event bin weighting in ctmodel for stacked computation (#2721) Enable ctbin to produce counts cubes for a joint binned analysis (#2714) Add Jupyter notebooks for H.E.S.S. DR1 (#2712) + csphagen now supports any kind of background model (#2710) Add code generator (#2709) Add csbkgmodel script (#2694) Compute DETX and DETY in ctmodel if they are not available (#2694) @@ -16,11 +17,11 @@ Account for varying energy thresholds in ctbin weight computation (#2685) Add ctbkgcube::cntcube() method (#2685) Avoid ctselect error in case that RoI radius is unchanged (#2682) - Add "use_irf_bkg" parameter to cslightcrv + Add "use_model_bkg" parameter to cslightcrv Add "like_accuracy" parameter to likelihood tools and scripts (#2662) Do not skip bins with zero counts in csspec (#2671) Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670) - Add hidden "use_irf_bkg" parameter to csphagen (#2659) + Add hidden "use_model_bkg" parameter to csphagen (#2659) Use full RMF true energy range for On/Off analysis in csspec (#2656) Defer import of ROOT module in csroot2caldb to run method (#2652) Transparently update parameter files (#2513) diff --git a/NEWS b/NEWS index 0f18261..f314b1f 100755 --- a/NEWS +++ b/NEWS @@ -270,7 +270,7 @@ None cslightcrv - Generate light curve --------------------------------- -Add hidden "use_irf_bkg" parameter for forwarding to csphagen. +Add hidden "use_model_bkg" parameter for forwarding to csphagen. Add hidden "nthreads" parameter and implement parallelisation of light curve computation (#2421). @@ -323,16 +323,19 @@ Use time reference of input observations if time selection is given in MET csphagen - Generate On/Off observations --------------------------------------- -Add hidden "use_irf_bkg" parameter. By default the parameter is set to "yes", -which means that the background acceptance provided in the IRF is used for -the computation of the alpha parameter and the background rate, stored in the -"BACKSCAL" column of the On spectrum and the "BACKRESP" column of the Off +The script now supports any kind of background model, not only IRF background +models (#2710). + +Add hidden "use_model_bkg" parameter. By default the parameter is set to "yes", +which means that the background model provided in the model container is used +for the computation of the alpha parameter and the background rate, stored in +the "BACKSCAL" column of the On spectrum and the "BACKRESP" column of the Off spectrum, respectively. If the parameter is set to "no" it is assumed that the -background rate in the On and Off regions are the same, and the IRF background -template is not used. In that case, the "BACKSCAL" column gives the ratio of -the solid angles between On and Off regions, and the "BACKRESP" column is set -to zero. The resulting data can only be fitted using the "wstat" statistic -(#2659). +background rate in the On and Off regions are the same, and the model background +is not used. In that case, the "BACKSCAL" column gives the ratio of the solid +angles between On and Off regions, and the "BACKRESP" column is set to the +solid angle of the On region. The resulting data can only be fitted using the +"WSTAT" statistic (#2659). Add hidden "nthreads" parameter and implement parallelisation of computations (#2421). diff --git a/cscripts/cslightcrv.par b/cscripts/cslightcrv.par index beb9673..8df5628 100755 --- a/cscripts/cslightcrv.par +++ b/cscripts/cslightcrv.par @@ -28,37 +28,37 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file" # # Script parameters #================== -tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" -tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" -tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" -mjdref, r, h, 51544.5,,, "Reference MJD for MET" -tbins, i, a, 5,1,10000, "Number of time bins" -tbinfile, f, a, NONE,,, "File defining the time binning" -method, s, a, 3D, 3D|ONOFF,, "Analysis method" -emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" -emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" -enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for 3D analysis only)" -coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" -proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" -xref, r, a, 83.63,0,360, "First coordinate of image/source region center in degrees (RA or galactic l)" -yref, r, a, 22.51,-90,90, "Second coordinate of image/source region center in degrees (DEC or galactic b)" -nxpix, i, a, 200,,, "Size of the X axis in pixels" -nypix, i, a, 200,,, "Size of the Y axis in pixels" -binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" -rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" -bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" -bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" -use_irf_bkg, b, h, yes,,, "Use IRF background template?" -maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" -etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" -etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" -etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" -calc_ts, b, h, yes,,, "Compute TS value for each bin?" -calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" -fix_srcs, b, h, yes,,, "Fix other sky model parameters?" -fix_bkg, b, h, no,,, "Fix background model parameters?" +tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" +tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" +tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" +mjdref, r, h, 51544.5,,, "Reference MJD for MET" +tbins, i, a, 5,1,10000, "Number of time bins" +tbinfile, f, a, NONE,,, "File defining the time binning" +method, s, a, 3D, 3D|ONOFF,, "Analysis method" +emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" +emax, r, a, 100.0,,, "Upper energy limit of events (TeV)" +enumbins, i, a, 0,0,100, "Number of energy bins for binned (0=unbinned for 3D analysis only)" +coordsys, s, a, CEL,CEL|GAL,, "Coordinate System" +proj, s, a, CAR,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" +xref, r, a, 83.63,0,360, "First coordinate of image/source region center in degrees (RA or galactic l)" +yref, r, a, 22.51,-90,90, "Second coordinate of image/source region center in degrees (DEC or galactic b)" +nxpix, i, a, 200,,, "Size of the X axis in pixels" +nypix, i, a, 200,,, "Size of the Y axis in pixels" +binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" +bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" +use_model_bkg, b, h, yes,,, "Use background model?" +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" +etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" +etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" +etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" +calc_ts, b, h, yes,,, "Compute TS value for each bin?" +calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" +fix_srcs, b, h, yes,,, "Fix other sky model parameters?" +fix_bkg, b, h, no,,, "Fix background model parameters?" # # Standard parameters diff --git a/cscripts/csphagen.par b/cscripts/csphagen.par index f2fafa1..83e0286 100644 --- a/cscripts/csphagen.par +++ b/cscripts/csphagen.par @@ -28,28 +28,28 @@ prefix, s, h, onoff,,, "Prefix for output files" # # Script parameters #================== -ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" -emin, r, a, 0.1,,, "Start value for first energy bin in TeV" -emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" -enumbins, i, a, 120,,, "Number of energy bins" -ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" -coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" -ra, r, a, 83.63,0,360, "Right Ascension of source region centre (deg)" -dec, r, a, 22.01,-90,90, "Declination of source region centre (deg)" -glon, r, a, 184.56,0,360, "Galactic longitude of source region centre (deg)" -glat, r, a, -5.79,-90,90, "Galactic latitude of source region centre (deg)" -rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" -srcregfile, f, a, on.reg,,, "Source region file (ds9 or FITS WCS)" -bkgmethod, s, a, REFLECTED,REFLECTED|CUSTOM,, "Method for background estimation" -bkgregfile, f, a, bkg.reg,,, "Background regions file (ds9 or FITS WCS)" -bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" -use_irf_bkg, b, h, yes,,, "Use IRF background template?" -maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" -stack, b, a, no,,, "Stack multiple observations into single PHA, ARF and RMF files?" -etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" -etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" -etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" +ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" +emin, r, a, 0.1,,, "Start value for first energy bin in TeV" +emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" +enumbins, i, a, 120,,, "Number of energy bins" +ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" +coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" +ra, r, a, 83.63,0,360, "Right Ascension of source region centre (deg)" +dec, r, a, 22.01,-90,90, "Declination of source region centre (deg)" +glon, r, a, 184.56,0,360, "Galactic longitude of source region centre (deg)" +glat, r, a, -5.79,-90,90, "Galactic latitude of source region centre (deg)" +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" +srcregfile, f, a, on.reg,,, "Source region file (ds9 or FITS WCS)" +bkgmethod, s, a, REFLECTED,REFLECTED|CUSTOM,, "Method for background estimation" +bkgregfile, f, a, bkg.reg,,, "Background regions file (ds9 or FITS WCS)" +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" +use_model_bkg, b, h, yes,,, "Use background model?" +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" +stack, b, a, no,,, "Stack multiple observations into single PHA, ARF and RMF files?" +etruemin, r, h, 0.01,,, "Minimum true energy (TeV)" +etruemax, r, h, 300.0,,, "Maximum true energy (TeV)" +etruebins, i, h, 30,,, "Number of bins per decade for true energy bins" # # Standard parameters diff --git a/cscripts/csphagen.py b/cscripts/csphagen.py index 4875d95..62b50e3 100755 --- a/cscripts/csphagen.py +++ b/cscripts/csphagen.py @@ -47,7 +47,9 @@ class csphagen(ctools.csobservation): self._etruebounds = gammalib.GEbounds() self._src_dir = gammalib.GSkyDir() self._src_reg = gammalib.GSkyRegions() - self._src_model = None + self._models = gammalib.GModels() + self._srcname = '' + self._use_model_bkg = True self._bkg_regs = [] self._excl_reg = None self._has_exclusion = False @@ -69,18 +71,20 @@ class csphagen(ctools.csobservation): Pickled instance """ # Set pickled dictionary - state = {'base' : ctools.csobservation.__getstate__(self), - 'ebounds' : self._ebounds, - 'etruebounds' : self._etruebounds, - 'src_dir' : self._src_dir, - 'src_reg' : self._src_reg, - 'src_model' : self._src_model, - 'bkg_regs' : self._bkg_regs, - 'excl_reg' : self._excl_reg, - 'has_exclusion': self._has_exclusion, - 'srcshape' : self._srcshape, - 'rad' : self._rad, - 'nthreads' : self._nthreads} + state = {'base' : ctools.csobservation.__getstate__(self), + 'ebounds' : self._ebounds, + 'etruebounds' : self._etruebounds, + 'src_dir' : self._src_dir, + 'src_reg' : self._src_reg, + 'models' : self._models, + 'srcname' : self._srcname, + 'use_model_bkg' : self._use_model_bkg, + 'bkg_regs' : self._bkg_regs, + 'excl_reg' : self._excl_reg, + 'has_exclusion' : self._has_exclusion, + 'srcshape' : self._srcshape, + 'rad' : self._rad, + 'nthreads' : self._nthreads} # Return pickled dictionary return state @@ -99,7 +103,9 @@ class csphagen(ctools.csobservation): self._etruebounds = state['etruebounds'] self._src_dir = state['src_dir'] self._src_reg = state['src_reg'] - self._src_model = state['src_model'] + self._models = state['models'] + self._srcname = state['srcname'] + self._use_model_bkg = state['use_model_bkg'] self._bkg_regs = state['bkg_regs'] self._excl_reg = state['excl_reg'] self._has_exclusion = state['has_exclusion'] @@ -157,8 +163,8 @@ class csphagen(ctools.csobservation): self._rad = self['rad'].real() self._src_reg.append(gammalib.GSkyRegionCircle(self._src_dir, self._rad)) - # Query usage of IRF background template - self['use_irf_bkg'].boolean() + # Query usage of background model + self['use_model_bkg'].boolean() # Return return @@ -223,19 +229,23 @@ class csphagen(ctools.csobservation): """ Get parameters from parfile and setup observations """ + # Clear source models + self._models.clear() + # Setup observations (require response and allow event list, don't # allow counts cube) self._setup_observations(self.obs(), True, True, False) - # Get spatial component of source model if an input model is defined + # Get source model and source name. First try to extract models from + # observation container. If this does not work then try creating + # model from the inmodel parameter if self.obs().models().size() > 0: - name = self['srcname'].string() - self._src_model = self.obs().models()[name].spatial().clone() + self._models = self.obs().models().clone() + self._srcname = self['srcname'].string() elif self['inmodel'].is_valid(): inmodel = self['inmodel'].filename() - models = gammalib.GModels(inmodel) - name = self['srcname'].string() - self._src_model = models[name].spatial().clone() + self._models = gammalib.GModels(inmodel) + self._srcname = self['srcname'].string() # Set energy bounds self._ebounds = self._create_ebounds() @@ -274,6 +284,16 @@ class csphagen(ctools.csobservation): # Set number of processes for multiprocessing self._nthreads = mputils.nthreads(self) + # If we have no model then create now a dummy model + if self._models.is_empty(): + spatial = gammalib.GModelSpatialPointSource(self._src_dir) + spectral = gammalib.GModelSpectralPlaw() + model = gammalib.GModelSky(spatial, spectral) + model.name('Dummy') + self._models.append(model) + self._srcname = 'Dummy' + self._use_model_bkg = False + # Return return @@ -481,21 +501,22 @@ class csphagen(ctools.csobservation): bkg_reg = self._set_background_regions(obs) # Get IRF background template usage flag - use_irf_bkg = self['use_irf_bkg'].boolean() - if not use_irf_bkg: - self._log_string(gammalib.NORMAL, 'IRF background template ' - 'not used, assume constant backround rate.') + use_model_bkg = self['use_model_bkg'].boolean() + if not use_model_bkg: + self._log_string(gammalib.NORMAL, 'Background model not used, ' + 'assume constant backround rate.') # If there are background regions then create On/Off observation # and append it to the output container if bkg_reg.size() >= self['bkgregmin'].integer(): onoff = gammalib.GCTAOnOffObservation(obs, - self._src_model, + self._models, + self._srcname, self._etruebounds, self._ebounds, self._src_reg, bkg_reg, - use_irf_bkg) + use_model_bkg) onoff.id(obs.id()) else: @@ -578,10 +599,6 @@ class csphagen(ctools.csobservation): outobs = gammalib.GObservations() self._bkg_regs = [] - # Set spatial model - if self._src_model == None: - self._src_model = gammalib.GModelSpatialPointSource(self._src_dir) - # If there is more than one observation and we use multiprocessing if self._nthreads > 1 and self.obs().size() > 1: diff --git a/cscripts/obsutils.py b/cscripts/obsutils.py index 0fdb003..dbba584 100755 --- a/cscripts/obsutils.py +++ b/cscripts/obsutils.py @@ -809,13 +809,13 @@ def get_onoff_obs(cls, obs, nthreads=0): if cls._logExplicit(): cls._log.header3('Creating On/Off observations') - # Initialise inmodel, srcname, inexclusion and use_irf_bkg - inmodel = 'NONE' - srcname = '' - inexclusion = 'NONE' - use_irf_bkg = True + # Initialise inmodel, srcname, inexclusion and use_model_bkg + inmodel = 'NONE' + srcname = '' + inexclusion = 'NONE' + use_model_bkg = True - # Set inmodel, srcname, inexclusion and use_irf_bkg if they are available + # Set inmodel, srcname, inexclusion and use_model_bkg if they are available if cls.has_par('inmodel'): if cls['inmodel'].is_valid(): inmodel = cls['inmodel'].value() @@ -824,8 +824,8 @@ def get_onoff_obs(cls, obs, nthreads=0): if cls.has_par('inexclusion'): if cls['inexclusion'].is_valid(): inexclusion = cls['inexclusion'].value() - if cls.has_par('use_irf_bkg'): - use_irf_bkg = cls['use_irf_bkg'].boolean() + if cls.has_par('use_model_bkg'): + use_model_bkg = cls['use_model_bkg'].boolean() # Create On/Off observations phagen = cscripts.csphagen(obs) @@ -849,16 +849,16 @@ def get_onoff_obs(cls, obs, nthreads=0): phagen['bkgmethod'] = cls['bkgmethod'].string() if cls['bkgmethod'].string() == 'REFLECTED': phagen['bkgregmin'] = cls['bkgregmin'].integer() - phagen['use_irf_bkg'] = use_irf_bkg - phagen['maxoffset'] = cls['maxoffset'].real() - phagen['stack'] = True - phagen['etruemin'] = cls['etruemin'].real() - phagen['etruemax'] = cls['etruemax'].real() - phagen['etruebins'] = cls['etruebins'].integer() - phagen['chatter'] = cls['chatter'].integer() - phagen['clobber'] = cls['clobber'].boolean() - phagen['debug'] = cls['debug'].boolean() - phagen['nthreads'] = nthreads + phagen['use_model_bkg'] = use_model_bkg + phagen['maxoffset'] = cls['maxoffset'].real() + phagen['stack'] = True + phagen['etruemin'] = cls['etruemin'].real() + phagen['etruemax'] = cls['etruemax'].real() + phagen['etruebins'] = cls['etruebins'].integer() + phagen['chatter'] = cls['chatter'].integer() + phagen['clobber'] = cls['clobber'].boolean() + phagen['debug'] = cls['debug'].boolean() + phagen['nthreads'] = nthreads phagen.run() # Clone resulting observation container diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index f9254e0..9967f14 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -52,7 +52,7 @@ Improvements Add ``ctbkgcube::cntcube()`` method Account for varying energy thresholds in :ref:`ctbin` weight computation Unnormalize background cube values in :ref:`ctbkgcube` -* Add ``use_irf_bkg`` parameter to :ref:`cslightcrv` +* Add ``use_model_bkg`` parameter to :ref:`cslightcrv` * [`2671 `_] - Do not skip bins with zero counts in :ref:`csspec` * [`2670 `_] - @@ -63,7 +63,7 @@ Improvements :ref:`ctlike`, :ref:`cttsmap`, :ref:`ctulimit`, and :ref:`cstsmapsplit` to allow controlling the accuracy of the maximum likelihood computation * [`2659 `_] - - Add hidden ``use_irf_bkg`` parameter to :ref:`csphagen` + Add hidden ``use_model_bkg`` parameter to :ref:`csphagen` * [`2656 `_] - Use full ``RMF`` true energy range for On/Off analysis in :ref:`csspec` * [`2513 `_] - diff --git a/doc/source/users/reference_manual/cslightcrv.rst b/doc/source/users/reference_manual/cslightcrv.rst index 706496e..c2ff529 100755 --- a/doc/source/users/reference_manual/cslightcrv.rst +++ b/doc/source/users/reference_manual/cslightcrv.rst @@ -144,20 +144,20 @@ General parameters ``ONOFF`` analysis. If this number of background regions is not available the observation is skipped. -``(use_irf_bkg = yes) [boolean]`` - Specifies whether the IRF background template should be used for the - computation of the ``alpha`` parameter and the predicted background rate in - the Off region that is stored in the ``BACKRESP`` column of the Off spectrum - when using the ``ONOFF`` method. - - If the parameter is set to ``no`` the IRF background template is not used and - the background rate is assumed identical within the On and Off regions. This +``(use_model_bkg = yes) [boolean]`` + Specifies whether the background model should be used for the computation + of the ``alpha`` parameter and the predicted background rate in the Off + region that is stored in the ``BACKRESP`` column of the Off spectrum when + using the ``ONOFF`` method. + + If the parameter is set to ``no`` the background model is not used and the + background rate is assumed identical within the On and Off regions. This is the classical IACT analysis method that is used when using reflected Off regions. In that case the ``alpha`` parameter becomes independent of energy and only reflects the ratio between the solid angles of the On and Off - regions. The ``BACKRESP`` column in the Off spectrum will be filled with zeros. - The data need to be fitted with the ``wstat`` statistic, fitting with ``cstat`` - will not work. + regions. The ``BACKRESP`` column in the Off spectrum will be filled with + the solid angle of the On region. The data need to be fitted with the ``wstat`` + statistic, fitting with ``cstat`` will not work. ``(maxoffset = 4.0) [real]`` Maximum offset in degrees of source from camera center to accept the diff --git a/doc/source/users/reference_manual/csphagen.rst b/doc/source/users/reference_manual/csphagen.rst index 56eb167..53ea5ba 100644 --- a/doc/source/users/reference_manual/csphagen.rst +++ b/doc/source/users/reference_manual/csphagen.rst @@ -167,19 +167,20 @@ General parameters If this number of background regions is not available the observation is skipped. -``(use_irf_bkg = yes) [boolean]`` - Specifies whether the IRF background template should be used for the - computation of the ``alpha`` parameter and the predicted background rate in - the Off region that is stored in the ``BACKRESP`` column of the Off spectrum. - - If the parameter is set to ``no`` the IRF background template is not used and - the background rate is assumed identical within the On and Off regions. This +``(use_model_bkg = yes) [boolean]`` + Specifies whether the background model should be used for the computation + of the ``alpha`` parameter and the predicted background rate in the Off + region that is stored in the ``BACKRESP`` column of the Off spectrum when + using the ``ONOFF`` method. + + If the parameter is set to ``no`` the background model is not used and the + background rate is assumed identical within the On and Off regions. This is the classical IACT analysis method that is used when using reflected Off regions. In that case the ``alpha`` parameter becomes independent of energy and only reflects the ratio between the solid angles of the On and Off - regions. The ``BACKRESP`` column in the Off spectrum will be filled with zeros. - The data need to be fitted with the ``wstat`` statistic, fitting with ``cstat`` - will not work. + regions. The ``BACKRESP`` column in the Off spectrum will be filled with + the solid angle of the On region. The data need to be fitted with the ``wstat`` + statistic, fitting with ``cstat`` will not work. ``(maxoffset = 4.0) [real]`` Maximum offset in degrees of source from camera center to accept the diff --git a/doc/source/users/tutorials/hess_dr1/classical.ipynb b/doc/source/users/tutorials/hess_dr1/classical.ipynb index 8451a26..74745f7 100644 --- a/doc/source/users/tutorials/hess_dr1/classical.ipynb +++ b/doc/source/users/tutorials/hess_dr1/classical.ipynb @@ -100,7 +100,7 @@ "phagen['dec'] = 22.01\n", "phagen['rad'] = 0.2\n", "phagen['bkgmethod'] = 'REFLECTED'\n", - "phagen['use_irf_bkg'] = False\n", + "phagen['use_model_bkg'] = False\n", "phagen['maxoffset'] = 2.0\n", "phagen['stack'] = True # treat observations separately in joint likelihood fit\n", "\n", @@ -111,7 +111,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Note that we have used the hidden parameter *use_irf_bkg* to specify that no background model should be used in the computation of the background normalisation factor, which is simply assumed to be the ratio of the solid angles of On/Off regions.\n", + "Note that we have used the hidden parameter *use_model_bkg* to specify that no background model should be used in the computation of the background normalisation factor, which is simply assumed to be the ratio of the solid angles of On/Off regions.\n", "\n", "## Likelihood fit\n", "\n", diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index 65db11f..37d28f2 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -241,31 +241,31 @@ class Test(test): # cslightcrv with classical analysis lcrv = cscripts.cslightcrv() - lcrv['inobs'] = self._offaxis_events - lcrv['inmodel'] = self._model_onoff - lcrv['srcname'] = 'Crab' - lcrv['caldb'] = self._caldb - lcrv['irf'] = self._irf - lcrv['tbinalg'] = 'LIN' - lcrv['tmin'] = '2020-01-01T00:00:00' - lcrv['tmax'] = '2020-01-01T00:05:00' - lcrv['tbins'] = 2 - lcrv['method'] = 'ONOFF' - lcrv['use_irf_bkg'] = False # Needed even if WSTAT - lcrv['emin'] = 1.0 - lcrv['emax'] = 100.0 - lcrv['enumbins'] = 2 - lcrv['coordsys'] = 'CEL' - lcrv['xref'] = 83.63 - lcrv['yref'] = 22.01 - lcrv['rad'] = 0.2 - lcrv['etruemin'] = 1.0 - lcrv['etruemax'] = 100.0 - lcrv['etruebins'] = 5 - lcrv['statistic'] = 'WSTAT' - lcrv['outfile'] = 'cslightcrv_py5.fits' - lcrv['logfile'] = 'cslightcrv_py5.log' - lcrv['chatter'] = 4 + lcrv['inobs'] = self._offaxis_events + lcrv['inmodel'] = self._model_onoff + lcrv['srcname'] = 'Crab' + lcrv['caldb'] = self._caldb + lcrv['irf'] = self._irf + lcrv['tbinalg'] = 'LIN' + lcrv['tmin'] = '2020-01-01T00:00:00' + lcrv['tmax'] = '2020-01-01T00:05:00' + lcrv['tbins'] = 2 + lcrv['method'] = 'ONOFF' + lcrv['use_model_bkg'] = False # Needed even if WSTAT + lcrv['emin'] = 1.0 + lcrv['emax'] = 100.0 + lcrv['enumbins'] = 2 + lcrv['coordsys'] = 'CEL' + lcrv['xref'] = 83.63 + lcrv['yref'] = 22.01 + lcrv['rad'] = 0.2 + lcrv['etruemin'] = 1.0 + lcrv['etruemax'] = 100.0 + lcrv['etruebins'] = 5 + lcrv['statistic'] = 'WSTAT' + lcrv['outfile'] = 'cslightcrv_py5.fits' + lcrv['logfile'] = 'cslightcrv_py5.log' + lcrv['chatter'] = 4 # Execute cslightcrv script lcrv.execute()