FluxPointsDataset¶
-
class
gammapy.spectrum.
FluxPointsDataset
(model, data, mask=None, likelihood='chi2')[source]¶ Bases:
gammapy.utils.fitting.Dataset
Fit a set of flux points with a parametric model.
Parameters: - model :
SpectralModel
Spectral model
- data :
FluxPoints
Flux points.
- mask :
numpy.ndarray
Mask to apply to the likelihood.
- likelihood : {“chi2”, “chi2assym”}
Likelihood function to use for the fit.
Examples
Load flux points from file and fit with a power-law model:
from astropy import units as u from gammapy.spectrum import FluxPoints, FluxPointsDataset form gammapy.utils.fitting import Fit from gammapy.spectrum.models import PowerLaw filename = '$GAMMAPY_DATA/tests/spectrum/flux_points/diff_flux_points.fits' flux_points = FluxPoints.read(filename) model = PowerLaw() dataset = FluxPointsDataset(model, flux_points) fit = Fit(dataset) result = fit.run() print(result) print(result.model)
Methods Summary
data_shape
()Shape of the flux points data flux_pred
()Compute predicted flux. likelihood
(parameters[, mask])Total likelihood given the current model parameters. likelihood_per_bin
()Likelihood per bin given the current model parameters Methods Documentation
- model :