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.
Parameters: obs :
SpectrumObservation
orSpectrumObservationList
Spectrum observation(s)
groups :
SpectrumEnergyGroups
Energy groups (usually output of
SpectrumEnergyGroupMaker
)model :
SpectralModel
Global model (usually output of
SpectrumFit
)Methods Summary
compute_approx_model
(global_model, energy_group)Compute approximate model, to be used in the energy bin. 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[, …])Methods Documentation
-
static
compute_approx_model
(global_model, energy_group)[source]¶ Compute approximate model, to be used in the energy bin. TODO: At the moment just the global model with fixed parameters is returned
-
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)
-
static