TSMapEstimator¶
-
class
gammapy.estimators.
TSMapEstimator
(model=None, kernel_width='0.2 deg', downsampling_factor=None, method='root brentq', error_method='covar', error_sigma=1, ul_method='covar', ul_sigma=2, threshold=None, rtol=0.001)[source]¶ Bases:
object
Compute TS map from a MapDataset using different optimization methods.
The map is computed fitting by a single parameter amplitude fit. The fit is simplified by finding roots of the the derivative of the fit statistics using various root finding algorithms. The approach is described in Appendix A in Stewart (2009).
- Parameters
- model
SkyModel
Source model kernel. If set to None, assume point source model, PointSpatialModel.
- kernel_width
Angle
Width of the kernel to use: the kernel will be truncated at this size
- downsampling_factorint
Sample down the input maps to speed up the computation. Only integer values that are a multiple of 2 are allowed. Note that the kernel is not sampled down, but must be provided with the downsampled bin size.
- methodstr (‘root’)
The following options are available:
'root brentq'
(default)Fit amplitude by finding the roots of the the derivative of the fit statistics using the brentq method.
'root newton'
Fit amplitude by finding the roots of the the derivative of the fit statistics using Newton’s method.
'leastsq iter'
Fit the amplitude by an iterative least square fit, that can be solved analytically.
- error_method[‘covar’, ‘conf’]
Error estimation method.
- error_sigmaint (1)
Sigma for flux error.
- ul_method[‘covar’, ‘conf’]
Upper limit estimation method.
- ul_sigmaint (2)
Sigma for flux upper limits.
- thresholdfloat (None)
If the TS value corresponding to the initial flux estimate is not above this threshold, the optimizing step is omitted to save computing time.
- rtolfloat (0.001)
Relative precision of the flux estimate. Used as a stopping criterion for the amplitude fit.
- model
Notes
Negative \(TS\) values are defined as following:
\[\begin{split}TS = \left \{ \begin{array}{ll} -TS \text{ if } F < 0 \\ TS \text{ else} \end{array} \right.\end{split}\]Where \(F\) is the fitted flux amplitude.
References
Methods Summary
flux_default
(dataset, kernel)Estimate default flux map using a given kernel.
get_kernel
(self, dataset)Set the convolution kernel for the input dataset.
mask_default
(exposure, background, kernel)Compute default mask where to estimate TS values.
run
(self, dataset[, steps])Run TS map estimation.
sqrt_ts
(map_ts)Compute sqrt(TS) map.
Methods Documentation
-
get_kernel
(self, dataset)[source]¶ Set the convolution kernel for the input dataset.
Convolves the model with the PSFKernel at the center of the dataset. If no PSFMap or PSFKernel is found the dataset, the model is used without convolution.
-
static
mask_default
(exposure, background, kernel)[source]¶ Compute default mask where to estimate TS values.
- Parameters
- Returns
- mask
gammapy.maps.WcsNDMap
Mask map.
- mask
-
run
(self, dataset, steps='all')[source]¶ Run TS map estimation.
Requires a MapDataset with counts, exposure and background_model properly set to run.
- Parameters
- dataset
MapDataset
Input MapDataset.
- stepslist of str or ‘all’
Which maps to compute. Available options are:
“ts”: estimate delta TS and significance (sqrt_ts)
“flux-err”: estimate symmetric error on flux.
“flux-ul”: estimate upper limits on flux.
By default all steps are executed.
- dataset
- Returns
- mapsdict
Dictionary containing result maps. Keys are:
ts : delta TS map
sqrt_ts : sqrt(delta TS), or significance map
flux : flux map
flux_err : symmetric error map
flux_ul : upper limit map
-
static
sqrt_ts
(map_ts)[source]¶ Compute sqrt(TS) map.
Compute sqrt(TS) as defined by:
\[\begin{split}\sqrt{TS} = \left \{ \begin{array}{ll} -\sqrt{-TS} & : \text{if} \ TS < 0 \\ \sqrt{TS} & : \text{else} \end{array} \right.\end{split}\]- Parameters
- map_ts
gammapy.maps.WcsNDMap
Input TS map.
- map_ts
- Returns
- sqrt_ts
gammapy.maps.WcsNDMap
Sqrt(TS) map.
- sqrt_ts