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
- model
SkyModel
Source model kernel. If set to None, assume spatail model: point source model, PointSpatialModel. spectral model: PowerLawSpectral Model of index 2
- kernel_width
Angle
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_edges
Quantity
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.
- model
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
Attributes Summary
Config parameters
Which quantities are computed
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
- dataset
MapDataset
Input dataset.
- kernel
ndarray
Source model kernel.
- dataset
- Returns
- flux
WcsNDMap
Approximate flux map.
- flux
-
estimate_flux_map
(dataset)[source]¶ Estimate flux and ts maps for single dataset
- Parameters
- dataset
MapDataset
Map dataset
- 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
- dataset
MapDataset
Input dataset.
- dataset
- Returns
- kernel
Map
Kernel map
- kernel
-
static
estimate_mask_default
(dataset, kernel)[source]¶ Compute default mask where to estimate TS values.
- Parameters
- dataset
MapDataset
Input dataset.
- kernel
ndarray
Source model kernel.
- dataset
- Returns
- mask
gammapy.maps.WcsNDMap
Mask map.
- mask
-
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_ts
gammapy.maps.WcsNDMap
Input TS map.
- map_ts
- Returns
- sqrt_ts
gammapy.maps.WcsNDMap
Sqrt(TS) map.
- sqrt_ts
-
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}\]
-
run
(dataset)[source]¶ Run TS map estimation.
Requires a MapDataset with counts, exposure and background_model properly set to run.
- Parameters
- dataset
MapDataset
Input MapDataset.
- dataset
- 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