# TSMapEstimator¶

class gammapy.detect.TSMapEstimator(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 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 sescribed in Appendix A in Stewart (2009).

Parameters
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.

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

[Stewart2009]

Methods Summary

 flux_default(maps, kernel) Estimate default flux map using a given kernel. mask_default(maps, kernel) Compute default mask where to estimate TS values. run(self, maps, kernel[, which, …]) Run TS map estimation. sqrt_ts(map_ts) Compute sqrt(TS) map.

Methods Documentation

static flux_default(maps, kernel)[source]

Estimate default flux map using a given kernel.

Parameters
mapsdict

Input sky maps. Requires “counts”, “background” and “exposure” maps.

kernelastropy.convolution.Kernel2D

Source model kernel.

Returns
flux_approxgammapy.maps.WcsNDMap

Approximate flux map.

static mask_default(maps, kernel)[source]

Compute default mask where to estimate TS values.

Parameters
mapsdict

Input sky maps. Requires “background” and “exposure”.

kernelastropy.convolution.Kernel2D

Source model kernel.

Returns
maskgammapy.maps.WcsNDMap

run(self, maps, kernel, which='all', downsampling_factor=None)[source]

Run TS map estimation.

Requires “counts”, “exposure” and “background” map to run.

Parameters
mapsdict

Input sky maps.

kernel

Source model kernel.

whichlist of str or ‘all’

Which maps to compute.

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.

Returns
mapsdict

Result maps.

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_tsgammapy.maps.WcsNDMap

Input TS map.

Returns
sqrt_tsgammapy.maps.WcsNDMap

Sqrt(TS) map.