# SED Analysis¶

The sed() method computes 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:

sed Options
Option Default Description
bin_index 2.0 Spectral index that will be use when fitting the energy distribution within an energy bin.
cov_scale 3.0
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:

sed Output Dictionary
Key Type Description
emin ndarray Lower edges of SED energy bins (log10(E/MeV)).
emax ndarray Upper edges of SED energy bins (log10(E/MeV)).
ecenter ndarray Centers of SED energy bins (log10(E/MeV)).
flux ndarray Flux in each bin ($$\mathrm{cm}^{-2}~\mathrm{s}^{-1}$$).
eflux ndarray Energy flux in each bin ($$\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}$$).
dfde ndarray Differential flux in each bin ($$\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}$$).
e2dfde ndarray E^2 x the differential flux in each bin ($$\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}$$).
dfde_err ndarray 1-sigma error on dfde evaluated from likelihood curvature.
dfde_err_lo ndarray Lower 1-sigma error on dfde evaluated from the profile likelihood (MINOS errors).
dfde_err_hi ndarray Upper 1-sigma error on dfde evaluated from the profile likelihood (MINOS errors).
dfde_ul95 ndarray 95% CL upper limit 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.
e2dfde_err ndarray 1-sigma error on e2dfde evaluated from likelihood curvature.
e2dfde_err_lo ndarray Lower 1-sigma error on e2dfde evaluated from the profile likelihood (MINOS errors).
e2dfde_err_hi ndarray Upper 1-sigma error on e2dfde evaluated from the profile likelihood (MINOS errors).
e2dfde_ul95 ndarray 95% CL upper limit 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.
ts ndarray Test statistic.
Npred ndarray Number of model counts.
fit_quality ndarray Fit quality parameter.
index ndarray Spectral index of the power-law model used to fit this bin.
lnlprofile dict Likelihood scan for each energy bin.
config dict Copy of input configuration to this method.

## Reference/API¶

GTAnalysis.sed(name, profile=True, energies=None, **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 energies parameter.

Parameters: name (str) – Source name. prefix (str) – Optional string that will be prepended to all output files (FITS and rendered images). 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. cov_scale (float) – Scaling factor that will be applied when setting the gaussian prior on the normalization of free background sources. If this parameter is None then no gaussian prior will be applied. sed – Dictionary containing output of the SED analysis. This dictionary is also saved to the ‘sed’ dictionary of the Source instance. dict