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)
Warning
If the best-fit extension differs significantly from the nominal value, the user is recommended to re-optimize the ROI.
Energy-dependent Extension Fit¶
Use the option fit_ebin=True
to perform separate exention scans
in each energy bin (in addition to the joint fit):
gta.extension('sourceA', fit_ebin=True, loge_bins=np.linspace(3, 6.5, 15) )
By default, the method will use the energy bins of the underlying
analysis. The loge_bins
keyword argument can be used to override
the default binning with the restriction that the SED energy bins
must align with the analysis bins. The bins used in the analysis can be
found with gta.log_energies
. For example if in the analysis
8 energy bins per decade are considered and you want to make the SED in 4 bins
per decade you can specify loge_bins=gta.log_energies[::2]
.
User-defined Fit Range¶
The default extension scan covers 21 points between 0.01 deg and 1.0 deg,
evenly spaced in log space. The user may overwrite the fit range
(width_min
and width_max
keywords) and/or the number of
points for the scan (width_nstep
) or directly supply a list
of extensions to be tested (width
keyword).
The point source hypothesis is always tested as well. If the extension range includes the nominal extension value used during ROI optimization, this value will be explicitly scanned as well.
Warning
The wider the range of extension values to be fit over, the more important it is to consider freeing the normalization of the background sources to avoid artifacts.
Extension Dictionary¶
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:
Key | Type | Description |
---|---|---|
name |
str |
Name of source. |
file |
str |
Name of output FITS file. |
config |
dict |
Copy of the input configuration to this method. |
width |
ndarray |
Vector of width (intrinsic 68% containment radius) values (deg). |
dloglike |
ndarray |
Delta-log-likelihood values for each point in the profile likelihood scan. |
loglike |
ndarray |
Log-likelihood values for each point in the scan over the spatial extension. |
loglike_ptsrc |
float |
Log-Likelihood value of the best-fit point-source model. |
loglike_ext |
float |
Log-Likelihood of the best-fit extended source model. |
loglike_init |
float |
Log-Likelihood of model before extension fit. |
loglike_base |
float |
Log-Likelihood of model after initial spectral fit. |
ext |
float |
Best-fit extension (68% containment radius) (deg). |
ext_err_hi |
float |
Upper (1-sigma) error on the best-fit extension (deg). |
ext_err_lo |
float |
Lower (1-sigma) error on the best-fit extension (deg). |
ext_err |
float |
Symmetric (1-sigma) error on the best-fit extension (deg). |
ext_ul95 |
float |
95% CL upper limit on the spatial extension (deg). |
ts_ext |
float |
Test statistic for the extension hypothesis. |
ebin_e_min |
ndarray |
|
ebin_e_ctr |
ndarray |
|
ebin_e_max |
ndarray |
|
ebin_ext |
ndarray |
Best-fit extension as measured in each energy bin (intrinsic 68% containment radius) (deg). |
ebin_ext_err |
ndarray |
Symmetric (1-sigma) error on best-fit extension in each energy bin (deg). |
ebin_ext_err_hi |
ndarray |
Upper (1-sigma) error on best-fit extension in each energy bin (deg). |
ebin_ext_err_lo |
ndarray |
Lower (1-sigma) error on best-fit extension in each energy bin (deg). |
ebin_ext_ul95 |
ndarray |
95% CL upper limit on best-fit extension in each energy bin (deg). |
ebin_ts_ext |
ndarray |
Test statistic for extension hypothesis in each energy bin. |
ebin_dloglike |
ndarray |
Delta-log-likelihood values for scan over the spatial extension in each energy bin. |
ebin_loglike |
ndarray |
Log-likelihood values for scan over the spatial extension in each energy bin. |
ebin_loglike_ptsrc |
ndarray |
Log-Likelihood value of the best-fit point-source model in each energy bin. |
ebin_loglike_ext |
ndarray |
Log-Likelihood value of the best-fit extended source model in each energy bin. |
ra |
float |
Right ascension of best-fit position (deg). |
dec |
float |
Declination of best-fit position (deg). |
glon |
float |
Galactic Longitude of best-fit position (deg). |
glat |
float |
Galactic Latitude of best-fit position (deg). |
ra_err |
float |
Std. deviation of positional uncertainty in right ascension (deg). |
dec_err |
float |
Std. deviation of positional uncertainty in declination (deg). |
glon_err |
float |
Std. deviation of positional uncertainty in galactic longitude (deg). |
glat_err |
float |
Std. deviation of positional uncertainty in galactic latitude (deg). |
pos_offset |
float |
Angular offset (deg) between the old and new (localized) source positions. |
pos_err |
float |
1-sigma positional uncertainty (deg). |
pos_r68 |
float |
68% positional uncertainty (deg). |
pos_r95 |
float |
95% positional uncertainty (deg). |
pos_r99 |
float |
99% positional uncertainty (deg). |
pos_err_semimajor |
float |
1-sigma uncertainty (deg) along major axis of uncertainty ellipse. |
pos_err_semiminor |
float |
1-sigma uncertainty (deg) along minor axis of uncertainty ellipse. |
pos_angle |
float |
Position angle of uncertainty ellipse with respect to major axis. |
tsmap |
Map |
|
ptsrc_tot_map |
Map |
|
ptsrc_src_map |
Map |
|
ptsrc_bkg_map |
Map |
|
ext_tot_map |
Map |
|
ext_src_map |
Map |
|
ext_bkg_map |
Map |
|
source_fit |
dict |
Dictionary with parameters of the best-fit extended source model. |
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 |
---|---|---|
fit_ebin |
False | Perform a fit for the angular extension in each analysis energy bin. |
fit_position |
False | Perform a simultaneous fit to the source position and extension. |
fix_shape |
False | Fix spectral shape parameters of the source of interest. If True then only the normalization parameter will be fit. |
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. |
make_tsmap |
True | Make a TS map for the source of interest. |
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. |
tsmap_fitter |
tsmap | Set the method for generating the TS map. Valid options are tsmap or tscube. |
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. |