TSMapEstimator

class gammapy.estimators.TSMapEstimator(model=None, kernel_width=None, downsampling_factor=None, n_sigma=1, n_sigma_ul=2, threshold=None, rtol=0.01, selection_optional=None, 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.01)

Relative precision of the flux estimate. Used as a stopping criterion for the norm fit.

selection_optionallist of str

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

  • “all”: all the optional steps are executed

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

  • “ul”: estimate upper limits on flux.

Default is None so the optional steps are not 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_fit_input_maps(dataset)

Estimate fit input maps

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)

Compute default mask where to estimate TS values.

estimate_pad_width(dataset[, kernel])

Estimate pad width of the dataset

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_fit_input_maps(dataset)[source]

Estimate fit input maps

Parameters
datasetMapDataset

Map dataset

Returns
mapsdict of Map

Maps dict

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

Estimate default flux map using a given kernel.

Parameters
datasetMapDataset

Input dataset.

kernelWcsNDMap

Source model kernel.

exposureWcsNDMap

Exposure map on reconstructed energy.

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)[source]

Compute default mask where to estimate TS values.

Parameters
datasetMapDataset

Input dataset.

Returns
maskWcsNDMap

Mask map.

estimate_pad_width(dataset, kernel=None)[source]

Estimate pad width of the dataset

Parameters
datasetMapDataset

Input MapDataset.

kernelWcsNDMap

Source model kernel.

Returns
pad_widthtuple

Padding width

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