Commit 734b34828efb2718e8b6dd34633bb9b779f222c3

Authored by Jürgen Knödlseder
1 parent 83951372

Add "statistic" parameter to all likelihood scripts (#2237)

The scripts cslightcrv, csphasecrv, cspull, cssens, csspec, cstsdist, and cstsmapsplit now have a "statistics" parameter to allow setting of the optimizer statistic. Except of cstsmapsplit, all of the scripts now derive from the cslikelihood base class.
ChangeLog
1 -2017-10-21 1 +2017-10-22
2 2
3 * Version 1.5.0 released 3 * Version 1.5.0 released
4 ======================== 4 ========================
5 5
6 - Add "statistic" parameter to all likelihood tools (#2237) 6 + Add "statistic" parameter to all likelihood tools and scripts (#2237)
7 Rename ctlike "stat" parameter to "statistic" (#2237) 7 Rename ctlike "stat" parameter to "statistic" (#2237)
8 Enable handling of On/Off observations in csspec (#2231) 8 Enable handling of On/Off observations in csspec (#2231)
9 Add csphagen script (#2208) 9 Add csphagen script (#2208)
@@ -164,6 +164,10 @@ None @@ -164,6 +164,10 @@ None
164 164
165 cslightcrv - Generate light curve 165 cslightcrv - Generate light curve
166 --------------------------------- 166 ---------------------------------
  167 +The script now derived from the cslikelihood base class. A "statistic"
  168 +parameter was added to allow setting the optimizer statistic for the light
  169 +curve generation (#2237).
  170 +
167 Use t-type parameters for "tmin" and "tmax" to all specifying times in various 171 Use t-type parameters for "tmin" and "tmax" to all specifying times in various
168 formats (#1864). 172 formats (#1864).
169 173
@@ -185,8 +189,8 @@ None @@ -185,8 +189,8 @@ None
185 189
186 csmodelsois - Puts selected sources in diffuse model cube 190 csmodelsois - Puts selected sources in diffuse model cube
187 --------------------------------------------------------- 191 ---------------------------------------------------------
188 -Add csmodelsois script that replaces selected models in a model container by  
189 -a diffuse map cube (#2180). 192 +Add script that replaces selected models in a model container by a diffuse
  193 +map cube (#2180).
190 194
191 195
192 csobs2caldb - Generate calibration database entry for an IACT observation 196 csobs2caldb - Generate calibration database entry for an IACT observation
@@ -211,17 +215,22 @@ None @@ -211,17 +215,22 @@ None
211 215
212 csphagen - Generate On/Off observations 216 csphagen - Generate On/Off observations
213 --------------------------------------- 217 ---------------------------------------
214 -The script csphagen was added to allow the generation of PHA, ARF and RMF datasets  
215 -for classical On/Off IACT analysis (#2208). 218 +The script was added to allow the generation of PHA, ARF and RMF datasets for classical On/Off IACT analysis (#2208).
216 219
217 220
218 csphasecrv - Generate phase curve 221 csphasecrv - Generate phase curve
219 --------------------------------- 222 ---------------------------------
220 -None 223 +The script now derived from the cslikelihood base class. A "statistic"
  224 +parameter was added to allow setting the optimizer statistic for the light
  225 +curve generation (#2237).
221 226
222 227
223 cspull - Generate pull distributions 228 cspull - Generate pull distributions
224 ------------------------------------ 229 ------------------------------------
  230 +The script now derived from the cslikelihood base class. A "statistic"
  231 +parameter was added to allow setting the optimizer statistic for the pull
  232 +distribution generation (#2237).
  233 +
225 Use t-type parameters for "tmin" and "tmax" to all specifying times in various 234 Use t-type parameters for "tmin" and "tmax" to all specifying times in various
226 formats (#1864). 235 formats (#1864).
227 236
@@ -238,18 +247,20 @@ None @@ -238,18 +247,20 @@ None
238 247
239 cssens - Computes sensitivity curve 248 cssens - Computes sensitivity curve
240 ----------------------------------- 249 -----------------------------------
241 -None 250 +The script now derived from the cslikelihood base class. A "statistic"
  251 +parameter was added to allow setting the optimizer statistic for the sensitivity
  252 +computation (#2237).
242 253
243 254
244 csspec - Generates Spectral Energy Distribution 255 csspec - Generates Spectral Energy Distribution
245 ----------------------------------------------- 256 -----------------------------------------------
246 -The csspec script now derived from the cslikelihood base class. A "statistic" 257 +The script now derived from the cslikelihood base class. A "statistic"
247 parameter was added to allow setting the optimizer statistic for the spectrum 258 parameter was added to allow setting the optimizer statistic for the spectrum
248 generation (#2237). 259 generation (#2237).
249 260
250 -The csspec script now can also handle On/Off spectra for SED generation (#2231). 261 +The script now can also handle On/Off spectra for SED generation (#2231).
251 262
252 -The csspec script now can also handle non-CTA data. For that purpose a "method" 263 +The script now can also handle non-CTA data. For that purpose a "method"
253 parameter has been introduced that allows to selected between slicing of the data 264 parameter has been introduced that allows to selected between slicing of the data
254 (method="SLICE"), which is only supported for CTA observations, and replacing of 265 (method="SLICE"), which is only supported for CTA observations, and replacing of
255 the spectral model by a node function (method="NODES"). If method="AUTO" the tool 266 the spectral model by a node function (method="NODES"). If method="AUTO" the tool
@@ -264,6 +275,10 @@ None @@ -264,6 +275,10 @@ None
264 275
265 cstsdist - Computes Test Statistic distribution 276 cstsdist - Computes Test Statistic distribution
266 ----------------------------------------------- 277 -----------------------------------------------
  278 +The script now derived from the cslikelihood base class. A "statistic"
  279 +parameter was added to allow setting the optimizer statistic for the Test
  280 +Statistic distribution generation (#2237).
  281 +
267 Use t-type parameters for "tmin" and "tmax" to all specifying times in various 282 Use t-type parameters for "tmin" and "tmax" to all specifying times in various
268 formats (#1864). 283 formats (#1864).
269 284
@@ -275,7 +290,8 @@ None @@ -275,7 +290,8 @@ None
275 290
276 cstsmapsplit - Prepare split Test Statistic computation 291 cstsmapsplit - Prepare split Test Statistic computation
277 ------------------------------------------------------- 292 -------------------------------------------------------
278 -None 293 +A "statistic" parameter was added to allow setting the optimizer statistic for
  294 +the TS map generation (#2237).
279 295
280 296
281 csviscube - Generate visibility cube 297 csviscube - Generate visibility cube
cscripts/cslightcrv.par
@@ -42,6 +42,7 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE @@ -42,6 +42,7 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE
42 nxpix, i, a, 200,,, "Size of the X axis in pixels" 42 nxpix, i, a, 200,,, "Size of the X axis in pixels"
43 nypix, i, a, 200,,, "Size of the Y axis in pixels" 43 nypix, i, a, 200,,, "Size of the Y axis in pixels"
44 binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" 44 binsz, r, a, 0.02,,, "Pixel size (deg/pixel)"
  45 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
45 calc_ts, b, h, yes,,, "Compute TS value for each bin?" 46 calc_ts, b, h, yes,,, "Compute TS value for each bin?"
46 calc_ulim, b, h, yes,,, "Compute upper limit for each bin?" 47 calc_ulim, b, h, yes,,, "Compute upper limit for each bin?"
47 fix_srcs, b, h, yes,,, "Fix other sky model parameters?" 48 fix_srcs, b, h, yes,,, "Fix other sky model parameters?"
cscripts/cslightcrv.py
@@ -28,7 +28,7 @@ from cscripts import ioutils @@ -28,7 +28,7 @@ from cscripts import ioutils
28 # ================ # 28 # ================ #
29 # cslightcrv class # 29 # cslightcrv class #
30 # ================ # 30 # ================ #
31 -class cslightcrv(ctools.cscript): 31 +class cslightcrv(ctools.cslikelihood):
32 """ 32 """
33 Generates a lightcurve 33 Generates a lightcurve
34 34
@@ -68,9 +68,8 @@ class cslightcrv(ctools.cscript): @@ -68,9 +68,8 @@ class cslightcrv(ctools.cscript):
68 """ 68 """
69 Constructor 69 Constructor
70 """ 70 """
71 - # Set name  
72 - self._name = 'cslightcrv'  
73 - self._version = ctools.__version__ 71 + # Initialise application by calling the appropriate class constructor
  72 + self._init_cslikelihood('cslightcrv', ctools.__version__, argv)
74 73
75 # Initialise some members 74 # Initialise some members
76 self._srcname = '' 75 self._srcname = ''
@@ -78,12 +77,6 @@ class cslightcrv(ctools.cscript): @@ -78,12 +77,6 @@ class cslightcrv(ctools.cscript):
78 self._stacked = False 77 self._stacked = False
79 self._fits = gammalib.GFits() 78 self._fits = gammalib.GFits()
80 79
81 - # Initialise observation container from constructor arguments.  
82 - self._obs, argv = self._set_input_obs(argv)  
83 -  
84 - # Initialise script by calling the appropriate class constructor.  
85 - self._init_cscript(argv)  
86 -  
87 # Return 80 # Return
88 return 81 return
89 82
@@ -95,11 +88,14 @@ class cslightcrv(ctools.cscript): @@ -95,11 +88,14 @@ class cslightcrv(ctools.cscript):
95 """ 88 """
96 # Setup observations (require response and allow event list, don't 89 # Setup observations (require response and allow event list, don't
97 # allow counts cube) 90 # allow counts cube)
98 - self._setup_observations(self._obs, True, True, False) 91 + self._setup_observations(self.obs(), True, True, False)
  92 +
  93 + # Set observation statistic
  94 + self._set_obs_statistic(gammalib.toupper(self['statistic'].string()))
99 95
100 # Set models if there are none in the container 96 # Set models if there are none in the container
101 - if self._obs.models().size() == 0:  
102 - self._obs.models(self['inmodel'].filename()) 97 + if self.obs().models().size() == 0:
  98 + self.obs().models(self['inmodel'].filename())
103 99
104 # Get source name 100 # Get source name
105 self._srcname = self['srcname'].string() 101 self._srcname = self['srcname'].string()
@@ -188,7 +184,7 @@ class cslightcrv(ctools.cscript): @@ -188,7 +184,7 @@ class cslightcrv(ctools.cscript):
188 elif algorithm == 'GTI': 184 elif algorithm == 'GTI':
189 185
190 # Append the GTIs of all observations 186 # Append the GTIs of all observations
191 - for obs in self._obs: 187 + for obs in self.obs():
192 for i in range(obs.events().gti().size()): 188 for i in range(obs.events().gti().size()):
193 gti.append(obs.events().gti().tstart(i), 189 gti.append(obs.events().gti().tstart(i),
194 obs.events().gti().tstop(i)) 190 obs.events().gti().tstop(i))
@@ -209,7 +205,7 @@ class cslightcrv(ctools.cscript): @@ -209,7 +205,7 @@ class cslightcrv(ctools.cscript):
209 names = [] 205 names = []
210 206
211 # Collect list of free parameter names 207 # Collect list of free parameter names
212 - for par in self._obs.models()[self._srcname]: 208 + for par in self.obs().models()[self._srcname]:
213 if par.is_free(): 209 if par.is_free():
214 names.append(par.name()) 210 names.append(par.name())
215 211
@@ -221,12 +217,10 @@ class cslightcrv(ctools.cscript): @@ -221,12 +217,10 @@ class cslightcrv(ctools.cscript):
221 Adjust model parameters dependent on user parameters 217 Adjust model parameters dependent on user parameters
222 """ 218 """
223 # Write header 219 # Write header
224 - if self._logTerse():  
225 - self._log('\n')  
226 - self._log.header1('Adjust model parameters') 220 + self._log_header1(gammalib.TERSE, 'Adjust model parameters')
227 221
228 # Adjust model parameters dependent on input user parameters 222 # Adjust model parameters dependent on input user parameters
229 - for model in self._obs.models(): 223 + for model in self.obs().models():
230 224
231 # Set TS flag for all models to false. The source of interest will 225 # Set TS flag for all models to false. The source of interest will
232 # be set to true later 226 # be set to true later
@@ -237,8 +231,7 @@ class cslightcrv(ctools.cscript): @@ -237,8 +231,7 @@ class cslightcrv(ctools.cscript):
237 classname = model.classname() 231 classname = model.classname()
238 232
239 # Log model name 233 # Log model name
240 - if self._logNormal():  
241 - self._log.header3(model.name()) 234 + self._log_header3(gammalib.NORMAL, model.name())
242 235
243 # If the model is the source of interest and the 'calc_ts' parameter 236 # If the model is the source of interest and the 'calc_ts' parameter
244 # is true then enable the TS computation for the source 237 # is true then enable the TS computation for the source
@@ -254,9 +247,7 @@ class cslightcrv(ctools.cscript): @@ -254,9 +247,7 @@ class cslightcrv(ctools.cscript):
254 for par in model: 247 for par in model:
255 if par.is_free(): 248 if par.is_free():
256 par.fix() 249 par.fix()
257 - if self._logNormal():  
258 - self._log(gammalib.parformat(par.name()))  
259 - self._log('fixed\n') 250 + self._log_value(gammalib.NORMAL, par.name(), 'fixed')
260 251
261 # Return 252 # Return
262 return 253 return
@@ -287,7 +278,8 @@ class cslightcrv(ctools.cscript): @@ -287,7 +278,8 @@ class cslightcrv(ctools.cscript):
287 ioutils.append_result_column(table, results, 'e_MJD', 'days', 'e_mjd') 278 ioutils.append_result_column(table, results, 'e_MJD', 'days', 'e_mjd')
288 279
289 # Append parameter columns 280 # Append parameter columns
290 - ioutils.append_model_par_column(table, self._obs.models()[self._srcname], 281 + ioutils.append_model_par_column(table,
  282 + self.obs().models()[self._srcname],
291 results) 283 results)
292 284
293 # Append Test Statistic column "TS" 285 # Append Test Statistic column "TS"
@@ -327,8 +319,7 @@ class cslightcrv(ctools.cscript): @@ -327,8 +319,7 @@ class cslightcrv(ctools.cscript):
327 if self['calc_ulim'].boolean(): 319 if self['calc_ulim'].boolean():
328 320
329 # Write header in logger 321 # Write header in logger
330 - if self._logExplicit():  
331 - self._log.header3('Computing upper limit') 322 + self._log_header3(gammalib.EXPLICIT, 'Computing upper limit')
332 323
333 # Create copy of observations 324 # Create copy of observations
334 cpy_obs = obs.copy() 325 cpy_obs = obs.copy()
@@ -358,8 +349,7 @@ class cslightcrv(ctools.cscript): @@ -358,8 +349,7 @@ class cslightcrv(ctools.cscript):
358 ul_flux = ulimit.flux_ulimit() 349 ul_flux = ulimit.flux_ulimit()
359 ul_eflux = ulimit.eflux_ulimit() 350 ul_eflux = ulimit.eflux_ulimit()
360 except: 351 except:
361 - if self._logTerse():  
362 - self._log('Upper limit calculation failed.\n') 352 + self._log_string(gammalib.TERSE, 'Upper limit calculation failed.')
363 ul_diff = -1.0 353 ul_diff = -1.0
364 ul_flux = -1.0 354 ul_flux = -1.0
365 ul_eflux = -1.0 355 ul_eflux = -1.0
@@ -414,14 +404,14 @@ class cslightcrv(ctools.cscript): @@ -414,14 +404,14 @@ class cslightcrv(ctools.cscript):
414 self._get_parameters() 404 self._get_parameters()
415 405
416 # Write observation into logger 406 # Write observation into logger
417 - self._log_observations(gammalib.NORMAL, self._obs, 'Observation') 407 + self._log_observations(gammalib.NORMAL, self.obs(), 'Observation')
418 408
419 # Get time boundaries 409 # Get time boundaries
420 tmin = self._tbins.tstart(0) 410 tmin = self._tbins.tstart(0)
421 tmax = self._tbins.tstop(self._tbins.size()-1) 411 tmax = self._tbins.tstop(self._tbins.size()-1)
422 412
423 # Select events 413 # Select events
424 - select = ctools.ctselect(self._obs) 414 + select = ctools.ctselect(self.obs())
425 select['emin'] = self['emin'].real() 415 select['emin'] = self['emin'].real()
426 select['emax'] = self['emax'].real() 416 select['emax'] = self['emax'].real()
427 select['tmin'] = tmin.convert(self._time_reference()) 417 select['tmin'] = tmin.convert(self._time_reference())
@@ -432,22 +422,18 @@ class cslightcrv(ctools.cscript): @@ -432,22 +422,18 @@ class cslightcrv(ctools.cscript):
432 select.run() 422 select.run()
433 423
434 # Extract observations 424 # Extract observations
435 - self._obs = select.obs().copy() 425 + self.obs(select.obs().copy())
436 426
437 # Write observation into logger 427 # Write observation into logger
438 - if self._logTerse():  
439 - self._log('\n')  
440 - self._log.header1(gammalib.number('Selected observation',len(self._obs)))  
441 - self._log(str(self._obs))  
442 - self._log('\n') 428 + self._log_header1(gammalib.TERSE,
  429 + gammalib.number('Selected observation',
  430 + len(self.obs())))
443 431
444 # Adjust model parameters dependent on user parameters 432 # Adjust model parameters dependent on user parameters
445 self._adjust_model_pars() 433 self._adjust_model_pars()
446 434
447 # Write header 435 # Write header
448 - if self._logTerse():  
449 - self._log('\n')  
450 - self._log.header1('Generate lightcurve') 436 + self._log_header1(gammalib.TERSE, 'Generate lightcurve')
451 437
452 # Initialise list of result dictionaries 438 # Initialise list of result dictionaries
453 results = [] 439 results = []
@@ -463,8 +449,8 @@ class cslightcrv(ctools.cscript): @@ -463,8 +449,8 @@ class cslightcrv(ctools.cscript):
463 tmax = self._tbins.tstop(i) 449 tmax = self._tbins.tstop(i)
464 450
465 # Write time bin into header 451 # Write time bin into header
466 - if self._logTerse():  
467 - self._log.header2('MJD '+str(tmin.mjd())+'-'+str(tmax.mjd())) 452 + self._log_header2(gammalib.TERSE, 'MJD %f - %f ' %
  453 + (tmin.mjd(), tmax.mjd()))
468 454
469 # Compute time bin center and time width 455 # Compute time bin center and time width
470 twidth = 0.5 * (tmax - tmin) # in seconds 456 twidth = 0.5 * (tmax - tmin) # in seconds
@@ -481,11 +467,10 @@ class cslightcrv(ctools.cscript): @@ -481,11 +467,10 @@ class cslightcrv(ctools.cscript):
481 'values': {}} 467 'values': {}}
482 468
483 # Log information 469 # Log information
484 - if self._logExplicit():  
485 - self._log.header3('Selecting events') 470 + self._log_header3(gammalib.EXPLICIT, 'Selecting events')
486 471
487 # Select events 472 # Select events
488 - select = ctools.ctselect(self._obs) 473 + select = ctools.ctselect(self.obs())
489 select['emin'] = self['emin'].real() 474 select['emin'] = self['emin'].real()
490 select['emax'] = self['emax'].real() 475 select['emax'] = self['emax'].real()
491 select['tmin'] = tmin.convert(self._time_reference()) 476 select['tmin'] = tmin.convert(self._time_reference())
@@ -505,8 +490,7 @@ class cslightcrv(ctools.cscript): @@ -505,8 +490,7 @@ class cslightcrv(ctools.cscript):
505 obs = self._bin_observation(obs) 490 obs = self._bin_observation(obs)
506 491
507 # Header 492 # Header
508 - if self._logExplicit():  
509 - self._log.header3('Fitting the data') 493 + self._log_header3(gammalib.EXPLICIT, 'Fitting the data')
510 494
511 # Do maximum likelihood model fitting 495 # Do maximum likelihood model fitting
512 like = ctools.ctlike(obs) 496 like = ctools.ctlike(obs)
@@ -626,7 +610,7 @@ class cslightcrv(ctools.cscript): @@ -626,7 +610,7 @@ class cslightcrv(ctools.cscript):
626 610
627 # Set default name is user name is empty 611 # Set default name is user name is empty
628 if not name: 612 if not name:
629 - user_name = self._name 613 + user_name = self._name()
630 else: 614 else:
631 user_name = name 615 user_name = name
632 616
@@ -661,7 +645,7 @@ class cslightcrv(ctools.cscript): @@ -661,7 +645,7 @@ class cslightcrv(ctools.cscript):
661 Set model container 645 Set model container
662 """ 646 """
663 # Copy models 647 # Copy models
664 - self._obs.models(models) 648 + self.obs().models(models)
665 649
666 # Return 650 # Return
667 return 651 return
cscripts/csphasecrv.par
@@ -40,6 +40,7 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE @@ -40,6 +40,7 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE
40 nxpix, i, a, 200,,, "Size of the X axis in pixels" 40 nxpix, i, a, 200,,, "Size of the X axis in pixels"
41 nypix, i, a, 200,,, "Size of the Y axis in pixels" 41 nypix, i, a, 200,,, "Size of the Y axis in pixels"
42 binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" 42 binsz, r, a, 0.02,,, "Pixel size (deg/pixel)"
  43 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
43 44
44 # 45 #
45 # Standard parameters 46 # Standard parameters
cscripts/csphasecrv.py
@@ -28,7 +28,7 @@ from cscripts import ioutils @@ -28,7 +28,7 @@ from cscripts import ioutils
28 # ================ # 28 # ================ #
29 # csphasecrv class # 29 # csphasecrv class #
30 # ================ # 30 # ================ #
31 -class csphasecrv(ctools.cscript): 31 +class csphasecrv(ctools.cslikelihood):
32 """ 32 """
33 Generates spectra in phase bins 33 Generates spectra in phase bins
34 34
@@ -56,9 +56,8 @@ class csphasecrv(ctools.cscript): @@ -56,9 +56,8 @@ class csphasecrv(ctools.cscript):
56 """ 56 """
57 Constructor 57 Constructor
58 """ 58 """
59 - # Set name  
60 - self._name = 'csphasecrv'  
61 - self._version = ctools.__version__ 59 + # Initialise application by calling the appropriate class constructor
  60 + self._init_cslikelihood('csphasecrv', ctools.__version__, argv)
62 61
63 # Initialise some members. Phases are stored in a nested list 62 # Initialise some members. Phases are stored in a nested list
64 # [[ph1min,ph1max], [ph2min,ph2max],..] 63 # [[ph1min,ph1max], [ph2min,ph2max],..]
@@ -68,12 +67,6 @@ class csphasecrv(ctools.cscript): @@ -68,12 +67,6 @@ class csphasecrv(ctools.cscript):
68 self._fits = gammalib.GFits() 67 self._fits = gammalib.GFits()
69 self._fitmodels = {} 68 self._fitmodels = {}
70 69
71 - # Initialise observation container from constructor arguments.  
72 - self._obs, argv = self._set_input_obs(argv)  
73 -  
74 - # Initialise script by calling the appropriate class constructor.  
75 - self._init_cscript(argv)  
76 -  
77 # Return 70 # Return
78 return 71 return
79 72
@@ -84,11 +77,14 @@ class csphasecrv(ctools.cscript): @@ -84,11 +77,14 @@ class csphasecrv(ctools.cscript):
84 """ 77 """
85 # Setup observations (require response and allow event list, don't 78 # Setup observations (require response and allow event list, don't
86 # allow counts cube) 79 # allow counts cube)
87 - self._setup_observations(self._obs, True, True, False) 80 + self._setup_observations(self.obs(), True, True, False)
  81 +
  82 + # Set observation statistic
  83 + self._set_obs_statistic(gammalib.toupper(self['statistic'].string()))
88 84
89 # Set models if there are none in the container 85 # Set models if there are none in the container
90 - if self._obs.models().size() == 0:  
91 - self._obs.models(self['inmodel'].filename()) 86 + if self.obs().models().size() == 0:
  87 + self.obs().models(self['inmodel'].filename())
92 88
93 # Get source name 89 # Get source name
94 self._srcname = self['srcname'].string() 90 self._srcname = self['srcname'].string()
@@ -101,7 +97,7 @@ class csphasecrv(ctools.cscript): @@ -101,7 +97,7 @@ class csphasecrv(ctools.cscript):
101 97
102 # Query the hidden parameters, just in case 98 # Query the hidden parameters, just in case
103 self['edisp'].boolean() 99 self['edisp'].boolean()
104 - 100 +
105 # Read ahead output parameters 101 # Read ahead output parameters
106 if self._read_ahead(): 102 if self._read_ahead():
107 self['outfile'].filename() 103 self['outfile'].filename()
@@ -176,7 +172,7 @@ class csphasecrv(ctools.cscript): @@ -176,7 +172,7 @@ class csphasecrv(ctools.cscript):
176 names = [] 172 names = []
177 173
178 # Collect list of free parameter names 174 # Collect list of free parameter names
179 - for par in self._obs.models()[self._srcname]: 175 + for par in self.obs().models()[self._srcname]:
180 if par.is_free(): 176 if par.is_free():
181 names.append(par.name()) 177 names.append(par.name())
182 178
@@ -209,7 +205,7 @@ class csphasecrv(ctools.cscript): @@ -209,7 +205,7 @@ class csphasecrv(ctools.cscript):
209 ioutils.append_result_column(table, results, 'PHASE_MAX', '', 'phmax') 205 ioutils.append_result_column(table, results, 'PHASE_MAX', '', 'phmax')
210 206
211 # Append parameter columns 207 # Append parameter columns
212 - ioutils.append_model_par_column(table, self._obs.models()[self._srcname], 208 + ioutils.append_model_par_column(table, self.obs().models()[self._srcname],
213 results) 209 results)
214 210
215 # Return table 211 # Return table
@@ -323,10 +319,10 @@ class csphasecrv(ctools.cscript): @@ -323,10 +319,10 @@ class csphasecrv(ctools.cscript):
323 self._get_parameters() 319 self._get_parameters()
324 320
325 # Write observation into logger 321 # Write observation into logger
326 - self._log_observations(gammalib.NORMAL, self._obs, 'Observation') 322 + self._log_observations(gammalib.NORMAL, self.obs(), 'Observation')
327 323
328 # Store and clear observations to split them into phase bins 324 # Store and clear observations to split them into phase bins
329 - orig_obs = self._obs.copy() 325 + orig_obs = self.obs().copy()
330 326
331 # Dictionary to save phase fitted models 327 # Dictionary to save phase fitted models
332 self._fitmodels = {} 328 self._fitmodels = {}
@@ -338,8 +334,8 @@ class csphasecrv(ctools.cscript): @@ -338,8 +334,8 @@ class csphasecrv(ctools.cscript):
338 for phbin in self._phbins: 334 for phbin in self._phbins:
339 335
340 # Write time bin into header 336 # Write time bin into header
341 - if self._logTerse():  
342 - self._log.header2('PHASE '+str(phbin[0])+'-'+str(phbin[1])) 337 + self._log_header2(gammalib.TERSE, 'PHASE %f - %f' %
  338 + (phbin[0], phbin[1]))
343 339
344 # Select events 340 # Select events
345 select = ctools.ctselect(orig_obs) 341 select = ctools.ctselect(orig_obs)
@@ -363,12 +359,10 @@ class csphasecrv(ctools.cscript): @@ -363,12 +359,10 @@ class csphasecrv(ctools.cscript):
363 # and compute the stacked response functions and setup 359 # and compute the stacked response functions and setup
364 # an observation container with a single stacked observation. 360 # an observation container with a single stacked observation.
365 if self._stacked: 361 if self._stacked:
366 - #obs = self._bin_observation(select.obs())  
367 obs = obsutils.get_stacked_obs(self, select.obs()) 362 obs = obsutils.get_stacked_obs(self, select.obs())
368 363
369 # Header 364 # Header
370 - if self._logExplicit():  
371 - self._log.header3('Fitting the data') 365 + self._log_header3(gammalib.EXPLICIT, 'Fitting the data')
372 366
373 # Do maximum likelihood model fitting 367 # Do maximum likelihood model fitting
374 like = ctools.ctlike(obs) 368 like = ctools.ctlike(obs)
@@ -378,11 +372,12 @@ class csphasecrv(ctools.cscript): @@ -378,11 +372,12 @@ class csphasecrv(ctools.cscript):
378 # Renormalize models to phase selection 372 # Renormalize models to phase selection
379 # TODO move the scaling from the temporal to the spectral component 373 # TODO move the scaling from the temporal to the spectral component
380 for model in like.obs().models(): 374 for model in like.obs().models():
381 - scaled_norm = model['Normalization'].value()/(phbin[1] - phbin[0]) 375 + scaled_norm = model['Normalization'].value()/(phbin[1]-phbin[0])
382 model['Normalization'].value(scaled_norm) 376 model['Normalization'].value(scaled_norm)
383 377
384 # Store fit model 378 # Store fit model
385 - self._fitmodels[str(phbin[0])+'-'+str(phbin[1])] = like.obs().models().copy() 379 + self._fitmodels[str(phbin[0])+'-'+str(phbin[1])] = \
  380 + like.obs().models().copy()
386 381
387 # Create FITS file 382 # Create FITS file
388 self._create_fits() 383 self._create_fits()
@@ -424,7 +419,7 @@ class csphasecrv(ctools.cscript): @@ -424,7 +419,7 @@ class csphasecrv(ctools.cscript):
424 419
425 # Set default name is user name is empty 420 # Set default name is user name is empty
426 if not name: 421 if not name:
427 - user_name = self._name 422 + user_name = self._name()
428 else: 423 else:
429 user_name = name 424 user_name = name
430 425
cscripts/cspull.par
@@ -27,21 +27,22 @@ outfile, f, a, pull.dat,,, "Output pull distribution file" @@ -27,21 +27,22 @@ outfile, f, a, pull.dat,,, "Output pull distribution file"
27 # 27 #
28 # Script parameters 28 # Script parameters
29 #================== 29 #==================
30 -ntrials, i, a, 10,,, "Number of trials"  
31 -ra, r, a, 83.6331,0,360, "RA of pointing (degrees)"  
32 -dec, r, a, 22.0145,-90,90, "Dec of pointing (degrees)"  
33 -rad, r, h, 5.0,0,180, "Radius of ROI (degrees)"  
34 -coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)"  
35 -proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method"  
36 -emin, r, a, 0.1,,, "Lower energy limit (TeV)"  
37 -emax, r, a, 100.0,,, "Upper energy limit (TeV)"  
38 -enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)"  
39 -tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"  
40 -tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"  
41 -npix, i, a, 200,,, "Number of pixels for binned"  
42 -binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)"  
43 -profile, b, h, no,,, "Use likelihood profile method for errors?"  
44 -seed, i, h, 1,,, "Initial random number generator seed" 30 +ntrials, i, a, 10,,, "Number of trials"
  31 +ra, r, a, 83.6331,0,360, "RA of pointing (degrees)"
  32 +dec, r, a, 22.0145,-90,90, "Dec of pointing (degrees)"
  33 +rad, r, h, 5.0,0,180, "Radius of ROI (degrees)"
  34 +coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)"
  35 +proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method"
  36 +emin, r, a, 0.1,,, "Lower energy limit (TeV)"
  37 +emax, r, a, 100.0,,, "Upper energy limit (TeV)"
  38 +enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)"
  39 +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"
  40 +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"
  41 +npix, i, a, 200,,, "Number of pixels for binned"
  42 +binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)"
  43 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  44 +profile, b, h, no,,, "Use likelihood profile method for errors?"
  45 +seed, i, h, 1,,, "Initial random number generator seed"
45 46
46 # 47 #
47 # Standard parameters 48 # Standard parameters
cscripts/cspull.py
@@ -28,7 +28,7 @@ from cscripts import ioutils @@ -28,7 +28,7 @@ from cscripts import ioutils
28 # ============ # 28 # ============ #
29 # cspull class # 29 # cspull class #
30 # ============ # 30 # ============ #
31 -class cspull(ctools.cscript): 31 +class cspull(ctools.cslikelihood):
32 """ 32 """
33 Generates pull distributions for a model 33 Generates pull distributions for a model
34 """ 34 """
@@ -37,9 +37,8 @@ class cspull(ctools.cscript): @@ -37,9 +37,8 @@ class cspull(ctools.cscript):
37 """ 37 """
38 Constructor 38 Constructor
39 """ 39 """
40 - # Set name  
41 - self._name = 'cspull'  
42 - self._version = ctools.__version__ 40 + # Initialise application by calling the appropriate class constructor
  41 + self._init_cslikelihood('cspull', ctools.__version__, argv)
43 42
44 # Initialise some members 43 # Initialise some members
45 self._edisp = False 44 self._edisp = False
@@ -53,12 +52,6 @@ class cspull(ctools.cscript): @@ -53,12 +52,6 @@ class cspull(ctools.cscript):
53 self._seed = 1 52 self._seed = 1
54 self._chatter = 2 53 self._chatter = 2
55 54
56 - # Initialise observation container from constructor arguments  
57 - self._obs, argv = self._set_input_obs(argv)  
58 -  
59 - # Initialise application by calling the appropriate class constructor  
60 - self._init_cscript(argv)  
61 -  
62 # Return 55 # Return
63 return 56 return
64 57
@@ -69,13 +62,16 @@ class cspull(ctools.cscript): @@ -69,13 +62,16 @@ class cspull(ctools.cscript):
69 Get parameters from parfile 62 Get parameters from parfile
70 """ 63 """
71 # If there are no observations in container then get some ... 64 # If there are no observations in container then get some ...
72 - if self._obs.size() == 0:  
73 - self._obs = self._get_observations() 65 + if self.obs().size() == 0:
  66 + self.obs(self._get_observations())
74 67
75 # ... otherwise add response information and energy boundaries 68 # ... otherwise add response information and energy boundaries
76 # in case they are missing 69 # in case they are missing
77 else: 70 else:
78 - self._setup_observations(self._obs) 71 + self._setup_observations(self.obs())
  72 +
  73 + # Set observation statistic
  74 + self._set_obs_statistic(gammalib.toupper(self['statistic'].string()))
79 75
80 # Get number of energy bins 76 # Get number of energy bins
81 self._enumbins = self['enumbins'].integer() 77 self._enumbins = self['enumbins'].integer()
@@ -88,8 +84,8 @@ class cspull(ctools.cscript): @@ -88,8 +84,8 @@ class cspull(ctools.cscript):
88 self._proj = self['proj'].string() 84 self._proj = self['proj'].string()
89 85
90 # Set models if we have none 86 # Set models if we have none
91 - if self._obs.models().size() == 0:  
92 - self._obs.models(self['inmodel'].filename()) 87 + if self.obs().models().size() == 0:
  88 + self.obs().models(self['inmodel'].filename())
93 89
94 # Read other parameters 90 # Read other parameters
95 self._ntrials = self['ntrials'].integer() 91 self._ntrials = self['ntrials'].integer()
@@ -168,7 +164,7 @@ class cspull(ctools.cscript): @@ -168,7 +164,7 @@ class cspull(ctools.cscript):
168 emax = None 164 emax = None
169 165
170 # Simulate events 166 # Simulate events
171 - obs = obsutils.sim(self._obs, 167 + obs = obsutils.sim(self.obs(),
172 emin=emin, 168 emin=emin,
173 emax=emax, 169 emax=emax,
174 nbins=self._enumbins, 170 nbins=self._enumbins,
@@ -190,7 +186,7 @@ class cspull(ctools.cscript): @@ -190,7 +186,7 @@ class cspull(ctools.cscript):
190 186
191 # Write simulation results 187 # Write simulation results
192 self._log_header3(gammalib.NORMAL, 'Simulation') 188 self._log_header3(gammalib.NORMAL, 'Simulation')
193 - for run in self._obs: 189 + for run in self.obs():
194 self._log_value(gammalib.NORMAL, 'Input observation %s' % run.id(), 190 self._log_value(gammalib.NORMAL, 'Input observation %s' % run.id(),
195 self._obs_string(run)) 191 self._obs_string(run))
196 for run in obs: 192 for run in obs:
@@ -200,7 +196,7 @@ class cspull(ctools.cscript): @@ -200,7 +196,7 @@ class cspull(ctools.cscript):
200 196
201 # Fit model 197 # Fit model
202 if self['profile'].boolean(): 198 if self['profile'].boolean():
203 - models = self._obs.models() 199 + models = self.obs().models()
204 for model in models: 200 for model in models:
205 like = ctools.cterror(obs) 201 like = ctools.cterror(obs)
206 like['srcname'] = model.name() 202 like['srcname'] = model.name()
@@ -256,7 +252,7 @@ class cspull(ctools.cscript): @@ -256,7 +252,7 @@ class cspull(ctools.cscript):
256 # (fitted - true) / error 252 # (fitted - true) / error
257 # In case that the error is 0 the pull is set to 99 253 # In case that the error is 0 the pull is set to 99
258 fitted_value = par.value() 254 fitted_value = par.value()
259 - real_value = self._obs.models()[i][k].value() 255 + real_value = self.obs().models()[i][k].value()
260 error = par.error() 256 error = par.error()
261 if error != 0.0: 257 if error != 0.0:
262 pull = (fitted_value - real_value) / error 258 pull = (fitted_value - real_value) / error
@@ -292,7 +288,7 @@ class cspull(ctools.cscript): @@ -292,7 +288,7 @@ class cspull(ctools.cscript):
292 self._get_parameters() 288 self._get_parameters()
293 289
294 # Write observation into logger 290 # Write observation into logger
295 - self._log_observations(gammalib.NORMAL, self._obs, 'Input observation') 291 + self._log_observations(gammalib.NORMAL, self.obs(), 'Input observation')
296 292
297 # Write header 293 # Write header
298 self._log_header1(gammalib.TERSE, 'Generate pull distribution') 294 self._log_header1(gammalib.TERSE, 'Generate pull distribution')
@@ -320,7 +316,7 @@ class cspull(ctools.cscript): @@ -320,7 +316,7 @@ class cspull(ctools.cscript):
320 Set model container 316 Set model container
321 """ 317 """
322 # Set model container 318 # Set model container
323 - self._obs.models(models) 319 + self.obs().models(models)
324 320
325 # Return 321 # Return
326 return 322 return
cscripts/cssens.par
@@ -28,18 +28,19 @@ outfile, f, h, sensitivity.dat,,, "Output sensitivity ASCII file" @@ -28,18 +28,19 @@ outfile, f, h, sensitivity.dat,,, "Output sensitivity ASCII file"
28 # 28 #
29 # Script parameters 29 # Script parameters
30 #================== 30 #==================
31 -offset, r, h, 0.0,,, "Source offset angle (deg)"  
32 -duration, r, a, 180000.0,,, "Effective exposure time (s)"  
33 -rad, r, a, 5.0,,, "Radius of ROI (deg)"  
34 -emin, r, a, 0.03163,,, "Lower energy limit (TeV)"  
35 -emax, r, a, 125.8925,,, "Upper energy limit (TeV)"  
36 -bins, i, a, 18,,, "Number of energy bins for differential sensitivity computation"  
37 -enumbins, i, h, 0,,, "Number of energy bins for binned analysis (0=unbinned)"  
38 -npix, i, h, 200,,, "Number of pixels for binned analysis"  
39 -binsz, r, h, 0.05,,, "Pixel size for binned analysis (deg/pixel)"  
40 -type, s, h, Differential,Differential|Integral,, "Sensitivity type"  
41 -sigma, r, h, 5.0,,, "Significance threshold (Gaussian sigma)"  
42 -max_iter, i, h, 50,,, "Maximum number of iterations" 31 +offset, r, h, 0.0,,, "Source offset angle (deg)"
  32 +duration, r, a, 180000.0,,, "Effective exposure time (s)"
  33 +rad, r, a, 5.0,,, "Radius of ROI (deg)"
  34 +emin, r, a, 0.03163,,, "Lower energy limit (TeV)"
  35 +emax, r, a, 125.8925,,, "Upper energy limit (TeV)"
  36 +bins, i, a, 18,,, "Number of energy bins for differential sensitivity computation"
  37 +enumbins, i, h, 0,,, "Number of energy bins for binned analysis (0=unbinned)"
  38 +npix, i, h, 200,,, "Number of pixels for binned analysis"
  39 +binsz, r, h, 0.05,,, "Pixel size for binned analysis (deg/pixel)"
  40 +type, s, h, Differential,Differential|Integral,, "Sensitivity type"
  41 +sigma, r, h, 5.0,,, "Significance threshold (Gaussian sigma)"
  42 +max_iter, i, h, 50,,, "Maximum number of iterations"
  43 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
43 44
44 # 45 #
45 # Standard parameters 46 # Standard parameters
cscripts/cssens.py
@@ -30,7 +30,7 @@ from cscripts import ioutils @@ -30,7 +30,7 @@ from cscripts import ioutils
30 # ============ # 30 # ============ #
31 # cssens class # 31 # cssens class #
32 # ============ # 32 # ============ #
33 -class cssens(ctools.cscript): 33 +class cssens(ctools.cslikelihood):
34 """ 34 """
35 Computes the CTA sensitivity 35 Computes the CTA sensitivity
36 36
@@ -47,9 +47,8 @@ class cssens(ctools.cscript): @@ -47,9 +47,8 @@ class cssens(ctools.cscript):
47 """ 47 """
48 Constructor. 48 Constructor.
49 """ 49 """
50 - # Set name  
51 - self._name = 'cssens'  
52 - self._version = ctools.__version__ 50 + # Initialise application by calling the appropriate class constructor
  51 + self._init_cslikelihood('cssens', ctools.__version__, argv)
53 52
54 # Initialise class members 53 # Initialise class members
55 self._ebounds = gammalib.GEbounds() 54 self._ebounds = gammalib.GEbounds()
@@ -59,12 +58,6 @@ class cssens(ctools.cscript): @@ -59,12 +58,6 @@ class cssens(ctools.cscript):
59 self._dec = None 58 self._dec = None
60 self._log_clients = False 59 self._log_clients = False
61 60
62 - # Initialise observation container from constructor arguments  
63 - self._obs, argv = self._set_input_obs(argv)  
64 -  
65 - # Initialise application by calling the appropriate class constructor  
66 - self._init_cscript(argv)  
67 -  
68 # Return 61 # Return
69 return 62 return
70 63
@@ -75,12 +68,15 @@ class cssens(ctools.cscript): @@ -75,12 +68,15 @@ class cssens(ctools.cscript):
75 Get user parameters from parfile 68 Get user parameters from parfile
76 """ 69 """
77 # Set observation if not done before 70 # Set observation if not done before
78 - if self._obs.size() == 0:  
79 - self._obs = self._set_obs(self['emin'].real(), self['emax'].real()) 71 + if self.obs().size() == 0:
  72 + self.obs(self._set_obs(self['emin'].real(), self['emax'].real()))
  73 +
  74 + # Set observation statistic
  75 + self._set_obs_statistic(gammalib.toupper(self['statistic'].string()))
80 76
81 # Set models if we have none 77 # Set models if we have none
82 - if self._obs.models().size() == 0:  
83 - self._obs.models(self['inmodel'].filename()) 78 + if self.obs().models().size() == 0:
  79 + self.obs().models(self['inmodel'].filename())
84 80
85 # Get source name 81 # Get source name
86 self._srcname = self['srcname'].string() 82 self._srcname = self['srcname'].string()
@@ -186,7 +182,7 @@ class cssens(ctools.cscript): @@ -186,7 +182,7 @@ class cssens(ctools.cscript):
186 Maximum energy 182 Maximum energy
187 """ 183 """
188 # Loop over all observations in container 184 # Loop over all observations in container
189 - for i, obs in enumerate(self._obs): 185 + for i, obs in enumerate(self.obs()):
190 186
191 # Get energy boundaries of the observation 187 # Get energy boundaries of the observation
192 obs_ebounds = self._obs_ebounds[i] 188 obs_ebounds = self._obs_ebounds[i]
@@ -337,11 +333,11 @@ class cssens(ctools.cscript): @@ -337,11 +333,11 @@ class cssens(ctools.cscript):
337 models = test_model.copy() 333 models = test_model.copy()
338 crab_prefactor = models[self._srcname]['Prefactor'].value() * crab_unit 334 crab_prefactor = models[self._srcname]['Prefactor'].value() * crab_unit
339 models[self._srcname]['Prefactor'].value(crab_prefactor * test_crab_flux) 335 models[self._srcname]['Prefactor'].value(crab_prefactor * test_crab_flux)
340 - self._obs.models(models) 336 + self.obs().models(models)
341 337
342 # Simulate events for the models. "sim" holds an observation 338 # Simulate events for the models. "sim" holds an observation
343 # container with observations containing the simulated events. 339 # container with observations containing the simulated events.
344 - sim = obsutils.sim(self._obs, nbins=enumbins, seed=iterations, 340 + sim = obsutils.sim(self.obs(), nbins=enumbins, seed=iterations,
345 binsz=binsz, npix=npix, 341 binsz=binsz, npix=npix,
346 log=self._log_clients, 342 log=self._log_clients,
347 debug=self['debug'].boolean(), 343 debug=self['debug'].boolean(),
@@ -488,7 +484,7 @@ class cssens(ctools.cscript): @@ -488,7 +484,7 @@ class cssens(ctools.cscript):
488 self._log_string(gammalib.TERSE, str(par)) 484 self._log_string(gammalib.TERSE, str(par))
489 485
490 # Restore energy boundaries of observation container 486 # Restore energy boundaries of observation container
491 - for i, obs in enumerate(self._obs): 487 + for i, obs in enumerate(self.obs()):
492 obs.events().ebounds(self._obs_ebounds[i]) 488 obs.events().ebounds(self._obs_ebounds[i])
493 489
494 # Store result 490 # Store result
@@ -583,7 +579,7 @@ class cssens(ctools.cscript): @@ -583,7 +579,7 @@ class cssens(ctools.cscript):
583 579
584 # Loop over observations and store a deep copy of the energy 580 # Loop over observations and store a deep copy of the energy
585 # boundaries for later use 581 # boundaries for later use
586 - for obs in self._obs: 582 + for obs in self.obs():
587 self._obs_ebounds.append(obs.events().ebounds().copy()) 583 self._obs_ebounds.append(obs.events().ebounds().copy())
588 584
589 # Initialise script 585 # Initialise script
@@ -593,14 +589,14 @@ class cssens(ctools.cscript): @@ -593,14 +589,14 @@ class cssens(ctools.cscript):
593 results = [] 589 results = []
594 590
595 # Set test source model for this observation 591 # Set test source model for this observation
596 - models = modutils.test_source(self._obs.models(), self._srcname, 592 + models = modutils.test_source(self.obs().models(), self._srcname,
597 ra=self._ra, dec=self._dec) 593 ra=self._ra, dec=self._dec)
598 594
599 # Write observation into logger 595 # Write observation into logger
600 - self._log_observations(gammalib.NORMAL, self._obs, 'Observation') 596 + self._log_observations(gammalib.NORMAL, self.obs(), 'Input observation')
601 597
602 # Write models into logger 598 # Write models into logger
603 - self._log_models(gammalib.NORMAL, models, 'Model') 599 + self._log_models(gammalib.TERSE, models, 'Input model')
604 600
605 # Get sensitivity type 601 # Get sensitivity type
606 sensitivity_type = self['type'].string() 602 sensitivity_type = self['type'].string()
cscripts/cstsdist.par
@@ -32,19 +32,20 @@ outfile, f, a, ts.dat,,, "Output Test Statistic distribution file" @@ -32,19 +32,20 @@ outfile, f, a, ts.dat,,, "Output Test Statistic distribution file"
32 # 32 #
33 # Script parameters 33 # Script parameters
34 #================== 34 #==================
35 -ntrials, i, a, 10,,, "Number of trials"  
36 -ra, r, a, 83.63,0,360, "RA of pointing (degrees)"  
37 -dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)"  
38 -rad, r, h, 5.0,0,180, "Radius of ROI (degrees)"  
39 -coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)"  
40 -proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method"  
41 -emin, r, a, 0.1,,, "Lower energy limit (TeV)"  
42 -emax, r, a, 100.0,,, "Upper energy limit (TeV)"  
43 -enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)"  
44 -tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"  
45 -tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"  
46 -npix, i, a, 200,,, "Number of pixels for binned"  
47 -binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)" 35 +ntrials, i, a, 10,,, "Number of trials"
  36 +ra, r, a, 83.63,0,360, "RA of pointing (degrees)"
  37 +dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)"
  38 +rad, r, h, 5.0,0,180, "Radius of ROI (degrees)"
  39 +coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)"
  40 +proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method"
  41 +emin, r, a, 0.1,,, "Lower energy limit (TeV)"
  42 +emax, r, a, 100.0,,, "Upper energy limit (TeV)"
  43 +enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)"
  44 +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"
  45 +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"
  46 +npix, i, a, 200,,, "Number of pixels for binned"
  47 +binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)"
  48 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
48 49
49 # 50 #
50 # Standard parameters 51 # Standard parameters
cscripts/cstsdist.py
@@ -29,7 +29,7 @@ from cscripts import ioutils @@ -29,7 +29,7 @@ from cscripts import ioutils
29 # ============== # 29 # ============== #
30 # cstsdist class # 30 # cstsdist class #
31 # ============== # 31 # ============== #
32 -class cstsdist(ctools.cscript): 32 +class cstsdist(ctools.cslikelihood):
33 """ 33 """
34 Generates Test Statistic distribution for a model 34 Generates Test Statistic distribution for a model
35 """ 35 """
@@ -39,20 +39,13 @@ class cstsdist(ctools.cscript): @@ -39,20 +39,13 @@ class cstsdist(ctools.cscript):
39 """ 39 """
40 Constructor. 40 Constructor.
41 """ 41 """
42 - # Set name  
43 - self._name = 'cstsdist'  
44 - self._version = ctools.__version__ 42 + # Initialise application by calling the appropriate class constructor
  43 + self._init_cslikelihood('cstsdist', ctools.__version__, argv)
45 44
46 # Initialise some members 45 # Initialise some members
47 self._srcname = '' 46 self._srcname = ''
48 self._log_clients = False 47 self._log_clients = False
49 48
50 - # Initialise observation container from constructor arguments  
51 - self._obs, argv = self._set_input_obs(argv)  
52 -  
53 - # Initialise application by calling the appropriate class constructor  
54 - self._init_cscript(argv)  
55 -  
56 # Return 49 # Return
57 return 50 return
58 51
@@ -63,8 +56,11 @@ class cstsdist(ctools.cscript): @@ -63,8 +56,11 @@ class cstsdist(ctools.cscript):
63 Get parameters from parfile and setup the observation 56 Get parameters from parfile and setup the observation
64 """ 57 """
65 # Set observation if not done before 58 # Set observation if not done before
66 - if self._obs.size() == 0:  
67 - self._obs = self._get_observations() 59 + if self.obs().size() == 0:
  60 + self.obs(self._get_observations())
  61 +
  62 + # Set observation statistic
  63 + self._set_obs_statistic(gammalib.toupper(self['statistic'].string()))
68 64
69 # Get source name 65 # Get source name
70 self._srcname = self['srcname'].string() 66 self._srcname = self['srcname'].string()
@@ -77,8 +73,8 @@ class cstsdist(ctools.cscript): @@ -77,8 +73,8 @@ class cstsdist(ctools.cscript):
77 self['proj'].string() 73 self['proj'].string()
78 74
79 # Set models if we have none 75 # Set models if we have none
80 - if self._obs.models().size() == 0:  
81 - self._obs.models(self['inmodel'].filename()) 76 + if self.obs().models().size() == 0:
  77 + self.obs().models(self['inmodel'].filename())
82 78
83 # Query parameters 79 # Query parameters
84 self['edisp'].boolean() 80 self['edisp'].boolean()
@@ -107,8 +103,7 @@ class cstsdist(ctools.cscript): @@ -107,8 +103,7 @@ class cstsdist(ctools.cscript):
107 Result dictionary 103 Result dictionary
108 """ 104 """
109 # Write header 105 # Write header
110 - if self._logExplicit():  
111 - self._log.header2('Trial '+str(seed+1)) 106 + self._log_header2(gammalib.EXPLICIT, 'Trial %d' % (seed+1))
112 107
113 # Set default binned parameters 108 # Set default binned parameters
114 coordsys = 'CEL' 109 coordsys = 'CEL'
@@ -124,7 +119,7 @@ class cstsdist(ctools.cscript): @@ -124,7 +119,7 @@ class cstsdist(ctools.cscript):
124 proj = self['proj'].string() 119 proj = self['proj'].string()
125 120
126 # Simulate events 121 # Simulate events
127 - sim = obsutils.sim(self._obs, 122 + sim = obsutils.sim(self.obs(),
128 nbins = self['enumbins'].integer(), 123 nbins = self['enumbins'].integer(),
129 seed = seed, 124 seed = seed,
130 proj = proj, 125 proj = proj,
@@ -226,30 +221,16 @@ class cstsdist(ctools.cscript): @@ -226,30 +221,16 @@ class cstsdist(ctools.cscript):
226 self._get_parameters() 221 self._get_parameters()
227 222
228 # Set test source model for this observation 223 # Set test source model for this observation
229 - self.models(modutils.test_source(self._obs.models(), self._srcname))  
230 -  
231 - # Write models into logger  
232 - if self._logTerse():  
233 - self._log('\n')  
234 - self._log.header1('Models')  
235 - self._log(str(self._obs.models()))  
236 - self._log('\n') 224 + self.models(modutils.test_source(self.obs().models(), self._srcname))
237 225
238 # Write observation into logger 226 # Write observation into logger
239 - if self._logTerse():  
240 - self._log('\n')  
241 - self._log.header1(gammalib.number('Observation',len(self._obs)))  
242 - self._log(str(self._obs))  
243 - self._log('\n')  
244 - if self._logExplicit():  
245 - for obs in self._obs:  
246 - self._log(str(obs))  
247 - self._log('\n') 227 + self._log_observations(gammalib.NORMAL, self.obs(), 'Input observation')
  228 +
  229 + # Write models into logger
  230 + self._log_models(gammalib.TERSE, self.obs().models(), 'Input model')
248 231
249 # Write header 232 # Write header
250 - if self._logTerse():  
251 - self._log('\n')  
252 - self._log.header1('Generate TS distribution') 233 + self._log_header1(gammalib.TERSE, 'Generate TS distribution')
253 234
254 # Loop over trials 235 # Loop over trials
255 for seed in range(self['ntrials'].integer()): 236 for seed in range(self['ntrials'].integer()):
@@ -274,7 +255,7 @@ class cstsdist(ctools.cscript): @@ -274,7 +255,7 @@ class cstsdist(ctools.cscript):
274 Model container 255 Model container
275 """ 256 """
276 # Copy models 257 # Copy models
277 - self._obs.models(models) 258 + self.obs().models(models)
278 259
279 # Return 260 # Return
280 return 261 return
doc/source/admin/release_history/1.5.rst
@@ -23,6 +23,11 @@ Bug fixes @@ -23,6 +23,11 @@ Bug fixes
23 Improvements 23 Improvements
24 ------------ 24 ------------
25 25
  26 +* [`2237 <https://cta-redmine.irap.omp.eu/issues/2237>`_] -
  27 + Add ``statistic`` parameters to :ref:`ctbutterfly`, :ref:`cterror`,
  28 + :ref:`cttsmap`, :ref:`ctulimit`, :ref:`cslightcrv, :ref:`csphasecrv`,
  29 + :ref:`cspull`, :ref:`cssens`, :ref:`csspec`, :ref:`cstsdist` and
  30 + :ref:`cstsmapsplit`
26 * [`2231 <https://cta-redmine.irap.omp.eu/issues/2231>`_] - 31 * [`2231 <https://cta-redmine.irap.omp.eu/issues/2231>`_] -
27 Enable handling of On/Off observations in :ref:`csspec` 32 Enable handling of On/Off observations in :ref:`csspec`
28 * [`2207 <https://cta-redmine.irap.omp.eu/issues/2207>`_] - 33 * [`2207 <https://cta-redmine.irap.omp.eu/issues/2207>`_] -
@@ -50,3 +55,7 @@ Clean up @@ -50,3 +55,7 @@ Clean up
50 55
51 * [`2237 <https://cta-redmine.irap.omp.eu/issues/2237>`_] - 56 * [`2237 <https://cta-redmine.irap.omp.eu/issues/2237>`_] -
52 Rename :ref:`ctlike` ``stat`` parameter to ``statistic`` 57 Rename :ref:`ctlike` ``stat`` parameter to ``statistic``
  58 +* [`2237 <https://cta-redmine.irap.omp.eu/issues/2237>`_] -
  59 + Derive :ref:`cslightcrv, :ref:`csphasecrv`, :ref:`cspull`, :ref:`cssens`,
  60 + :ref:`csspec` and :ref:`cttsdist` scripts from ``cslikelihood`` base
  61 + class
doc/source/users/reference_manual/cslightcrv.rst
@@ -38,7 +38,7 @@ General parameters @@ -38,7 +38,7 @@ General parameters
38 38
39 ``caldb [string]`` 39 ``caldb [string]``
40 Calibration database. 40 Calibration database.
41 - 41 +
42 ``irf [string]`` 42 ``irf [string]``
43 Instrumental response function. 43 Instrumental response function.
44 44
@@ -65,34 +65,42 @@ General parameters @@ -65,34 +65,42 @@ General parameters
65 65
66 ``emin [real]`` 66 ``emin [real]``
67 Lower energy limit of events (in TeV). 67 Lower energy limit of events (in TeV).
68 - 68 +
69 ``emax [real]`` 69 ``emax [real]``
70 Upper energy limit of events (in TeV). 70 Upper energy limit of events (in TeV).
71 - 71 +
72 ``enumbins [integer]`` 72 ``enumbins [integer]``
73 Number of energy bins per light curve bin (0=unbinned). 73 Number of energy bins per light curve bin (0=unbinned).
74 74
75 ``coordsys <CEL|GAL> [string]`` 75 ``coordsys <CEL|GAL> [string]``
76 Coordinate system (CEL - celestial, GAL - galactic). 76 Coordinate system (CEL - celestial, GAL - galactic).
77 - 77 +
78 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` 78 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]``
79 Projection method. 79 Projection method.
80 80
81 ``xref [real]`` 81 ``xref [real]``
82 Right Ascension / Galactic longitude of image centre (J2000, in degrees). 82 Right Ascension / Galactic longitude of image centre (J2000, in degrees).
83 - 83 +
84 ``yref [real]`` 84 ``yref [real]``
85 Declination / Galactic latitude of image centre (J2000, in degrees). 85 Declination / Galactic latitude of image centre (J2000, in degrees).
86 86
87 ``nxpix [integer]`` 87 ``nxpix [integer]``
88 Size of the Right Ascension / Galactic longitude axis (in pixels). 88 Size of the Right Ascension / Galactic longitude axis (in pixels).
89 - 89 +
90 ``nypix [integer]`` 90 ``nypix [integer]``
91 Size of the Declination / Galactic latitude axis (in pixels). 91 Size of the Declination / Galactic latitude axis (in pixels).
92 - 92 +
93 ``binsz [real]`` 93 ``binsz [real]``
94 Pixel size (in degrees/pixel). 94 Pixel size (in degrees/pixel).
95 95
  96 +``(statistic = DEFAULT) <DEFAULT|CSTAT|WSTAT|CHI2> [string]``
  97 + Optimization statistic. ``DEFAULT`` uses the default statistic for all
  98 + observations, which is ``CSTAT`` or the statistic specified in the
  99 + observation definition XML file. ``CSTAT`` uses the C statistic for
  100 + all observations, ``WSTAT`` uses the W statistic for all On/Off
  101 + observations, and ``CHI2`` uses the Chi squared statistic for all
  102 + binned or stacked observations.
  103 +
96 ``(calc_ts = yes) [boolean]`` 104 ``(calc_ts = yes) [boolean]``
97 Compute TS value for each time bin? 105 Compute TS value for each time bin?
98 106
@@ -115,20 +123,21 @@ Standard parameters @@ -115,20 +123,21 @@ Standard parameters
115 ``(chatter = 2) [integer]`` 123 ``(chatter = 2) [integer]``
116 Verbosity of the executable: 124 Verbosity of the executable:
117 ``chatter = 0``: no information will be logged 125 ``chatter = 0``: no information will be logged
118 - 126 +
119 ``chatter = 1``: only errors will be logged 127 ``chatter = 1``: only errors will be logged
120 - 128 +
121 ``chatter = 2``: errors and actions will be logged 129 ``chatter = 2``: errors and actions will be logged
122 - 130 +
123 ``chatter = 3``: report about the task execution 131 ``chatter = 3``: report about the task execution
124 - 132 +
125 ``chatter = 4``: detailed report about the task execution 133 ``chatter = 4``: detailed report about the task execution
126 134
127 ``(clobber = yes) [boolean]`` 135 ``(clobber = yes) [boolean]``
128 Specifies whether an existing light curve output file should be overwritten. 136 Specifies whether an existing light curve output file should be overwritten.
129 137
130 ``(debug = no) [boolean]`` 138 ``(debug = no) [boolean]``
131 - Enables debug mode. In debug mode the executable will dump any log file output to the console. 139 + Enables debug mode. In debug mode the executable will dump any log file
  140 + output to the console.
132 141
133 ``(mode = ql) [string]`` 142 ``(mode = ql) [string]``
134 Mode of automatic parameters (default is "ql", i.e. "query and learn"). 143 Mode of automatic parameters (default is "ql", i.e. "query and learn").
doc/source/users/reference_manual/csphasecrv.rst
@@ -35,7 +35,7 @@ General parameters @@ -35,7 +35,7 @@ General parameters
35 35
36 ``caldb [string]`` 36 ``caldb [string]``
37 Calibration database. 37 Calibration database.
38 - 38 +
39 ``irf [string]`` 39 ``irf [string]``
40 Instrumental response function. 40 Instrumental response function.
41 41
@@ -57,34 +57,42 @@ General parameters @@ -57,34 +57,42 @@ General parameters
57 57
58 ``emin [real]`` 58 ``emin [real]``
59 Lower energy limit of events (in TeV). 59 Lower energy limit of events (in TeV).
60 - 60 +
61 ``emax [real]`` 61 ``emax [real]``
62 Upper energy limit of events (in TeV). 62 Upper energy limit of events (in TeV).
63 - 63 +
64 ``enumbins [integer]`` 64 ``enumbins [integer]``
65 Number of energy bins per phase bin (0=unbinned). 65 Number of energy bins per phase bin (0=unbinned).
66 66
67 ``coordsys <CEL|GAL> [string]`` 67 ``coordsys <CEL|GAL> [string]``
68 Coordinate system (CEL - celestial, GAL - galactic). 68 Coordinate system (CEL - celestial, GAL - galactic).
69 - 69 +
70 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` 70 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]``
71 Projection method. 71 Projection method.
72 72
73 ``xref [real]`` 73 ``xref [real]``
74 Right Ascension / Galactic longitude of image centre (J2000, in degrees). 74 Right Ascension / Galactic longitude of image centre (J2000, in degrees).
75 - 75 +
76 ``yref [real]`` 76 ``yref [real]``
77 Declination / Galactic latitude of image centre (J2000, in degrees). 77 Declination / Galactic latitude of image centre (J2000, in degrees).
78 78
79 ``nxpix [integer]`` 79 ``nxpix [integer]``
80 Size of the Right Ascension / Galactic longitude axis (in pixels). 80 Size of the Right Ascension / Galactic longitude axis (in pixels).
81 - 81 +
82 ``nypix [integer]`` 82 ``nypix [integer]``
83 Size of the Declination / Galactic latitude axis (in pixels). 83 Size of the Declination / Galactic latitude axis (in pixels).
84 - 84 +
85 ``binsz [real]`` 85 ``binsz [real]``
86 Pixel size (in degrees/pixel). 86 Pixel size (in degrees/pixel).
87 87
  88 +``(statistic = DEFAULT) <DEFAULT|CSTAT|WSTAT|CHI2> [string]``
  89 + Optimization statistic. ``DEFAULT`` uses the default statistic for all
  90 + observations, which is ``CSTAT`` or the statistic specified in the
  91 + observation definition XML file. ``CSTAT`` uses the C statistic for
  92 + all observations, ``WSTAT`` uses the W statistic for all On/Off
  93 + observations, and ``CHI2`` uses the Chi squared statistic for all
  94 + binned or stacked observations.
  95 +
88 96
89 Standard parameters 97 Standard parameters
90 ------------------- 98 -------------------
@@ -95,21 +103,22 @@ Standard parameters @@ -95,21 +103,22 @@ Standard parameters
95 ``(chatter = 2) [integer]`` 103 ``(chatter = 2) [integer]``
96 Verbosity of the executable: 104 Verbosity of the executable:
97 ``chatter = 0``: no information will be logged 105 ``chatter = 0``: no information will be logged
98 - 106 +
99 ``chatter = 1``: only errors will be logged 107 ``chatter = 1``: only errors will be logged
100 - 108 +
101 ``chatter = 2``: errors and actions will be logged 109 ``chatter = 2``: errors and actions will be logged
102 - 110 +
103 ``chatter = 3``: report about the task execution 111 ``chatter = 3``: report about the task execution
104 - 112 +
105 ``chatter = 4``: detailed report about the task execution 113 ``chatter = 4``: detailed report about the task execution
106 114
107 ``(clobber = yes) [boolean]`` 115 ``(clobber = yes) [boolean]``
108 Specifies whether an existing light curve output file should be overwritten. 116 Specifies whether an existing light curve output file should be overwritten.
109 - 117 +
110 ``(debug = no) [boolean]`` 118 ``(debug = no) [boolean]``
111 - Enables debug mode. In debug mode the executable will dump any log file output to the console.  
112 - 119 + Enables debug mode. In debug mode the executable will dump any log file
  120 + output to the console.
  121 +
113 ``(mode = ql) [string]`` 122 ``(mode = ql) [string]``
114 Mode of automatic parameters (default is "ql", i.e. "query and learn"). 123 Mode of automatic parameters (default is "ql", i.e. "query and learn").
115 124
doc/source/users/reference_manual/cspull.rst
@@ -40,31 +40,28 @@ General parameters @@ -40,31 +40,28 @@ General parameters
40 40
41 ``inmodel [file]`` 41 ``inmodel [file]``
42 Input model XML file. 42 Input model XML file.
43 -  
44 -``outfile [file]``  
45 - ASCII file containing the individual pull values.  
46 - 43 +
47 ``caldb [string]`` 44 ``caldb [string]``
48 Calibration database. 45 Calibration database.
49 - 46 +
50 ``irf [string]`` 47 ``irf [string]``
51 Instrumental response function. 48 Instrumental response function.
52 49
53 -``(deadc = 0.98) [real]``  
54 - Average deadtime correction factor.  
55 -  
56 ``(edisp = no) [boolean]`` 50 ``(edisp = no) [boolean]``
57 Apply energy dispersion to response computation? 51 Apply energy dispersion to response computation?
58 52
59 -``(profile = no) [boolean]``  
60 - Use likelihood profile method for errors? 53 +``(deadc = 0.98) [real]``
  54 + Average deadtime correction factor.
  55 +
  56 +``outfile [file]``
  57 + ASCII file containing the individual pull values.
61 58
62 ``ntrials [integer]`` 59 ``ntrials [integer]``
63 Number of samples for generating the pull distribution. 60 Number of samples for generating the pull distribution.
64 - 61 +
65 ``ra [real]`` 62 ``ra [real]``
66 Right Ascension of CTA pointing (J2000, in degrees). 63 Right Ascension of CTA pointing (J2000, in degrees).
67 - 64 +
68 ``dec [real]`` 65 ``dec [real]``
69 Declination of CTA pointing (J2000, in degrees). 66 Declination of CTA pointing (J2000, in degrees).
70 67
@@ -73,31 +70,45 @@ General parameters @@ -73,31 +70,45 @@ General parameters
73 70
74 ``coordsys <CEL|GAL> [string]`` 71 ``coordsys <CEL|GAL> [string]``
75 Coordinate system (CEL - celestial, GAL - galactic). 72 Coordinate system (CEL - celestial, GAL - galactic).
76 - 73 +
77 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` 74 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]``
78 Projection method. 75 Projection method.
79 - 76 +
80 ``emin [real]`` 77 ``emin [real]``
81 Lower energy limit of events (in TeV). 78 Lower energy limit of events (in TeV).
82 - 79 +
83 ``emax [real]`` 80 ``emax [real]``
84 Upper energy limit of events (in TeV). 81 Upper energy limit of events (in TeV).
85 - 82 +
86 ``enumbins [integer]`` 83 ``enumbins [integer]``
87 Number of energy bins (0=unbinned). 84 Number of energy bins (0=unbinned).
88 - 85 +
89 ``tmin [time]`` 86 ``tmin [time]``
90 Start time (UTC string, JD, MJD or MET in seconds). 87 Start time (UTC string, JD, MJD or MET in seconds).
91 - 88 +
92 ``tmax [time]`` 89 ``tmax [time]``
93 Stop time (UTC string, JD, MJD or MET in seconds). 90 Stop time (UTC string, JD, MJD or MET in seconds).
94 - 91 +
95 ``npix [integer]`` 92 ``npix [integer]``
96 Number of pixels for binned analysis. 93 Number of pixels for binned analysis.
97 - 94 +
98 ``binsz [real]`` 95 ``binsz [real]``
99 Pixel size for binned analysis. 96 Pixel size for binned analysis.
100 97
  98 +``(statistic = DEFAULT) <DEFAULT|CSTAT|WSTAT|CHI2> [string]``
  99 + Optimization statistic. ``DEFAULT`` uses the default statistic for all
  100 + observations, which is ``CSTAT`` or the statistic specified in the
  101 + observation definition XML file. ``CSTAT`` uses the C statistic for
  102 + all observations, ``WSTAT`` uses the W statistic for all On/Off
  103 + observations, and ``CHI2`` uses the Chi squared statistic for all
  104 + binned or stacked observations.
  105 +
  106 +``(profile = no) [boolean]``
  107 + Use likelihood profile method for errors?
  108 +
  109 +``(seed = 1) [integer]``
  110 + Initial random number generator seed.
  111 +
101 112
102 Standard parameters 113 Standard parameters
103 ------------------- 114 -------------------
@@ -105,22 +116,22 @@ Standard parameters @@ -105,22 +116,22 @@ Standard parameters
105 ``(chatter = 2) [integer]`` 116 ``(chatter = 2) [integer]``
106 Verbosity of the executable: 117 Verbosity of the executable:
107 ``chatter = 0``: no information will be logged 118 ``chatter = 0``: no information will be logged
108 - 119 +
109 ``chatter = 1``: only errors will be logged 120 ``chatter = 1``: only errors will be logged
110 - 121 +
111 ``chatter = 2``: errors and actions will be logged 122 ``chatter = 2``: errors and actions will be logged
112 - 123 +
113 ``chatter = 3``: report about the task execution 124 ``chatter = 3``: report about the task execution
114 - 125 +
115 ``chatter = 4``: detailed report about the task execution 126 ``chatter = 4``: detailed report about the task execution
116 - 127 +
117 ``(clobber = yes) [boolean]`` 128 ``(clobber = yes) [boolean]``
118 Specifies whether an existing output file should be overwritten. 129 Specifies whether an existing output file should be overwritten.
119 - 130 +
120 ``(debug = no) [boolean]`` 131 ``(debug = no) [boolean]``
121 Enables debug mode. In debug mode the executable will dump any log file 132 Enables debug mode. In debug mode the executable will dump any log file
122 output to the console. 133 output to the console.
123 - 134 +
124 ``(mode = ql) [string]`` 135 ``(mode = ql) [string]``
125 Mode of automatic parameters (default is "ql", i.e. "query and learn"). 136 Mode of automatic parameters (default is "ql", i.e. "query and learn").
126 137
doc/source/users/reference_manual/cssens.rst
@@ -52,54 +52,65 @@ General parameters @@ -52,54 +52,65 @@ General parameters
52 Name of the source in the source model XML file which should be used 52 Name of the source in the source model XML file which should be used
53 for sensitivity computation. 53 for sensitivity computation.
54 54
55 -``(offset = 0.0) [real]``  
56 - Offset angle of source in field of view (in degrees).  
57 -  
58 ``caldb [string]`` 55 ``caldb [string]``
59 Calibration database. 56 Calibration database.
60 - 57 +
61 ``irf [string]`` 58 ``irf [string]``
62 Instrumental response function. 59 Instrumental response function.
63 60
  61 +``(edisp = no) [boolean]``
  62 + Apply energy dispersion to response computation?
  63 +
64 ``(deadc = 0.95) [real]`` 64 ``(deadc = 0.95) [real]``
65 Average deadtime correction factor. 65 Average deadtime correction factor.
66 - 66 +
67 ``outfile [file]`` 67 ``outfile [file]``
68 ASCII file containing the sensitivity values. 68 ASCII file containing the sensitivity values.
69 - 69 +
  70 +``(offset = 0.0) [real]``
  71 + Offset angle of source in field of view (in degrees).
  72 +
70 ``duration [real]`` 73 ``duration [real]``
71 Effective exposure time (in seconds). 74 Effective exposure time (in seconds).
72 - 75 +
73 ``rad [real]`` 76 ``rad [real]``
74 Radius of Region of Interest (RoI) (in degrees). 77 Radius of Region of Interest (RoI) (in degrees).
75 - 78 +
76 ``emin [real]`` 79 ``emin [real]``
77 Lower energy limit for sensitivity computation (in TeV). 80 Lower energy limit for sensitivity computation (in TeV).
78 - 81 +
79 ``emax [real]`` 82 ``emax [real]``
80 Upper energy limit for sensitivity computation (in TeV). 83 Upper energy limit for sensitivity computation (in TeV).
81 84
82 ``bins [integer]`` 85 ``bins [integer]``
83 Number of energy bins for sensitivity computation. 86 Number of energy bins for sensitivity computation.
84 - 87 +
85 ``(enumbins = 0) [integer]`` 88 ``(enumbins = 0) [integer]``
86 Number of energy bins (0=unbinned). 89 Number of energy bins (0=unbinned).
87 - 90 +
88 ``(npix = 200) [integer]`` 91 ``(npix = 200) [integer]``
89 Number of pixels for binned analysis. 92 Number of pixels for binned analysis.
90 - 93 +
91 ``(binsz = 0.05) [real]`` 94 ``(binsz = 0.05) [real]``
92 Pixel size for binned analysis. 95 Pixel size for binned analysis.
93 - 96 +
94 ``(type = Differential) <Differential|Integral> [string]`` 97 ``(type = Differential) <Differential|Integral> [string]``
95 Sensitivity type. 98 Sensitivity type.
96 - 99 +
97 ``(sigma = 5.0) [real]`` 100 ``(sigma = 5.0) [real]``
98 Significance threshold. 101 Significance threshold.
99 - 102 +
100 ``(max_iter = 50) [integer]`` 103 ``(max_iter = 50) [integer]``
101 Maximum number of iterations. 104 Maximum number of iterations.
102 - 105 +
  106 +``(statistic = DEFAULT) <DEFAULT|CSTAT|WSTAT|CHI2> [string]``
  107 + Optimization statistic. ``DEFAULT`` uses the default statistic for all
  108 + observations, which is ``CSTAT`` or the statistic specified in the
  109 + observation definition XML file. ``CSTAT`` uses the C statistic for
  110 + all observations, ``WSTAT`` uses the W statistic for all On/Off
  111 + observations, and ``CHI2`` uses the Chi squared statistic for all
  112 + binned or stacked observations.
  113 +
103 114
104 Standard parameters 115 Standard parameters
105 ------------------- 116 -------------------
@@ -107,21 +118,22 @@ Standard parameters @@ -107,21 +118,22 @@ Standard parameters
107 ``(chatter = 2) [integer]`` 118 ``(chatter = 2) [integer]``
108 Verbosity of the executable: 119 Verbosity of the executable:
109 ``chatter = 0``: no information will be logged 120 ``chatter = 0``: no information will be logged
110 - 121 +
111 ``chatter = 1``: only errors will be logged 122 ``chatter = 1``: only errors will be logged
112 - 123 +
113 ``chatter = 2``: errors and actions will be logged 124 ``chatter = 2``: errors and actions will be logged
114 - 125 +
115 ``chatter = 3``: report about the task execution 126 ``chatter = 3``: report about the task execution
116 - 127 +
117 ``chatter = 4``: detailed report about the task execution 128 ``chatter = 4``: detailed report about the task execution
118 - 129 +
119 ``(clobber = yes) [boolean]`` 130 ``(clobber = yes) [boolean]``
120 Specifies whether an existing output file should be overwritten. 131 Specifies whether an existing output file should be overwritten.
121 - 132 +
122 ``(debug = no) [boolean]`` 133 ``(debug = no) [boolean]``
123 - Enables debug mode. In debug mode the executable will dump any log file output to the console.  
124 - 134 + Enables debug mode. In debug mode the executable will dump any log file
  135 + output to the console.
  136 +
125 ``(mode = ql) [string]`` 137 ``(mode = ql) [string]``
126 Mode of automatic parameters (default is "ql", i.e. "query and learn"). 138 Mode of automatic parameters (default is "ql", i.e. "query and learn").
127 139
doc/source/users/reference_manual/cstsdist.rst
@@ -42,9 +42,6 @@ General parameters @@ -42,9 +42,6 @@ General parameters
42 Name of the source in the source model XML file which should be used 42 Name of the source in the source model XML file which should be used
43 for Test Statistics computation. 43 for Test Statistics computation.
44 44
45 -``outfile [file]``  
46 - Output ASCII file containing the TS distribution values.  
47 -  
48 ``expcube [file]`` 45 ``expcube [file]``
49 Input exposure cube file. 46 Input exposure cube file.
50 47
@@ -59,22 +56,25 @@ General parameters @@ -59,22 +56,25 @@ General parameters
59 56
60 ``caldb [string]`` 57 ``caldb [string]``
61 Calibration database. 58 Calibration database.
62 - 59 +
63 ``irf [string]`` 60 ``irf [string]``
64 Instrumental response function. 61 Instrumental response function.
65 -  
66 -``(deadc = 0.98) [real]``  
67 - Average deadtime correction factor.  
68 62
69 ``(edisp = no) [boolean]`` 63 ``(edisp = no) [boolean]``
70 Apply energy dispersion to response computation. 64 Apply energy dispersion to response computation.
71 65
  66 +``(deadc = 0.98) [real]``
  67 + Average deadtime correction factor.
  68 +
  69 +``outfile [file]``
  70 + Output ASCII file containing the TS distribution values.
  71 +
72 ``ntrials [integer]`` 72 ``ntrials [integer]``
73 Number of Monte Carlo samples. 73 Number of Monte Carlo samples.
74 74
75 ``ra [real]`` 75 ``ra [real]``
76 Right Ascension of CTA pointing (J2000, in degrees). 76 Right Ascension of CTA pointing (J2000, in degrees).
77 - 77 +
78 ``dec [real]`` 78 ``dec [real]``
79 Declination of CTA pointing (J2000, in degrees). 79 Declination of CTA pointing (J2000, in degrees).
80 80
@@ -83,31 +83,39 @@ General parameters @@ -83,31 +83,39 @@ General parameters
83 83
84 ``coordsys <CEL|GAL> [string]`` 84 ``coordsys <CEL|GAL> [string]``
85 Coordinate system (CEL - celestial, GAL - galactic). 85 Coordinate system (CEL - celestial, GAL - galactic).
86 - 86 +
87 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` 87 ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]``
88 Projection method. 88 Projection method.
89 89
90 ``emin [real]`` 90 ``emin [real]``
91 Lower energy limit (in TeV). 91 Lower energy limit (in TeV).
92 - 92 +
93 ``emax [real]`` 93 ``emax [real]``
94 Upper energy limit (in TeV). 94 Upper energy limit (in TeV).
95 - 95 +
96 ``enumbins [integer]`` 96 ``enumbins [integer]``
97 Number of energy bins (0=unbinned). 97 Number of energy bins (0=unbinned).
98 - 98 +
99 ``tmin [time]`` 99 ``tmin [time]``
100 Start time (UTC string, JD, MJD or MET in seconds). 100 Start time (UTC string, JD, MJD or MET in seconds).
101 - 101 +
102 ``tmax [time]`` 102 ``tmax [time]``
103 Stop time (UTC string, JD, MJD or MET in seconds). 103 Stop time (UTC string, JD, MJD or MET in seconds).
104 - 104 +
105 ``npix [integer]`` 105 ``npix [integer]``
106 Number of pixels for binned analysis. 106 Number of pixels for binned analysis.
107 - 107 +
108 ``binsz [real]`` 108 ``binsz [real]``
109 Pixel size for binned analysis. 109 Pixel size for binned analysis.
110 110
  111 +``(statistic = DEFAULT) <DEFAULT|CSTAT|WSTAT|CHI2> [string]``
  112 + Optimization statistic. ``DEFAULT`` uses the default statistic for all
  113 + observations, which is ``CSTAT`` or the statistic specified in the
  114 + observation definition XML file. ``CSTAT`` uses the C statistic for
  115 + all observations, ``WSTAT`` uses the W statistic for all On/Off
  116 + observations, and ``CHI2`` uses the Chi squared statistic for all
  117 + binned or stacked observations.
  118 +
111 119
112 Standard parameters 120 Standard parameters
113 ------------------- 121 -------------------
@@ -115,21 +123,22 @@ Standard parameters @@ -115,21 +123,22 @@ Standard parameters
115 ``(chatter = 2) [integer]`` 123 ``(chatter = 2) [integer]``
116 Verbosity of the executable: 124 Verbosity of the executable:
117 ``chatter = 0``: no information will be logged 125 ``chatter = 0``: no information will be logged
118 - 126 +
119 ``chatter = 1``: only errors will be logged 127 ``chatter = 1``: only errors will be logged
120 - 128 +
121 ``chatter = 2``: errors and actions will be logged 129 ``chatter = 2``: errors and actions will be logged
122 - 130 +
123 ``chatter = 3``: report about the task execution 131 ``chatter = 3``: report about the task execution
124 - 132 +
125 ``chatter = 4``: detailed report about the task execution 133 ``chatter = 4``: detailed report about the task execution
126 - 134 +
127 ``(clobber = yes) [boolean]`` 135 ``(clobber = yes) [boolean]``
128 Specifies whether an existing output file should be overwritten. 136 Specifies whether an existing output file should be overwritten.
129 - 137 +
130 ``(debug = no) [boolean]`` 138 ``(debug = no) [boolean]``
131 - Enables debug mode. In debug mode the executable will dump any log file output to the console.  
132 - 139 + Enables debug mode. In debug mode the executable will dump any log file
  140 + output to the console.
  141 +
133 ``(mode = ql) [string]`` 142 ``(mode = ql) [string]``
134 Mode of automatic parameters (default is "ql", i.e. "query and learn"). 143 Mode of automatic parameters (default is "ql", i.e. "query and learn").
135 144