SpectrumFitResult¶
-
class
gammapy.spectrum.
SpectrumFitResult
(model, fit_range=None, statname=None, statval=None, stat_per_bin=None, npred_src=None, npred_bkg=None, background_model=None, fluxes=None, flux_errors=None, obs=None)[source]¶ Bases:
object
Class representing the result of a spectral fit
TODO: This only supports WStat fits at the moment. Find a solution to display also Cash fits (flag, subclass).
Parameters: model :
SpectralModel
Best-fit model
fit_range :
Quantity
Energy range of the spectral fit
statname : str, optional
Statistic used for the fit
statval : float, optional
Final fit statistic
stat_per_bin : float, optional
Fit statistic value per bin
npred_src : array-like, optional
Source counts predicted by the fit
npred_bkg : array-like, optional
Background counts predicted by the fit
background_model :
SpectralModel
Best-fit background model
flux_at_1TeV : dict, optional
Flux for the fitted model at 1 TeV
flux_at_1TeV_err : dict, optional
Error on the flux for the fitted model at 1 TeV
obs :
SpectrumObservation
Input data used for the fit
Attributes Summary
expected_background_counts
CountsSpectrum
of predicted background countsexpected_on_counts
CountsSpectrum
of predicted on countsexpected_source_counts
CountsSpectrum
of predicted source countsresiduals
Residuals Methods Summary
butterfly
([energy, flux_unit])Compute butterfly table. from_dict
(val)from_yaml
(filename)Create cls from YAML file info
()Print summary info. plot
(**kwargs)Standard debug plot. plot_counts
(ax)Plot predicted and detected counts. plot_residuals
(ax)Plot residuals. to_dict
()Convert to dict to_table
([energy_unit, flux_unit])Convert to Table
to_yaml
(filename[, mode])Write YAML file Attributes Documentation
-
expected_background_counts
¶ CountsSpectrum
of predicted background counts
-
expected_on_counts
¶ CountsSpectrum
of predicted on counts
-
expected_source_counts
¶ CountsSpectrum
of predicted source counts
-
residuals
¶ Residuals
Prediced on counts - expected on counts
Methods Documentation
-
butterfly
(energy=None, flux_unit='TeV-1 cm-2 s-1')[source]¶ Compute butterfly table.
Parameters: energy :
Quantity
, optionalEnergies at which to evaluate the butterfly.
flux_unit : str
Flux unit for the butterfly.
Returns: table :
Table
Butterfly info in table (cols: ‘energy’, ‘flux’, ‘flux_lo’, ‘flux_hi’)
-
classmethod
from_yaml
(filename)[source]¶ Create cls from YAML file
Parameters: filename : str, Path
File to read
-