Note

You are not reading the most up to date version of Gammapy documentation.
Access the latest stable version v1.3 or the list of Gammapy releases.

FluxPointEstimator

class gammapy.spectrum.FluxPointEstimator(obs, groups, model)[source]

Bases: object

Flux point estimator.

Computes flux points for a given spectrum observation dataset (a 1-dim on/off observation), energy binning and spectral model.

A spectral model shape is assumed, all parameters except the norm are fixed A 1D amplitude fit is done, to find the amplitude so that npred equals excess.

This is done for each group independently.

The method is used for example in this FERMI-LAT catalog paper https://ui.adsabs.harvard.edu/#abs/2015ApJS..218…23A or the HESS GPS paper https://ui.adsabs.harvard.edu/#abs/2018A%26A…612A…1H

Parameters:

obs : SpectrumObservation or SpectrumObservationList

Spectrum observation(s)

groups : SpectrumEnergyGroups

Energy groups (usually output of SpectrumEnergyGroupMaker)

model : SpectralModel

Global model (usually output of SpectrumFit)

Attributes Summary

fit Instance of SpectrumFit
obs Observations participating in the fit

Methods Summary

compute_flux_point(energy_group)
compute_flux_point_sqrt_ts(fit, stat_best_fit) Compute sqrt(TS) for flux point.
compute_flux_point_ul(fit, stat_best_fit[, …]) Compute upper limits for flux point values.
compute_points()
fit_point(model, energy_group, energy_ref[, …])

Attributes Documentation

fit

Instance of SpectrumFit

obs

Observations participating in the fit

Methods Documentation

compute_flux_point(energy_group)[source]
compute_flux_point_sqrt_ts(fit, stat_best_fit)[source]

Compute sqrt(TS) for flux point.

Parameters:

fit : SpectrumFit

Instance of spectrum fit.

stat_best_fit : float

TS value for best fit result.

Returns:

sqrt_ts : float

Sqrt(TS) for flux point.

compute_flux_point_ul(fit, stat_best_fit, delta_ts=4, negative=False)[source]

Compute upper limits for flux point values.

Parameters:

fit : SpectrumFit

Instance of spectrum fit.

stat_best_fit : float

TS value for best fit result.

delta_ts : float (4)

Difference in log-likelihood for given confidence interval. See Example below.

negative : bool

Compute limit in negative direction.

Returns:

dnde_ul : Quantity

Flux point upper limit.

Examples

To compute ~95% confidence upper limits (or 2 sigma) you can use:

from scipy.stats import chi2, norm

sigma = 2
cl = 1 - 2 * norm.sf(sigma) # using two sided p-value
delta_ts = chi2.isf(1 - cl, df=1)
compute_points()[source]
fit_point(model, energy_group, energy_ref, sqrt_ts_threshold=1)[source]