Commit 2f8a94a4ac93990b4d9c568f4410586262173bf1
1 parent
c1981f9a
On/Off analysis now supports any kind of background model (#2710)
Showing
11 changed files
with
187 additions
and
165 deletions
ChangeLog
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | Apply event bin weighting in ctmodel for stacked computation (#2721) |
| 8 | 8 | Enable ctbin to produce counts cubes for a joint binned analysis (#2714) |
| 9 | 9 | Add Jupyter notebooks for H.E.S.S. DR1 (#2712) |
| 10 | + csphagen now supports any kind of background model (#2710) | |
| 10 | 11 | Add code generator (#2709) |
| 11 | 12 | Add csbkgmodel script (#2694) |
| 12 | 13 | Compute DETX and DETY in ctmodel if they are not available (#2694) |
| ... | ... | @@ -16,11 +17,11 @@ |
| 16 | 17 | Account for varying energy thresholds in ctbin weight computation (#2685) |
| 17 | 18 | Add ctbkgcube::cntcube() method (#2685) |
| 18 | 19 | Avoid ctselect error in case that RoI radius is unchanged (#2682) |
| 19 | - Add "use_irf_bkg" parameter to cslightcrv | |
| 20 | + Add "use_model_bkg" parameter to cslightcrv | |
| 20 | 21 | Add "like_accuracy" parameter to likelihood tools and scripts (#2662) |
| 21 | 22 | Do not skip bins with zero counts in csspec (#2671) |
| 22 | 23 | Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670) |
| 23 | - Add hidden "use_irf_bkg" parameter to csphagen (#2659) | |
| 24 | + Add hidden "use_model_bkg" parameter to csphagen (#2659) | |
| 24 | 25 | Use full RMF true energy range for On/Off analysis in csspec (#2656) |
| 25 | 26 | Defer import of ROOT module in csroot2caldb to run method (#2652) |
| 26 | 27 | Transparently update parameter files (#2513) | ... | ... |
NEWS
| ... | ... | @@ -270,7 +270,7 @@ None |
| 270 | 270 | |
| 271 | 271 | cslightcrv - Generate light curve |
| 272 | 272 | --------------------------------- |
| 273 | -Add hidden "use_irf_bkg" parameter for forwarding to csphagen. | |
| 273 | +Add hidden "use_model_bkg" parameter for forwarding to csphagen. | |
| 274 | 274 | |
| 275 | 275 | Add hidden "nthreads" parameter and implement parallelisation of light |
| 276 | 276 | curve computation (#2421). |
| ... | ... | @@ -323,16 +323,19 @@ Use time reference of input observations if time selection is given in MET |
| 323 | 323 | |
| 324 | 324 | csphagen - Generate On/Off observations |
| 325 | 325 | --------------------------------------- |
| 326 | -Add hidden "use_irf_bkg" parameter. By default the parameter is set to "yes", | |
| 327 | -which means that the background acceptance provided in the IRF is used for | |
| 328 | -the computation of the alpha parameter and the background rate, stored in the | |
| 329 | -"BACKSCAL" column of the On spectrum and the "BACKRESP" column of the Off | |
| 326 | +The script now supports any kind of background model, not only IRF background | |
| 327 | +models (#2710). | |
| 328 | + | |
| 329 | +Add hidden "use_model_bkg" parameter. By default the parameter is set to "yes", | |
| 330 | +which means that the background model provided in the model container is used | |
| 331 | +for the computation of the alpha parameter and the background rate, stored in | |
| 332 | +the "BACKSCAL" column of the On spectrum and the "BACKRESP" column of the Off | |
| 330 | 333 | spectrum, respectively. If the parameter is set to "no" it is assumed that the |
| 331 | -background rate in the On and Off regions are the same, and the IRF background | |
| 332 | -template is not used. In that case, the "BACKSCAL" column gives the ratio of | |
| 333 | -the solid angles between On and Off regions, and the "BACKRESP" column is set | |
| 334 | -to zero. The resulting data can only be fitted using the "wstat" statistic | |
| 335 | -(#2659). | |
| 334 | +background rate in the On and Off regions are the same, and the model background | |
| 335 | +is not used. In that case, the "BACKSCAL" column gives the ratio of the solid | |
| 336 | +angles between On and Off regions, and the "BACKRESP" column is set to the | |
| 337 | +solid angle of the On region. The resulting data can only be fitted using the | |
| 338 | +"WSTAT" statistic (#2659). | |
| 336 | 339 | |
| 337 | 340 | Add hidden "nthreads" parameter and implement parallelisation of computations |
| 338 | 341 | (#2421). | ... | ... |
cscripts/cslightcrv.par
| ... | ... | @@ -28,37 +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 | -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?" | |
| 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_model_bkg, b, h, yes,,, "Use background model?" | |
| 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?" | |
| 62 | 62 | |
| 63 | 63 | # |
| 64 | 64 | # Standard parameters | ... | ... |
cscripts/csphagen.par
| ... | ... | @@ -28,28 +28,28 @@ prefix, s, h, onoff,,, "Prefix for output files" |
| 28 | 28 | # |
| 29 | 29 | # Script parameters |
| 30 | 30 | #================== |
| 31 | -ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" | |
| 32 | -emin, r, a, 0.1,,, "Start value for first energy bin in TeV" | |
| 33 | -emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" | |
| 34 | -enumbins, i, a, 120,,, "Number of energy bins" | |
| 35 | -ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" | |
| 36 | -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 37 | -coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" | |
| 38 | -ra, r, a, 83.63,0,360, "Right Ascension of source region centre (deg)" | |
| 39 | -dec, r, a, 22.01,-90,90, "Declination of source region centre (deg)" | |
| 40 | -glon, r, a, 184.56,0,360, "Galactic longitude of source region centre (deg)" | |
| 41 | -glat, r, a, -5.79,-90,90, "Galactic latitude of source region centre (deg)" | |
| 42 | -rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" | |
| 43 | -srcregfile, f, a, on.reg,,, "Source region file (ds9 or FITS WCS)" | |
| 44 | -bkgmethod, s, a, REFLECTED,REFLECTED|CUSTOM,, "Method for background estimation" | |
| 45 | -bkgregfile, f, a, bkg.reg,,, "Background regions file (ds9 or FITS WCS)" | |
| 46 | -bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" | |
| 47 | -use_irf_bkg, b, h, yes,,, "Use IRF background template?" | |
| 48 | -maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | |
| 49 | -stack, b, a, no,,, "Stack multiple observations into single PHA, ARF and RMF files?" | |
| 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" | |
| 31 | +ebinalg, s, a, LOG,FILE|LIN|LOG,, "Algorithm for defining energy bins" | |
| 32 | +emin, r, a, 0.1,,, "Start value for first energy bin in TeV" | |
| 33 | +emax, r, a, 100.0,,, "Stop value for last energy bin in TeV" | |
| 34 | +enumbins, i, a, 120,,, "Number of energy bins" | |
| 35 | +ebinfile, f, a, NONE,,, "Name of the file containing the energy bin definition" | |
| 36 | +srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 37 | +coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" | |
| 38 | +ra, r, a, 83.63,0,360, "Right Ascension of source region centre (deg)" | |
| 39 | +dec, r, a, 22.01,-90,90, "Declination of source region centre (deg)" | |
| 40 | +glon, r, a, 184.56,0,360, "Galactic longitude of source region centre (deg)" | |
| 41 | +glat, r, a, -5.79,-90,90, "Galactic latitude of source region centre (deg)" | |
| 42 | +rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" | |
| 43 | +srcregfile, f, a, on.reg,,, "Source region file (ds9 or FITS WCS)" | |
| 44 | +bkgmethod, s, a, REFLECTED,REFLECTED|CUSTOM,, "Method for background estimation" | |
| 45 | +bkgregfile, f, a, bkg.reg,,, "Background regions file (ds9 or FITS WCS)" | |
| 46 | +bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" | |
| 47 | +use_model_bkg, b, h, yes,,, "Use background model?" | |
| 48 | +maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | |
| 49 | +stack, b, a, no,,, "Stack multiple observations into single PHA, ARF and RMF files?" | |
| 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" | |
| 53 | 53 | |
| 54 | 54 | # |
| 55 | 55 | # Standard parameters | ... | ... |
cscripts/csphagen.py
| ... | ... | @@ -47,7 +47,9 @@ class csphagen(ctools.csobservation): |
| 47 | 47 | self._etruebounds = gammalib.GEbounds() |
| 48 | 48 | self._src_dir = gammalib.GSkyDir() |
| 49 | 49 | self._src_reg = gammalib.GSkyRegions() |
| 50 | - self._src_model = None | |
| 50 | + self._models = gammalib.GModels() | |
| 51 | + self._srcname = '' | |
| 52 | + self._use_model_bkg = True | |
| 51 | 53 | self._bkg_regs = [] |
| 52 | 54 | self._excl_reg = None |
| 53 | 55 | self._has_exclusion = False |
| ... | ... | @@ -69,18 +71,20 @@ class csphagen(ctools.csobservation): |
| 69 | 71 | Pickled instance |
| 70 | 72 | """ |
| 71 | 73 | # Set pickled dictionary |
| 72 | - state = {'base' : ctools.csobservation.__getstate__(self), | |
| 73 | - 'ebounds' : self._ebounds, | |
| 74 | - 'etruebounds' : self._etruebounds, | |
| 75 | - 'src_dir' : self._src_dir, | |
| 76 | - 'src_reg' : self._src_reg, | |
| 77 | - 'src_model' : self._src_model, | |
| 78 | - 'bkg_regs' : self._bkg_regs, | |
| 79 | - 'excl_reg' : self._excl_reg, | |
| 80 | - 'has_exclusion': self._has_exclusion, | |
| 81 | - 'srcshape' : self._srcshape, | |
| 82 | - 'rad' : self._rad, | |
| 83 | - 'nthreads' : self._nthreads} | |
| 74 | + state = {'base' : ctools.csobservation.__getstate__(self), | |
| 75 | + 'ebounds' : self._ebounds, | |
| 76 | + 'etruebounds' : self._etruebounds, | |
| 77 | + 'src_dir' : self._src_dir, | |
| 78 | + 'src_reg' : self._src_reg, | |
| 79 | + 'models' : self._models, | |
| 80 | + 'srcname' : self._srcname, | |
| 81 | + 'use_model_bkg' : self._use_model_bkg, | |
| 82 | + 'bkg_regs' : self._bkg_regs, | |
| 83 | + 'excl_reg' : self._excl_reg, | |
| 84 | + 'has_exclusion' : self._has_exclusion, | |
| 85 | + 'srcshape' : self._srcshape, | |
| 86 | + 'rad' : self._rad, | |
| 87 | + 'nthreads' : self._nthreads} | |
| 84 | 88 | |
| 85 | 89 | # Return pickled dictionary |
| 86 | 90 | return state |
| ... | ... | @@ -99,7 +103,9 @@ class csphagen(ctools.csobservation): |
| 99 | 103 | self._etruebounds = state['etruebounds'] |
| 100 | 104 | self._src_dir = state['src_dir'] |
| 101 | 105 | self._src_reg = state['src_reg'] |
| 102 | - self._src_model = state['src_model'] | |
| 106 | + self._models = state['models'] | |
| 107 | + self._srcname = state['srcname'] | |
| 108 | + self._use_model_bkg = state['use_model_bkg'] | |
| 103 | 109 | self._bkg_regs = state['bkg_regs'] |
| 104 | 110 | self._excl_reg = state['excl_reg'] |
| 105 | 111 | self._has_exclusion = state['has_exclusion'] |
| ... | ... | @@ -157,8 +163,8 @@ class csphagen(ctools.csobservation): |
| 157 | 163 | self._rad = self['rad'].real() |
| 158 | 164 | self._src_reg.append(gammalib.GSkyRegionCircle(self._src_dir, self._rad)) |
| 159 | 165 | |
| 160 | - # Query usage of IRF background template | |
| 161 | - self['use_irf_bkg'].boolean() | |
| 166 | + # Query usage of background model | |
| 167 | + self['use_model_bkg'].boolean() | |
| 162 | 168 | |
| 163 | 169 | # Return |
| 164 | 170 | return |
| ... | ... | @@ -223,19 +229,23 @@ class csphagen(ctools.csobservation): |
| 223 | 229 | """ |
| 224 | 230 | Get parameters from parfile and setup observations |
| 225 | 231 | """ |
| 232 | + # Clear source models | |
| 233 | + self._models.clear() | |
| 234 | + | |
| 226 | 235 | # Setup observations (require response and allow event list, don't |
| 227 | 236 | # allow counts cube) |
| 228 | 237 | self._setup_observations(self.obs(), True, True, False) |
| 229 | 238 | |
| 230 | - # Get spatial component of source model if an input model is defined | |
| 239 | + # Get source model and source name. First try to extract models from | |
| 240 | + # observation container. If this does not work then try creating | |
| 241 | + # model from the inmodel parameter | |
| 231 | 242 | if self.obs().models().size() > 0: |
| 232 | - name = self['srcname'].string() | |
| 233 | - self._src_model = self.obs().models()[name].spatial().clone() | |
| 243 | + self._models = self.obs().models().clone() | |
| 244 | + self._srcname = self['srcname'].string() | |
| 234 | 245 | elif self['inmodel'].is_valid(): |
| 235 | 246 | inmodel = self['inmodel'].filename() |
| 236 | - models = gammalib.GModels(inmodel) | |
| 237 | - name = self['srcname'].string() | |
| 238 | - self._src_model = models[name].spatial().clone() | |
| 247 | + self._models = gammalib.GModels(inmodel) | |
| 248 | + self._srcname = self['srcname'].string() | |
| 239 | 249 | |
| 240 | 250 | # Set energy bounds |
| 241 | 251 | self._ebounds = self._create_ebounds() |
| ... | ... | @@ -274,6 +284,16 @@ class csphagen(ctools.csobservation): |
| 274 | 284 | # Set number of processes for multiprocessing |
| 275 | 285 | self._nthreads = mputils.nthreads(self) |
| 276 | 286 | |
| 287 | + # If we have no model then create now a dummy model | |
| 288 | + if self._models.is_empty(): | |
| 289 | + spatial = gammalib.GModelSpatialPointSource(self._src_dir) | |
| 290 | + spectral = gammalib.GModelSpectralPlaw() | |
| 291 | + model = gammalib.GModelSky(spatial, spectral) | |
| 292 | + model.name('Dummy') | |
| 293 | + self._models.append(model) | |
| 294 | + self._srcname = 'Dummy' | |
| 295 | + self._use_model_bkg = False | |
| 296 | + | |
| 277 | 297 | # Return |
| 278 | 298 | return |
| 279 | 299 | |
| ... | ... | @@ -481,21 +501,22 @@ class csphagen(ctools.csobservation): |
| 481 | 501 | bkg_reg = self._set_background_regions(obs) |
| 482 | 502 | |
| 483 | 503 | # Get IRF background template usage flag |
| 484 | - use_irf_bkg = self['use_irf_bkg'].boolean() | |
| 485 | - if not use_irf_bkg: | |
| 486 | - self._log_string(gammalib.NORMAL, 'IRF background template ' | |
| 487 | - 'not used, assume constant backround rate.') | |
| 504 | + use_model_bkg = self['use_model_bkg'].boolean() | |
| 505 | + if not use_model_bkg: | |
| 506 | + self._log_string(gammalib.NORMAL, 'Background model not used, ' | |
| 507 | + 'assume constant backround rate.') | |
| 488 | 508 | |
| 489 | 509 | # If there are background regions then create On/Off observation |
| 490 | 510 | # and append it to the output container |
| 491 | 511 | if bkg_reg.size() >= self['bkgregmin'].integer(): |
| 492 | 512 | onoff = gammalib.GCTAOnOffObservation(obs, |
| 493 | - self._src_model, | |
| 513 | + self._models, | |
| 514 | + self._srcname, | |
| 494 | 515 | self._etruebounds, |
| 495 | 516 | self._ebounds, |
| 496 | 517 | self._src_reg, |
| 497 | 518 | bkg_reg, |
| 498 | - use_irf_bkg) | |
| 519 | + use_model_bkg) | |
| 499 | 520 | onoff.id(obs.id()) |
| 500 | 521 | |
| 501 | 522 | else: |
| ... | ... | @@ -578,10 +599,6 @@ class csphagen(ctools.csobservation): |
| 578 | 599 | outobs = gammalib.GObservations() |
| 579 | 600 | self._bkg_regs = [] |
| 580 | 601 | |
| 581 | - # Set spatial model | |
| 582 | - if self._src_model == None: | |
| 583 | - self._src_model = gammalib.GModelSpatialPointSource(self._src_dir) | |
| 584 | - | |
| 585 | 602 | # If there is more than one observation and we use multiprocessing |
| 586 | 603 | if self._nthreads > 1 and self.obs().size() > 1: |
| 587 | 604 | ... | ... |
cscripts/obsutils.py
| ... | ... | @@ -809,13 +809,13 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 809 | 809 | if cls._logExplicit(): |
| 810 | 810 | cls._log.header3('Creating On/Off observations') |
| 811 | 811 | |
| 812 | - # Initialise inmodel, srcname, inexclusion and use_irf_bkg | |
| 813 | - inmodel = 'NONE' | |
| 814 | - srcname = '' | |
| 815 | - inexclusion = 'NONE' | |
| 816 | - use_irf_bkg = True | |
| 812 | + # Initialise inmodel, srcname, inexclusion and use_model_bkg | |
| 813 | + inmodel = 'NONE' | |
| 814 | + srcname = '' | |
| 815 | + inexclusion = 'NONE' | |
| 816 | + use_model_bkg = True | |
| 817 | 817 | |
| 818 | - # Set inmodel, srcname, inexclusion and use_irf_bkg if they are available | |
| 818 | + # Set inmodel, srcname, inexclusion and use_model_bkg if they are available | |
| 819 | 819 | if cls.has_par('inmodel'): |
| 820 | 820 | if cls['inmodel'].is_valid(): |
| 821 | 821 | inmodel = cls['inmodel'].value() |
| ... | ... | @@ -824,8 +824,8 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 824 | 824 | if cls.has_par('inexclusion'): |
| 825 | 825 | if cls['inexclusion'].is_valid(): |
| 826 | 826 | inexclusion = cls['inexclusion'].value() |
| 827 | - if cls.has_par('use_irf_bkg'): | |
| 828 | - use_irf_bkg = cls['use_irf_bkg'].boolean() | |
| 827 | + if cls.has_par('use_model_bkg'): | |
| 828 | + use_model_bkg = cls['use_model_bkg'].boolean() | |
| 829 | 829 | |
| 830 | 830 | # Create On/Off observations |
| 831 | 831 | phagen = cscripts.csphagen(obs) |
| ... | ... | @@ -849,16 +849,16 @@ def get_onoff_obs(cls, obs, nthreads=0): |
| 849 | 849 | phagen['bkgmethod'] = cls['bkgmethod'].string() |
| 850 | 850 | if cls['bkgmethod'].string() == 'REFLECTED': |
| 851 | 851 | phagen['bkgregmin'] = cls['bkgregmin'].integer() |
| 852 | - phagen['use_irf_bkg'] = use_irf_bkg | |
| 853 | - phagen['maxoffset'] = cls['maxoffset'].real() | |
| 854 | - phagen['stack'] = True | |
| 855 | - phagen['etruemin'] = cls['etruemin'].real() | |
| 856 | - phagen['etruemax'] = cls['etruemax'].real() | |
| 857 | - phagen['etruebins'] = cls['etruebins'].integer() | |
| 858 | - phagen['chatter'] = cls['chatter'].integer() | |
| 859 | - phagen['clobber'] = cls['clobber'].boolean() | |
| 860 | - phagen['debug'] = cls['debug'].boolean() | |
| 861 | - phagen['nthreads'] = nthreads | |
| 852 | + phagen['use_model_bkg'] = use_model_bkg | |
| 853 | + phagen['maxoffset'] = cls['maxoffset'].real() | |
| 854 | + phagen['stack'] = True | |
| 855 | + phagen['etruemin'] = cls['etruemin'].real() | |
| 856 | + phagen['etruemax'] = cls['etruemax'].real() | |
| 857 | + phagen['etruebins'] = cls['etruebins'].integer() | |
| 858 | + phagen['chatter'] = cls['chatter'].integer() | |
| 859 | + phagen['clobber'] = cls['clobber'].boolean() | |
| 860 | + phagen['debug'] = cls['debug'].boolean() | |
| 861 | + phagen['nthreads'] = nthreads | |
| 862 | 862 | phagen.run() |
| 863 | 863 | |
| 864 | 864 | # Clone resulting observation container | ... | ... |
doc/source/admin/release_history/1.6.rst
| ... | ... | @@ -52,7 +52,7 @@ Improvements |
| 52 | 52 | Add ``ctbkgcube::cntcube()`` method |
| 53 | 53 | Account for varying energy thresholds in :ref:`ctbin` weight computation |
| 54 | 54 | Unnormalize background cube values in :ref:`ctbkgcube` |
| 55 | -* Add ``use_irf_bkg`` parameter to :ref:`cslightcrv` | |
| 55 | +* Add ``use_model_bkg`` parameter to :ref:`cslightcrv` | |
| 56 | 56 | * [`2671 <https://cta-redmine.irap.omp.eu/issues/2671>`_] - |
| 57 | 57 | Do not skip bins with zero counts in :ref:`csspec` |
| 58 | 58 | * [`2670 <https://cta-redmine.irap.omp.eu/issues/2670>`_] - |
| ... | ... | @@ -63,7 +63,7 @@ Improvements |
| 63 | 63 | :ref:`ctlike`, :ref:`cttsmap`, :ref:`ctulimit`, and :ref:`cstsmapsplit` |
| 64 | 64 | to allow controlling the accuracy of the maximum likelihood computation |
| 65 | 65 | * [`2659 <https://cta-redmine.irap.omp.eu/issues/2659>`_] - |
| 66 | - Add hidden ``use_irf_bkg`` parameter to :ref:`csphagen` | |
| 66 | + Add hidden ``use_model_bkg`` parameter to :ref:`csphagen` | |
| 67 | 67 | * [`2656 <https://cta-redmine.irap.omp.eu/issues/2656>`_] - |
| 68 | 68 | Use full ``RMF`` true energy range for On/Off analysis in :ref:`csspec` |
| 69 | 69 | * [`2513 <https://cta-redmine.irap.omp.eu/issues/2513>`_] - | ... | ... |
doc/source/users/reference_manual/cslightcrv.rst
| ... | ... | @@ -144,20 +144,20 @@ 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 | |
| 147 | +``(use_model_bkg = yes) [boolean]`` | |
| 148 | + Specifies whether the background model should be used for the computation | |
| 149 | + of the ``alpha`` parameter and the predicted background rate in the Off | |
| 150 | + region that is stored in the ``BACKRESP`` column of the Off spectrum when | |
| 151 | + using the ``ONOFF`` method. | |
| 152 | + | |
| 153 | + If the parameter is set to ``no`` the background model is not used and the | |
| 154 | + background rate is assumed identical within the On and Off regions. This | |
| 155 | 155 | is the classical IACT analysis method that is used when using reflected Off |
| 156 | 156 | regions. In that case the ``alpha`` parameter becomes independent of energy |
| 157 | 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. | |
| 158 | + regions. The ``BACKRESP`` column in the Off spectrum will be filled with | |
| 159 | + the solid angle of the On region. The data need to be fitted with the ``wstat`` | |
| 160 | + statistic, fitting with ``cstat`` will not work. | |
| 161 | 161 | |
| 162 | 162 | ``(maxoffset = 4.0) [real]`` |
| 163 | 163 | Maximum offset in degrees of source from camera center to accept the | ... | ... |
doc/source/users/reference_manual/csphagen.rst
| ... | ... | @@ -167,19 +167,20 @@ General parameters |
| 167 | 167 | If this number of background regions is not available the observation is |
| 168 | 168 | skipped. |
| 169 | 169 | |
| 170 | -``(use_irf_bkg = yes) [boolean]`` | |
| 171 | - Specifies whether the IRF background template should be used for the | |
| 172 | - computation of the ``alpha`` parameter and the predicted background rate in | |
| 173 | - the Off region that is stored in the ``BACKRESP`` column of the Off spectrum. | |
| 174 | - | |
| 175 | - If the parameter is set to ``no`` the IRF background template is not used and | |
| 176 | - the background rate is assumed identical within the On and Off regions. This | |
| 170 | +``(use_model_bkg = yes) [boolean]`` | |
| 171 | + Specifies whether the background model should be used for the computation | |
| 172 | + of the ``alpha`` parameter and the predicted background rate in the Off | |
| 173 | + region that is stored in the ``BACKRESP`` column of the Off spectrum when | |
| 174 | + using the ``ONOFF`` method. | |
| 175 | + | |
| 176 | + If the parameter is set to ``no`` the background model is not used and the | |
| 177 | + background rate is assumed identical within the On and Off regions. This | |
| 177 | 178 | is the classical IACT analysis method that is used when using reflected Off |
| 178 | 179 | regions. In that case the ``alpha`` parameter becomes independent of energy |
| 179 | 180 | and only reflects the ratio between the solid angles of the On and Off |
| 180 | - regions. The ``BACKRESP`` column in the Off spectrum will be filled with zeros. | |
| 181 | - The data need to be fitted with the ``wstat`` statistic, fitting with ``cstat`` | |
| 182 | - will not work. | |
| 181 | + regions. The ``BACKRESP`` column in the Off spectrum will be filled with | |
| 182 | + the solid angle of the On region. The data need to be fitted with the ``wstat`` | |
| 183 | + statistic, fitting with ``cstat`` will not work. | |
| 183 | 184 | |
| 184 | 185 | ``(maxoffset = 4.0) [real]`` |
| 185 | 186 | Maximum offset in degrees of source from camera center to accept the | ... | ... |
doc/source/users/tutorials/hess_dr1/classical.ipynb
| ... | ... | @@ -100,7 +100,7 @@ |
| 100 | 100 | "phagen['dec'] = 22.01\n", |
| 101 | 101 | "phagen['rad'] = 0.2\n", |
| 102 | 102 | "phagen['bkgmethod'] = 'REFLECTED'\n", |
| 103 | - "phagen['use_irf_bkg'] = False\n", | |
| 103 | + "phagen['use_model_bkg'] = False\n", | |
| 104 | 104 | "phagen['maxoffset'] = 2.0\n", |
| 105 | 105 | "phagen['stack'] = True # treat observations separately in joint likelihood fit\n", |
| 106 | 106 | "\n", |
| ... | ... | @@ -111,7 +111,7 @@ |
| 111 | 111 | "cell_type": "markdown", |
| 112 | 112 | "metadata": {}, |
| 113 | 113 | "source": [ |
| 114 | - "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", | |
| 114 | + "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", | |
| 115 | 115 | "\n", |
| 116 | 116 | "## Likelihood fit\n", |
| 117 | 117 | "\n", | ... | ... |
test/test_cslightcrv.py
| ... | ... | @@ -241,31 +241,31 @@ class Test(test): |
| 241 | 241 | |
| 242 | 242 | # cslightcrv with classical analysis |
| 243 | 243 | lcrv = cscripts.cslightcrv() |
| 244 | - lcrv['inobs'] = self._offaxis_events | |
| 245 | - lcrv['inmodel'] = self._model_onoff | |
| 246 | - lcrv['srcname'] = 'Crab' | |
| 247 | - lcrv['caldb'] = self._caldb | |
| 248 | - lcrv['irf'] = self._irf | |
| 249 | - lcrv['tbinalg'] = 'LIN' | |
| 250 | - lcrv['tmin'] = '2020-01-01T00:00:00' | |
| 251 | - lcrv['tmax'] = '2020-01-01T00:05:00' | |
| 252 | - lcrv['tbins'] = 2 | |
| 253 | - lcrv['method'] = 'ONOFF' | |
| 254 | - lcrv['use_irf_bkg'] = False # Needed even if WSTAT | |
| 255 | - lcrv['emin'] = 1.0 | |
| 256 | - lcrv['emax'] = 100.0 | |
| 257 | - lcrv['enumbins'] = 2 | |
| 258 | - lcrv['coordsys'] = 'CEL' | |
| 259 | - lcrv['xref'] = 83.63 | |
| 260 | - lcrv['yref'] = 22.01 | |
| 261 | - lcrv['rad'] = 0.2 | |
| 262 | - lcrv['etruemin'] = 1.0 | |
| 263 | - lcrv['etruemax'] = 100.0 | |
| 264 | - lcrv['etruebins'] = 5 | |
| 265 | - lcrv['statistic'] = 'WSTAT' | |
| 266 | - lcrv['outfile'] = 'cslightcrv_py5.fits' | |
| 267 | - lcrv['logfile'] = 'cslightcrv_py5.log' | |
| 268 | - lcrv['chatter'] = 4 | |
| 244 | + lcrv['inobs'] = self._offaxis_events | |
| 245 | + lcrv['inmodel'] = self._model_onoff | |
| 246 | + lcrv['srcname'] = 'Crab' | |
| 247 | + lcrv['caldb'] = self._caldb | |
| 248 | + lcrv['irf'] = self._irf | |
| 249 | + lcrv['tbinalg'] = 'LIN' | |
| 250 | + lcrv['tmin'] = '2020-01-01T00:00:00' | |
| 251 | + lcrv['tmax'] = '2020-01-01T00:05:00' | |
| 252 | + lcrv['tbins'] = 2 | |
| 253 | + lcrv['method'] = 'ONOFF' | |
| 254 | + lcrv['use_model_bkg'] = False # Needed even if WSTAT | |
| 255 | + lcrv['emin'] = 1.0 | |
| 256 | + lcrv['emax'] = 100.0 | |
| 257 | + lcrv['enumbins'] = 2 | |
| 258 | + lcrv['coordsys'] = 'CEL' | |
| 259 | + lcrv['xref'] = 83.63 | |
| 260 | + lcrv['yref'] = 22.01 | |
| 261 | + lcrv['rad'] = 0.2 | |
| 262 | + lcrv['etruemin'] = 1.0 | |
| 263 | + lcrv['etruemax'] = 100.0 | |
| 264 | + lcrv['etruebins'] = 5 | |
| 265 | + lcrv['statistic'] = 'WSTAT' | |
| 266 | + lcrv['outfile'] = 'cslightcrv_py5.fits' | |
| 267 | + lcrv['logfile'] = 'cslightcrv_py5.log' | |
| 268 | + lcrv['chatter'] = 4 | |
| 269 | 269 | |
| 270 | 270 | # Execute cslightcrv script |
| 271 | 271 | lcrv.execute() | ... | ... |