Extension Fitting

The extension() method executes a source extension analysis for a given source by computing a likelihood ratio test with respect to the no-extension (point-source) hypothesis and a best-fit model for extension. The best-fit extension is found by performing a likelihood profile scan over the source width (68% containment) and fitting for the extension that maximizes the model likelihood. 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 method will fix all background parameters before performing the extension fit. One can leave background parameters free by setting free_background=True:

# Free a nearby source that maybe be partially degenerate with the
# source of interest.  The normalization of SourceB will be refit
# when testing the extension of sourceA
gta.free_norm('sourceB')
gta.extension('sourceA', free_background=True)

# Fix all background parameters when testing the extension
# of sourceA
gta.extension('sourceA', free_background=False)

# Free normalizations of sources within 2 degrees of sourceA
gta.extension('sourceA', free_radius=2.0)

The results of the extension analysis are written to a dictionary which is the return value of the extension method.

ext = gta.extension('sourceA', write_npy=True, write_fits=True)

The contents of the output dictionary are given in the following table:

extension Output Dictionary
Key Type Description
width ndarray Vector of width values.
dloglike ndarray Sequence of delta-log-likelihood 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 log-Likelihood value of the best-fit point-source model.
loglike_ext float Model log-Likelihood value of the best-fit extended source model.
loglike_base float Model log-Likelihood value of the baseline model.
ext float Best-fit extension in degrees.
ext_err_hi float Upper (1 sigma) error on the best-fit extension in degrees.
ext_err_lo float Lower (1 sigma) error on the best-fit extension in degrees.
ext_err float Symmetric (1 sigma) error on the best-fit 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 best-fit 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.

extension Options
Option Default Description
fit_position False Perform a simultaneous fit to the source position and extension.
free_background False Leave background parameters free when performing the fit. If True then any parameters that are currently free in the model will be fit simultaneously with the source of interest.
free_radius None Free normalizations of background sources within this angular distance in degrees from the source of interest. If None then no sources will be freed.
make_plots False Generate diagnostic plots.
psf_scale_fn None Tuple of two vectors (logE,f) defining an energy-dependent 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 corresponds to 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 best-fit model of extension.
spatial_model RadialGaussian Spatial model that will be used to test the sourceextension. The spatial scale parameter of the model will be set such that the 68% containment radius of the model is equal to the width parameter.
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 this source with the best-fit model for spatial extension if TS_ext > tsext_threshold.
width None Sequence of values in degrees for the likelihood scan over spatial extension (68% containment radius). If this argument is None then the scan points will be determined from width_min/width_max/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 scan points between width_min and width_max. Scan points will be spaced evenly on a logarithmic scale between width_min and width_max.
write_fits True Write the output to a FITS file.
write_npy True Write the output dictionary to a numpy file.

Reference/API

GTAnalysis.extension(name, **kwargs)

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 one-dimensional scan of the spatial extension parameter over the range specified with the width parameters. The 1-D profile likelihood is then used to compute the best-fit value, upper limit, and TS for extension. The background parameters that will be simultaneously profiled when performing the spatial scan can be controlled with the free_background and free_radius options. By default the position of the source will be fixed to its current position. A simultaneous fit to position and extension can be performed by setting fit_position to True.

Parameters:
  • name (str) – Source name.
  • fit_position (bool) – Perform a simultaneous fit to the source position and extension. (default : False)
  • free_background (bool) – Leave background parameters free when performing the fit. If True then any parameters that are currently free in the model will be fit simultaneously with the source of interest. (default : False)
  • free_radius (float) – Free normalizations of background sources within this angular distance in degrees from the source of interest. If None then no sources will be freed. (default : None)
  • make_plots (bool) – Generate diagnostic plots. (default : False)
  • psf_scale_fn (tuple) – Tuple of two vectors (logE,f) defining an energy-dependent 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 corresponds to 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. (default : None)
  • save_model_map (bool) – Save model counts cubes for the best-fit model of extension. (default : False)
  • spatial_model (str) – Spatial model that will be used to test the sourceextension. The spatial scale parameter of the model will be set such that the 68% containment radius of the model is equal to the width parameter. (default : RadialGaussian)
  • sqrt_ts_threshold (float) – Threshold on sqrt(TS_ext) that will be applied when update is True. If None then nothreshold is applied. (default : None)
  • update (bool) – Update this source with the best-fit model for spatial extension if TS_ext > tsext_threshold. (default : False)
  • width (list) – Sequence of values in degrees for the likelihood scan over spatial extension (68% containment radius). If this argument is None then the scan points will be determined from width_min/width_max/width_nstep. (default : None)
  • width_max (float) – Maximum value in degrees for the likelihood scan over spatial extent. (default : 1.0)
  • width_min (float) – Minimum value in degrees for the likelihood scan over spatial extent. (default : 0.01)
  • width_nstep (int) – Number of scan points between width_min and width_max. Scan points will be spaced evenly on a logarithmic scale between width_min and width_max. (default : 21)
  • write_fits (bool) – Write the output to a FITS file. (default : True)
  • write_npy (bool) – Write the output dictionary to a numpy file. (default : True)
  • 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:

dict