TSMapEstimator

class gammapy.estimators.TSMapEstimator(model=None, kernel_width='0.2 deg', downsampling_factor=None, n_sigma=1, n_sigma_ul=2, threshold=None, rtol=0.01, selection_optional='all', energy_edges=None, sum_over_energy_groups=True, n_jobs=None)[source]

Bases: gammapy.estimators.Estimator

Compute TS map from a MapDataset using different optimization methods.

The map is computed fitting by a single parameter norm 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
modelSkyModel

Source model kernel. If set to None, assume spatail model: point source model, PointSpatialModel. spectral model: PowerLawSpectral Model of index 2

kernel_widthAngle

Width of the kernel to use: the kernel will be truncated at this size

n_sigmaint

Number of sigma for flux error. Default is 1.

n_sigma_ulint

Number of sigma for flux upper limits. Default is 2.

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.

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 norm fit.

selection_optionallist of str or ‘all’

Which maps to compute besides TS, sqrt(TS), flux and symmetric error on flux. Available options are:

  • “errn-errp”: estimate assymmetric error on flux.

  • “ul”: estimate upper limits on flux.

By default all steps are executed.

energy_edgesQuantity

Energy edges of the maps bins.

sum_over_energy_groupsbool

Whether to sum over the energy groups or fit the norm on the full energy cube.

n_jobsint

Number of processes used in parallel for the computation.

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

References

[Stewart2009]

Attributes Summary

config_parameters

Config parameters

selection_all

Which quantities are computed

selection_optional

tag

Methods Summary

copy()

Copy estimator

estimate_flux_default(dataset, kernel[, …])

Estimate default flux map using a given kernel.

estimate_flux_map(dataset)

Estimate flux and ts maps for single dataset

estimate_kernel(dataset)

Get the convolution kernel for the input dataset.

estimate_mask_default(dataset, kernel)

Compute default mask where to estimate TS values.

estimate_sqrt_ts(map_ts, norm)

Compute sqrt(TS) map.

get_sqrt_ts(ts, norm)

Compute sqrt(TS) value.

run(dataset)

Run TS map estimation.

Attributes Documentation

config_parameters

Config parameters

selection_all

Which quantities are computed

selection_optional
tag = 'TSMapEstimator'

Methods Documentation

copy()

Copy estimator

estimate_flux_default(dataset, kernel, exposure=None)[source]

Estimate default flux map using a given kernel.

Parameters
datasetMapDataset

Input dataset.

kernelndarray

Source model kernel.

Returns
fluxWcsNDMap

Approximate flux map.

estimate_flux_map(dataset)[source]

Estimate flux and ts maps for single dataset

Parameters
datasetMapDataset

Map dataset

estimate_kernel(dataset)[source]

Get the convolution kernel for the input dataset.

Convolves the model with the PSFKernel at the center of the dataset.

Parameters
datasetMapDataset

Input dataset.

Returns
kernelMap

Kernel map

static estimate_mask_default(dataset, kernel)[source]

Compute default mask where to estimate TS values.

Parameters
datasetMapDataset

Input dataset.

kernelndarray

Source model kernel.

Returns
maskgammapy.maps.WcsNDMap

Mask map.

estimate_sqrt_ts(map_ts, norm)[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.

static get_sqrt_ts(ts, norm)

Compute sqrt(TS) value.

Compute sqrt(TS) as defined by:

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

TS value.

normndarray

norm value

Returns
——-
sqrt_tsndarray

Sqrt(TS) value.

run(dataset)[source]

Run TS map estimation.

Requires a MapDataset with counts, exposure and background_model properly set to run.

Parameters
datasetMapDataset

Input MapDataset.

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