SED Analysis¶
The sed()
method can be used
to compute a spectral energy distribution (SED) for a source by
fitting the source flux normalization in a sequence of energy bins.
The normalization in each bin is fit independently using a power-law
spectrum 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). By default this method will fix the
parameters of all background components in the ROI. To leave
background parameters free in the fit set fix_background
to True.
The default configuration of
sed()
is defined in the sed
section of the configuration file:
Option | Default | Description |
---|---|---|
bin_index |
2.0 | Spectral index that will be use when fitting the energy distribution within an energy bin. |
fix_background |
True | Fix background parameters when fitting the source flux in each energy bin. |
ul_confidence |
0.95 | Confidence level for upper limit calculation. |
use_local_index |
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 bin_index will be used. |
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 for the SED
>>> sed = gta.sed('sourceA',energies=[2.0,2.5,3.0,3.5,4.0,4.5,5.0], bin_index=2)
By default the method will use the energy bins of the underlying
analysis. The energies
keyword argument can be used to override
the default binning with the restriction that the SED energy bins
most align with the analysis bins.
The output of the SED analysis are written to a dictionary which is
the return argument of the SED method. The output dictionary is also
saved to the sed
dictionary of the Source
instance which is written to the output file generated by
write_roi()
. The following
example shows how the output dictionary can be captured from either
from the method return value or later accessed from the
ROIModel
instance:
# Get the sed results from the return argument
>>> sed = gta.sed('sourceA')
# Get the sed results from the source object
>>> sed = gta.roi['sourceA']
The contents of the output dictionary are described below:
Key | Type | Description |
---|---|---|
Npred |
ndarray |
Number of model counts. |
config |
dict | Copy of the input parameters to this method. |
dfde |
ndarray |
Differential flux in each bin (MeV^{-1} cm^{-2} s^{-1}). |
dfde_err |
ndarray |
1-sigma error on dfde evaluated from likelihood curvature. |
dfde_err_hi |
ndarray |
Upper 1-sigma error on dfde evaluated from the profile likelihood (MINOS errors). |
dfde_err_lo |
ndarray |
Lower 1-sigma error on dfde evaluated from the profile likelihood (MINOS errors). |
dfde_ul |
ndarray |
Upper limit on dfde evaluated from the profile likelihood using a CL = ul_confidence . |
dfde_ul95 |
ndarray |
95% CL upper limit on dfde evaluated from the profile likelihood (MINOS errors). |
e2dfde |
ndarray |
E^2 x the differential flux in each bin (MeV^{-1} cm^{-2} s^{-1}). |
e2dfde_err |
ndarray |
1-sigma error on e2dfde evaluated from likelihood curvature. |
e2dfde_err_hi |
ndarray |
Upper 1-sigma error on e2dfde evaluated from the profile likelihood (MINOS errors). |
e2dfde_err_lo |
ndarray |
Lower 1-sigma error on e2dfde evaluated from the profile likelihood (MINOS errors). |
e2dfde_ul |
ndarray |
Upper limit on e2dfde evaluated from the profile likelihood using a CL = ul_confidence . |
e2dfde_ul95 |
ndarray |
95% CL upper limit on e2dfde evaluated from the profile likelihood (MINOS errors). |
ecenter |
ndarray |
Centers of SED energy bins (log10(E/MeV)). |
eflux |
ndarray |
Energy flux in each bin (MeV cm^{-2} s^{-1}). |
emax |
ndarray |
Upper edges of SED energy bins (log10(E/MeV)). |
emin |
ndarray |
Lower edges of SED energy bins (log10(E/MeV)). |
fit_quality |
ndarray |
Fit quality parameter. |
flux |
ndarray |
Flux in each bin (cm^{-2} s^{-1}). |
index |
ndarray |
Spectral index of the power-law model used to fit this bin. |
lnlprofile |
dict | Likelihood scan for each energy bin. |
ts |
ndarray |
Test statistic. |
Reference/API¶
-
GTAnalysis.
sed
(name, profile=True, energies=None, **kwargs)[source] Generate an SED for a source. This function will fit the normalization of a given source in each energy bin.
Parameters: - name (str) – Source name.
- profile (bool) – Profile the likelihood in each energy bin.
- energies (
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. - bin_index (float) – Spectral index that will be use when fitting the energy distribution within an energy bin.
- use_local_index (bool) – 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
bin_index
will be used. - fix_background (bool) – Fix background components when fitting the flux normalization in each energy bin. If fix_background=False then all background parameters that are currently free in the fit will be profiled. By default fix_background=True.
- ul_confidence (float) – Set the confidence level that will be used for the calculation of flux upper limits in each energy bin.
Returns: sed – This dictionary is also saved to the ‘sed’ dictionary of the
Source
instance.Return type: dict Dictionary containing output of the SED analysis.