TSMapEstimator

class gammapy.detect.TSMapEstimator(method='root brentq', error_method='covar', error_sigma=1, ul_method='covar', ul_sigma=2, n_jobs=1, 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:
method : str (‘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_sigma : int (1)

Sigma for flux error.

ul_method : [‘covar’, ‘conf’]

Upper limit estimation method.

ul_sigma : int (2)

Sigma for flux upper limits.

n_jobs : int

Number of parallel jobs to use for the computation.

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 \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:
maps : dict

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

kernel : astropy.convolution.Kernel2D

Source model kernel.

Returns:
flux_approx : gammapy.maps.WcsNDMap

Approximate flux map.

static mask_default(maps, kernel)[source]

Compute default mask where to estimate TS values.

Parameters:
maps : dict

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

kernel : astropy.convolution.Kernel2D

Source model kernel.

Returns:
mask : gammapy.maps.WcsNDMap

Mask map.

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

Run TS map estimation.

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

Parameters:
maps : dict

Input sky maps.

kernel : astropy.convolution.Kernel2D or 2D ndarray

Source model kernel.

which : list of str or ‘all’

Which maps to compute.

downsampling_factor : int

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:
maps : dict

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_ts : gammapy.maps.WcsNDMap

Input TS map.

Returns:
sqrt_ts : gammapy.maps.WcsNDMap

Sqrt(TS) map.