SED Analysis
The sed()
method computes a
spectral energy distribution (SED) by performing independent fits for
the flux normalization of a source in bins of energy. The
normalization in each bin is fit using a power-law spectral
parameterization with a fixed index. The value of this index can be
set with the bin_index
parameter or allowed to vary over the
energy range according to the local slope of the global spectral model
(with the use_local_index
parameter).
The free_background
, free_radius
, and cov_scale
parameters
control how nuisance parameters are dealt with in the fit. By default
the method will fix the parameters of background components ROI when
fitting the source normalization in each energy bin
(free_background=False
). Setting free_background=True
will
profile the normalizations of all background components that were free
when the method was executed. In order to minimize overfitting,
background normalization parameters are constrained with priors taken
from the global fit. The strength of the priors is controlled with
the cov_scale
parameter. A larger (smaller) value of
cov_scale
applies a weaker (stronger) constraint on the background
amplitude. Setting cov_scale=None
performs an unconstrained fit
without priors.
Examples
The sed()
method is executed
by passing the name of a source in the ROI as a single argument.
Additional keyword argument can also be provided to override the
default configuration of the method:
# Run analysis with default energy binning
sed = gta.sed('sourceA')
# Override the energy binning and the assumed power-law index
# within the bin
sed = gta.sed('sourceA', loge_bins=[2.0,2.5,3.0,3.5,4.0,4.5,5.0], bin_index=2.3)
# Profile background normalization parameters with prior scale of 5.0
sed = gta.sed('sourceA', free_background=True, cov_scale=5.0)
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]
.
The return value of sed()
is a
dictionary with the results of the analysis. The following example
shows how to extract values from the output dictionary and load the
SED data from the output FITS file:
# Get the sed results from the return argument
sed = gta.sed('sourceA', outfile='sed.fits')
# Print the SED flux values
print(sed['flux'])
# Reload the SED table from the output FITS file
from astropy.table import Table
sed_tab = Table.read('sed.fits')
The contents of the FITS file and output dictionary are documented in SED FITS File and SED Dictionary.
SED FITS File
The following table describes the contents of the FITS file written by
sed()
. The SED
HDU uses
that data format specification for SEDs documented here.
HDU, Column Name, Description |
||
---|---|---|
SED |
|
Lower edges of SED energy bins (MeV). |
SED |
|
Upper edges of SED energy bins (MeV). |
SED |
|
Centers of SED energy bins (MeV). |
SED |
|
Differential flux of the reference model evaluated at the lower bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
SED |
|
Differential flux of the reference model evaluated at the upper bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
SED |
|
Flux of the reference model in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
SED |
|
Energy flux of the reference model in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
SED |
|
Differential flux of the reference model evaluated at the bin center (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
SED |
|
Number of predicted counts in the reference model in each bin. |
SED |
|
Normalization in each bin in units of the reference model. |
SED |
|
Symmetric error on the normalization in each bin in units of the reference model. |
SED |
|
Lower 1-sigma error on the normalization in each bin in units of the reference model. |
SED |
|
Upper 1-sigma error on the normalization in each bin in units of the reference model. |
SED |
|
Upper limit on the normalization in each bin in units of the reference model. |
SED |
|
Log-likelihood value of the model for the best-fit amplitude. |
SED |
|
Array of NxM normalization values for the profile likelihood scan in N energy bins and M scan points. A row-wise multiplication with any of |
SED |
|
Array of NxM delta-loglikelihood values for the profile likelihood scan in N energy bins and M scan points. |
MODEL_FLUX |
|
Energies at which the spectral band is evaluated (MeV). |
MODEL_FLUX |
|
Central value of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)). |
MODEL_FLUX |
|
Lower 1-sigma bound of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)). |
MODEL_FLUX |
|
Upper 1-sigma bound of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)). |
MODEL_FLUX |
|
Symmetric error of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)). |
MODEL_FLUX |
|
Fractional width of spectral band. |
PARAMS |
|
Name of the parameter. |
PARAMS |
|
Value of the parameter. |
PARAMS |
|
1-sigma parameter error (nan indicates that the parameter was not included in the fit). |
PARAMS |
|
Covariance matrix among free parameters. |
PARAMS |
|
Correlation matrix among free parameters. |
SED Dictionary
The following table describes the contents of the
sed()
output dictionary:
Key, Type, Description |
||
---|---|---|
|
Lower edges of SED energy bins (log10(E/MeV)). |
|
|
Upper edges of SED energy bins (log10(E/MeV)). |
|
|
Centers of SED energy bins (log10(E/MeV)). |
|
|
Reference energies of SED energy bins (log10(E/MeV)). |
|
|
Lower edges of SED energy bins (MeV). |
|
|
Upper edges of SED energy bins (MeV). |
|
|
Centers of SED energy bins (MeV). |
|
|
Reference energies of SED energy bins (MeV). |
|
|
Flux of the reference model in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
|
|
Energy flux of the reference model in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
|
|
Differential flux of the reference model evaluated at the bin center (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
|
|
Differential flux of the reference model evaluated at the lower bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
|
|
Differential flux of the reference model evaluated at the upper bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)) |
|
|
E^2 x the differential flux of the reference model evaluated at the bin center (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)) |
|
|
Number of predicted counts in the reference model in each bin. |
|
|
Normalization in each bin in units of the reference model. |
|
|
Flux in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
|
|
Energy flux in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
|
|
Differential flux in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)). |
|
|
E^2 x the differential flux in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)). |
|
|
1-sigma error on dnde evaluated from likelihood curvature. |
|
|
Lower 1-sigma error on dnde evaluated from the profile likelihood (MINOS errors). |
|
|
Upper 1-sigma error on dnde evaluated from the profile likelihood (MINOS errors). |
|
|
95% CL upper limit on dnde evaluated from the profile likelihood (MINOS errors). |
|
|
Upper limit on dnde evaluated from the profile likelihood using a CL = |
|
|
1-sigma error on e2dnde evaluated from likelihood curvature. |
|
|
Lower 1-sigma error on e2dnde evaluated from the profile likelihood (MINOS errors). |
|
|
Upper 1-sigma error on e2dnde evaluated from the profile likelihood (MINOS errors). |
|
|
95% CL upper limit on e2dnde evaluated from the profile likelihood (MINOS errors). |
|
|
Upper limit on e2dnde evaluated from the profile likelihood using a CL = |
|
|
Test statistic. |
|
|
Log-likelihood of model for the best-fit amplitude. |
|
|
Number of model counts. |
|
|
Fit quality parameter for MINUIT and NEWMINUIT optimizers (3 - Full accurate covariance matrix, 2 - Full matrix, but forced positive-definite (i.e. not accurate), 1 - Diagonal approximation only, not accurate, 0 - Error matrix not calculated at all). |
|
|
Fit status parameter (0=ok). |
|
|
Spectral index of the power-law model used to fit this bin. |
|
|
Array of NxM normalization values for the profile likelihood scan in N energy bins and M scan points. A row-wise multiplication with any of |
|
|
Array of NxM delta-loglikelihood values for the profile likelihood scan in N energy bins and M scan points. |
|
|
Array of NxM loglikelihood values for the profile likelihood scan in N energy bins and M scan points. |
|
|
Covariance matrix for the best-fit spectral parameters of the source. |
|
|
Array of names for the parameters in the global spectral parameterization of this source. |
|
|
Array of parameter values. |
|
|
Array of parameter errors. |
|
|
Dictionary containing the differential flux uncertainty band of the best-fit global spectral parameterization for the source. |
|
|
Copy of input configuration to this method. |
Configuration
The default configuration of the method is controlled with the sed 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 |
||
---|---|---|
|
2.0 |
Spectral index that will be use when fitting the energy distribution within an energy bin. |
|
3.0 |
Scale factor that sets the strength of the prior on nuisance parameters that are free. Setting this to None disables the prior. |
|
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. |
|
None |
Set the parameters of the source of interest that will be freed when performing the global fit. By default all parameters will be freed. |
|
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. |
|
False |
Generate diagnostic plots. |
|
0.95 |
Confidence level for flux upper limit. |
|
4 |
Minimum threshold of TS for displaying flux point below this vlaue an Upper Limit is calculated. |
|
False |
Use a power-law approximation to the shape of the global spectrum in each bin. If this is false then a constant index set to |
|
True |
Write the output to a FITS file. |
|
True |
Write the output dictionary to a numpy file. |
Reference/API
- GTAnalysis.sed(name, **kwargs)
Generate a spectral energy distribution (SED) for a source. This function will fit the normalization of the source in each energy bin. By default the SED will be generated with the analysis energy bins but a custom binning can be defined with the
loge_bins
parameter.- Parameters:
name (str) – Source name.
prefix (str) – Optional string that will be prepended to all output files (FITS and rendered images).
loge_bins (
ndarray
) – Sequence of energies in log10(E/MeV) defining the edges of the energy bins. If this argument is None then the analysis energy bins will be used. The energies in this sequence must align with the bin edges of the underyling analysis instance.{options}
optimizer (dict) – Dictionary that overrides the default optimizer settings.
- Returns:
sed – Dictionary containing output of the SED analysis.
- Return type: