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:
objectClass 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 :
SpectralModelBest-fit model
fit_range :
QuantityEnergy 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 :
SpectralModelBest-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 :
SpectrumObservationInput data used for the fit
Attributes Summary
expected_background_countsCountsSpectrumof predicted background countsexpected_on_countsCountsSpectrumof predicted on countsexpected_source_countsCountsSpectrumof predicted source countsresidualsResiduals 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 Tableto_yaml(filename[, mode])Write YAML file Attributes Documentation
-
expected_background_counts¶ CountsSpectrumof predicted background counts
-
expected_on_counts¶ CountsSpectrumof predicted on counts
-
expected_source_counts¶ CountsSpectrumof 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 :
TableButterfly 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
-