TSImageEstimator

class gammapy.detect.TSImageEstimator(method='root brentq', error_method='covar', error_sigma=1, ul_method='covar', ul_sigma=2, parallel=True, threshold=None, rtol=0.001)[source]

Bases: object

Compute TS image using different optimization methods.

Parameters:

method : str (‘root’)

The following options are available:

  • 'root brentq' (default)
    Fit amplitude finding roots of the the derivative of the fit statistics. Described in Appendix A in Stewart (2009).
  • 'root newton'
    TODO: document
  • 'leastsq iter'

error_method : [‘covar’, ‘conf’]

Error estimation method.

error_sigma : int (1)

Sigma for flux error.

ul_method : [‘covar’, ‘conf’]

Upper limit estimation method.

ul_sigma : int (2)

Sigma for flux upper limits.

parallel : bool (True)

Whether to use multiple cores for parallel processing.

threshold : float (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.

rtol : float (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 & : \textnormal{if} \ F < 0 \\ \ \ TS & : \textnormal{else} \end{array} \right.\end{split}\]

Where \(F\) is the fitted flux amplitude.

References

[Stewart2009]

Methods Summary

flux_default(images, kernel) Estimate default flux image using a given kernel.
mask_default(images, kernel) Compute default mask where to estimate TS values.
run(images, kernel[, which]) Run TS image estimation.
sqrt_ts(image_ts) Compute sqrt(TS) image.

Methods Documentation

static flux_default(images, kernel)[source]

Estimate default flux image using a given kernel.

Parameters:

images : SkyImageList

List of input sky images. Requires counts, background and exposure.

kernel : astropy.convolution.Kernel2D

Source model kernel.

Returns:

flux_approx : SkyImage

Approximate flux image.

static mask_default(images, kernel)[source]

Compute default mask where to estimate TS values.

Parameters:

images : SkyImageList

List of input sky images. Requires background and exposure.

kernel : astropy.convolution.Kernel2D

Source model kernel.

Returns:

mask : SkyImage

Mask image.

run(images, kernel, which='all')[source]

Run TS image estimation.

Requires counts, exposure and background image to run.

Parameters:

kernel : astropy.convolution.Kernel2D or 2D ndarray

Source model kernel.

images : SkyImageList

List of input sky images.

which : list of str or ‘all’

Which images to compute.

Returns:

images : SkyImageList

Result images.

static sqrt_ts(image_ts)[source]

Compute sqrt(TS) image.

Compute sqrt(TS) as defined by:

\[\begin{split}\sqrt{TS} = \left \{ \begin{array}{ll} -\sqrt{-TS} & : \textnormal{if} \ TS < 0 \\ \ \ \sqrt{TS} & : \textnormal{else} \end{array} \right.\end{split}\]
Parameters:

image_ts : SkyImage

Input TS image.

Returns:

sqrt_ts : SkyImage

Sqrt(TS) image