SED Analysis

The sed() method computes a spectral energy distribution (SED) by fitting for the flux normalization of a source 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).

The fix_background and cov_scale parameters can be used to control how nuisance parameters are dealt with in the fit. By default this method will fix the parameters of background components ROI when fitting the source normalization in each energy bin (fix_background = True). Setting fix_background to False 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 to None can be used to perform the fit without priors.

The default configuration of sed() is defined with 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 Scale factor that sets the strength of the prior on nuisance parameters when ``fix_background``=True. Setting this to None disables the prior.
fix_background True Fix background normalization parameters when fitting the source flux in each energy bin. If True background normalizations will be profiled with a prior on their value with strength set by cov_scale.
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 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',fix_background=False,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 most align with the analysis bins.

The return value of sed() is a dictionary with the results of the analysis. 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']

# Print the SED flux values
>>> print(sed['flux'])

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():

sed Output Dictionary
HDU Column Name Description
SED E_MIN Lower edges of SED energy bins (MeV).
SED E_REF Upper edges of SED energy bins (MeV).
SED E_MAX Centers of SED energy bins (MeV).
SED REF_DFDE_E_MIN Differential flux of the reference model evaluated at the lower bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
SED REF_DFDE_E_MAX Differential flux of the reference model evaluated at the upper bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
SED REF_FLUX Flux of the reference model in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)).
SED REF_EFLUX Energy flux of the reference model in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)).
SED REF_DFDE Differential flux of the reference model evaluated at the bin center (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
SED REF_NPRED Number of predicted counts in the reference model in each bin.
SED NORM Normalization in each bin in units of the reference model.
SED NORM_ERR Symmetric error on the normalization in each bin in units of the reference model.
SED NORM_ERRN Lower 1-sigma error on the normalization in each bin in units of the reference model.
SED NORM_ERRP Upper 1-sigma error on the normalization in each bin in units of the reference model.
SED NORM_UL Upper limit on the normalization in each bin in units of the reference model.
SED LOGLIKE Log-likelihood value of the model for the best-fit amplitude.
SED NORM_SCAN 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 ref columns can be used to convert this matrix to the respective unit.
SED DLOGLIKE_SCAN Array of NxM delta-loglikelihood values for the profile likelihood scan in N energy bins and M scan points.
MODEL_FLUX ENERGY Energies at which the spectral band is evaluated (MeV).
MODEL_FLUX DFDE Central value of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)).
MODEL_FLUX DFDE_LO Lower 1-sigma bound of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)).
MODEL_FLUX DFDE_HI Upper 1-sigma bound of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)).
MODEL_FLUX DFDE_ERR Symmetric error of spectral band (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\)).
MODEL_FLUX DFDE_FERR Fractional width of spectral band.
PARAMS NAME Name of the parameter.
PARAMS VALUE Value of the parameter.
PARAMS ERROR 1-sigma parameter error (nan indicates that the parameter was not included in the fit).
PARAMS COVARIANCE Covariance matrix among free parameters.
PARAMS CORRELATION Correlation matrix among free parameters.

SED Dictionary

The following table describes the contents of the sed() output dictionary:

sed Output Dictionary
Key Type Description
logemin ndarray Lower edges of SED energy bins (log10(E/MeV)).
logemax ndarray Upper edges of SED energy bins (log10(E/MeV)).
logectr ndarray Centers of SED energy bins (log10(E/MeV)).
emin ndarray Lower edges of SED energy bins (MeV).
emax ndarray Upper edges of SED energy bins (MeV).
ectr ndarray Centers of SED energy bins (MeV).
ref_flux ndarray Flux of the reference model in each bin (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)).
ref_eflux ndarray Energy flux of the reference model in each bin (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\)).
ref_dfde ndarray Differential flux of the reference model evaluated at the bin center (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
ref_dfde_emin ndarray Differential flux of the reference model evaluated at the lower bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
ref_dfde_emax ndarray Differential flux of the reference model evaluated at the upper bin edge (\(\mathrm{cm}^{-2}~\mathrm{s}^{-1}~\mathrm{MeV}^{-1}\))
ref_e2dfde ndarray E^2 x the differential flux of the reference model evaluated at the bin center (\(\mathrm{MeV}~\mathrm{cm}^{-2}~\mathrm{s}^{-1}\))
ref_npred ndarray Number of predicted counts in the reference model in each bin.
norm ndarray Normalization in each bin in units of the reference model.
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.
loglike ndarray Log-likelihood of model for the best-fit amplitude.
npred ndarray Number of model counts.
fit_quality ndarray 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 ndarray Fit status parameter (0=ok).
index ndarray Spectral index of the power-law model used to fit this bin.
lnlprofile dict Likelihood scan for each energy bin.
norm_scan ndarray 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 ref columns can be used to convert this matrix to the respective unit.
dloglike_scan ndarray Array of NxM delta-loglikelihood values for the profile likelihood scan in N energy bins and M scan points.
loglike_scan ndarray Array of NxM loglikelihood values for the profile likelihood scan in N energy bins and M scan points.
params dict Dictionary of best-fit spectral parameters with 1-sigma uncertainties.
param_covariance ndarray Covariance matrix for the best-fit spectral parameters of the source.
param_names ndarray Array of names for the parameters in the global spectral parameterization of this source.
param_values ndarray Array of parameter values.
param_errors ndarray Array of parameter errors.
model_flux dict Dictionary containing the differential flux uncertainty band of the best-fit global spectral parameterization for the source.
config dict Copy of input configuration to this method.

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.
  • 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.
  • write_fits (bool) – Write a FITS file containing the SED analysis results.
  • write_npy (bool) – Write a numpy file with the contents of the output dictionary.
  • optimizer (dict) – Dictionary that overrides the default optimizer settings.
Returns:

sed – Dictionary containing output of the SED analysis. This dictionary is also saved to the ‘sed’ dictionary of the Source instance.

Return type:

dict