Extension Fitting¶
The extension()
method executes
a source extension analysis for a given source by computing a
likelihood ratio test with respect to the noextension (pointsource)
hypothesis and a bestfit model for extension. The bestfit extension
is evaluated by a likelihood profile scan over the source width.
Currently this method supports two models for extension: a 2D Gaussian
(RadialGaussian) or a 2D disk (RadialDisk).
At runtime the default settings for the extension analysis can be
overriden by passing one or more kwargs when executing
extension()
:
# Run extension fit of sourceA with default settings
>>> gta.extension('sourceA')
# Override default spatial model
>>> gta.extension('sourceA',spatial_model='RadialDisk')
By default the extension method will profile over any background
parameters that were free when the method was executed. One can fix
all background parameters by setting fix_background=True
:
# Free a nearby source that maybe be partially degenerate with the
# source of interest
gta.free_norm('sourceB')
# Normalization of SourceB will be refit when testing the extension
# of sourceA
gta.extension('sourceA')
# Fix all background parameters when testing the extension
# of sourceA
gta.extension('sourceA',fix_background=True)
The results of the extension analysis are written to a dictionary
which is the return value of the extension method. This dictionary
is also written to the extension dictionary of the corresponding
source and will also be saved in the output file generated by
write_roi()
.
ext = gta.extension('sourceA')
ext = gta.roi['sourceA']
The contents of the output dictionary are described in the following table:
Key  Type  Description 

width 
ndarray 
Vector of width values. 
dloglike 
ndarray 
Sequence of deltaloglikelihood values for each point in the profile likelihood scan. 
loglike 
ndarray 
Sequence of likelihood values for each point in the scan over the spatial extension. 
loglike_ptsrc 
float  Model logLikelihood value of the bestfit pointsource model. 
loglike_ext 
float  Model logLikelihood value of the bestfit extended source model. 
loglike_base 
float  Model logLikelihood value of the baseline model. 
ext 
float  Bestfit extension in degrees. 
ext_err_hi 
float  Upper (1 sigma) error on the bestfit extension in degrees. 
ext_err_lo 
float  Lower (1 sigma) error on the bestfit extension in degrees. 
ext_err 
float  Symmetric (1 sigma) error on the bestfit extension in degrees. 
ext_ul95 
float  95% CL upper limit on the spatial extension in degrees. 
ts_ext 
float  Test statistic for the extension hypothesis. 
source_fit 
dict  Dictionary with parameters of the bestfit extended source model. 
config 
dict  Copy of the input configuration to this method. 
Configuration¶
The default configuration of the method is controlled with the extension section of the configuration file. The default configuration can be overriden by passing the option as a kwargs argument to the method.
Option  Default  Description 

fix_background 
False  Fix any background parameters that are currently free in the model when performing the likelihood scan over extension. 
psf_scale_fn 
None  Tuple of vectors (logE,f) defining an energydependent PSF scaling function that will be applied when building spatial models for the source of interest. The tuple (logE,f) defines the fractional corrections f at the sequence of energies logE = log10(E/MeV) where f=0 means no correction. The correction function f(E) is evaluated by linearly interpolating the fractional correction factors f in log(E). The corrected PSF is given by P’(x;E) = P(x/(1+f(E));E) where x is the angular separation. 
save_model_map 
False  Save model counts cubes for the bestfit model of extension. 
spatial_model 
RadialGaussian  Spatial model use for extension test. 
sqrt_ts_threshold 
None  Threshold on sqrt(TS_ext) that will be applied when update is True. If None then nothreshold is applied. 
update 
False  Update the source model with the bestfit spatial extension. 
width 
None  Parameter vector for scan over spatial extent. If none then the parameter vector will be set from width_min , width_max , and width_nstep . 
width_max 
1.0  Maximum value in degrees for the likelihood scan over spatial extent. 
width_min 
0.01  Minimum value in degrees for the likelihood scan over spatial extent. 
width_nstep 
21  Number of steps for the spatial likelihood scan. 
Reference/API¶

GTAnalysis.
extension
(name, **kwargs)[source] Test this source for spatial extension with the likelihood ratio method (TS_ext). This method will substitute an extended spatial model for the given source and perform a onedimensional scan of the spatial extension parameter over the range specified with the width parameters. The 1D profile likelihood is then used to compute the bestfit value, upper limit, and TS for extension. Any background parameters that are free will also be simultaneously profiled in the likelihood scan.
Parameters:  name (str) – Source name.
 spatial_model (str) –
Spatial model that will be used to test the source extension. The spatial scale parameter of the respective model will be set such that the 68% containment radius of the model is equal to the width parameter. The following spatial models are supported:
 RadialDisk : Azimuthally symmetric 2D disk.
 RadialGaussian : Azimuthally symmetric 2D gaussian.
 width_min (float) – Minimum value in degrees for the spatial extension scan.
 width_max (float) – Maximum value in degrees for the spatial extension scan.
 width_nstep (int) – Number of scan points between width_min and width_max. Scan points will be spaced evenly on a logarithmic scale between log(width_min) and log(width_max).
 width (arraylike) – Sequence of values in degrees for the spatial extension scan. If this argument is None then the scan points will be determined from width_min/width_max/width_nstep.
 fix_background (bool) – Fix all background sources when performing the extension fit.
 update (bool) – Update this source with the bestfit model for spatial
extension if TS_ext >
tsext_threshold
.  sqrt_ts_threshold (float) – Threshold on sqrt(TS_ext) that will be applied when
update
is true. If None then no threshold will be applied.  psf_scale_fn (tuple) – Tuple of vectors (logE,f) defining an energydependent PSF scaling function that will be applied when building spatial models for the source of interest. The tuple (logE,f) defines the fractional corrections f at the sequence of energies logE = log10(E/MeV) where f=0 means no correction. The correction function f(E) is evaluated by linearly interpolating the fractional correction factors f in log(E). The corrected PSF is given by P’(x;E) = P(x/(1+f(E));E) where x is the angular separation.
 optimizer (dict) – Dictionary that overrides the default optimizer settings.
Returns: extension – Dictionary containing results of the extension analysis. The same dictionary is also saved to the dictionary of this source under ‘extension’.
Return type: