FluxPointsEstimator#

class gammapy.estimators.FluxPointsEstimator[source]#

Bases: FluxEstimator, ParallelMixin

Flux points estimator.

Estimates flux points for a given list of datasets, energies and spectral model.

To estimate the flux point the amplitude of the reference spectral model is fitted within the energy range defined by the energy group. This is done for each group independently. The amplitude is re-normalized using the “norm” parameter, which specifies the deviation of the flux from the reference model in this energy group. See https://gamma-astro-data-formats.readthedocs.io/en/latest/spectra/binned_likelihoods/index.html for details.

The method is also described in the Fermi-LAT catalog paper or the H.E.S.S. Galactic Plane Survey paper

Parameters:
sourcestr or int

For which source in the model to compute the flux points.

n_sigmafloat, optional

Number of sigma to use for asymmetric error computation. Must be a positive value. Default is 1.

n_sigma_ulfloat, optional

Number of sigma to use for upper limit computation. Must be a positive value. Default is 2.

n_sigma_sensitivityfloat, optional

Sigma to use for sensitivity computation. Must be a positive value. Default is 5.

selection_optionallist of str, optional

Which additional quantities to estimate. Available options are:

  • “all”: all the optional steps are executed.

  • “errn-errp”: estimate asymmetric errors on flux.

  • “ul”: estimate upper limits.

  • “scan”: estimate fit statistic profiles.

  • “sensitivity”: estimate sensitivity for a given significance.

Default is None so the optional steps are not executed.

energy_edgeslist of Quantity, optional

Edges of the flux points energy bins. The resulting bin edges won’t be exactly equal to the input ones, but rather the closest values to the energy axis edges of the parent dataset. Default is [1, 10] TeV.

fitFit, optional

Fit instance specifying the backend and fit options. If None, the Fit instance is created internally. Default is None.

reoptimizebool, optional

If True, the free parameters of the other models are fitted in each bin independently, together with the norm of the source of interest (but the other parameters of the source of interest are kept frozen). If False, only the norm of the source of interest is fitted, and all other parameters are frozen at their current values. Default is False.

sum_over_energy_groupsbool, optional

Whether to sum over the energy groups or fit the norm on the full energy grid. Default is None.

n_jobsint, optional

Number of processes used in parallel for the computation. The number of jobs is limited to the number of physical CPUs. If None, defaults to N_JOBS_DEFAULT. Default is None.

parallel_backend{“multiprocessing”, “ray”}, optional

Which backend to use for multiprocessing. If None, defaults to BACKEND_DEFAULT.

normParameter or dict, optional

Norm parameter used for the fit. Default is None and a new parameter is created automatically, with value=1, name=”norm”, scan_min=0.2, scan_max=5, and scan_n_values = 11. By default, the min and max are not set (consider setting them if errors or upper limits computation fails). If a dict is given, the entries should be a subset of Parameter arguments.

Notes

Examples

from astropy import units as u
from gammapy.datasets import SpectrumDatasetOnOff
from gammapy.estimators import FluxPointsEstimator
from gammapy.modeling.models import PowerLawSpectralModel, SkyModel

path = "$GAMMAPY_DATA/joint-crab/spectra/hess/"
dataset = SpectrumDatasetOnOff.read(path + "pha_obs23523.fits")

pwl = PowerLawSpectralModel(index=2.7, amplitude='3e-11  cm-2 s-1 TeV-1')

dataset.models = SkyModel(spectral_model=pwl, name="crab")

estimator = FluxPointsEstimator(
    source="crab",
    energy_edges=[0.1, 0.3, 1, 3, 10, 30, 100] * u.TeV,
)

fp = estimator.run(dataset)
print(fp)

Attributes Summary

tag

Methods Summary

estimate_flux_point(datasets, energy_min, ...)

Estimate flux point for a single energy group.

run(datasets)

Run the flux point estimator for all energy groups.

Attributes Documentation

tag = 'FluxPointsEstimator'#

Methods Documentation

estimate_flux_point(datasets, energy_min, energy_max)[source]#

Estimate flux point for a single energy group.

Parameters:
datasetsDatasets

Datasets.

energy_min, energy_maxQuantity

Energy bounds to compute the flux point for.

Returns:
resultdict

Dictionary with results for the flux point.

run(datasets)[source]#

Run the flux point estimator for all energy groups.

Parameters:
datasetsDatasets

Datasets.

Returns:
flux_pointsFluxPoints

Estimated flux points.

__init__(energy_edges=<Quantity [ 1., 10.] TeV>, sum_over_energy_groups=False, n_jobs=None, parallel_backend=None, **kwargs)[source]#
classmethod __new__(*args, **kwargs)#