FluxPointsEstimator#

class gammapy.estimators.FluxPointsEstimator(energy_edges=<Quantity [ 1., 10.] TeV>, sum_over_energy_groups=False, **kwargs)[source]#

Bases: gammapy.estimators.flux.FluxEstimator

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 https://ui.adsabs.harvard.edu/abs/2015ApJS..218…23A or the HESS Galactic Plane Survey paper https://ui.adsabs.harvard.edu/#abs/2018A%26A…612A…1H

Parameters
energy_edgesQuantity

Energy edges of the flux point bins.

sourcestr or int

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

norm_minfloat

Minimum value for the norm used for the fit statistic profile evaluation.

norm_maxfloat

Maximum value for the norm used for the fit statistic profile evaluation.

norm_n_valuesint

Number of norm values used for the fit statistic profile.

norm_valuesnumpy.ndarray

Array of norm values to be used for the fit statistic profile.

n_sigmaint

Number of sigma to use for asymmetric error computation. Default is 1.

n_sigma_ulint

Number of sigma to use for upper limit computation. Default is 2.

selection_optionallist of str

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.

Default is None so the optional steps are not executed.

fitFit

Fit instance specifying the backend and fit options.

reoptimizebool

Re-optimize other free model parameters. Default is True.

sum_over_energy_groupsbool

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

Attributes Summary

config_parameters

Config parameters

selection_optional

tag

Methods Summary

copy()

Copy estimator

estimate_best_fit(datasets, parameter)

Estimate parameter asymmetric errors

estimate_counts(datasets)

Estimate counts for the flux point.

estimate_errn_errp(datasets, parameter)

Estimate parameter asymmetric errors

estimate_flux_point(datasets, energy_min, ...)

Estimate flux point for a single energy group.

estimate_npred(datasets)

Estimate npred for the flux point.

estimate_npred_excess(datasets)

Estimate npred excess for the source.

estimate_scan(datasets, parameter)

Estimate parameter stat scan.

estimate_ts(datasets, parameter)

Estimate parameter ts

estimate_ul(datasets, parameter)

Estimate parameter ul.

get_scale_model(models)

Set scale model

run(datasets)

Run the flux point estimator for all energy groups.

Attributes Documentation

config_parameters#

Config parameters

selection_optional#
tag = 'FluxPointsEstimator'#

Methods Documentation

copy()#

Copy estimator

estimate_best_fit(datasets, parameter)#

Estimate parameter asymmetric errors

Parameters
datasetsDatasets

Datasets

parameterParameter

For which parameter to get the value

Returns
resultdict

Dict with the various parameter estimation values. Entries are:

  • parameter.name: best fit parameter value

  • “stat”: best fit total stat.

  • “success”: boolean flag for fit success

  • parameter.name_err: covariance-based error estimate on parameter value

static estimate_counts(datasets)#

Estimate counts for the flux point.

Parameters
datasetsDatasets

Datasets

Returns
resultdict

Dict with an array with one entry per dataset with the sum of the masked counts.

estimate_errn_errp(datasets, parameter)#

Estimate parameter asymmetric errors

Parameters
datasetsDatasets

Datasets

parameterParameter

For which parameter to get the value

Returns
resultdict

Dict with the parameter asymmetric errors. Entries are:

  • parameter.name_errp : positive error on parameter value

  • parameter.name_errn : negative error on parameter value

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

Dict with results for the flux point.

static estimate_npred(datasets)#

Estimate npred for the flux point.

Parameters
datasetsDatasets

Datasets

Returns
resultdict

Dict with an array with one entry per dataset with the sum of the masked npred.

estimate_npred_excess(datasets)#

Estimate npred excess for the source.

Parameters
datasetsDatasets

Datasets

Returns
resultdict

Dict with an array with one entry per dataset with the sum of the masked npred excess.

estimate_scan(datasets, parameter)#

Estimate parameter stat scan.

Parameters
datasetsDatasets

The datasets used to estimate the model parameter

parameterParameter

For which parameter to get the value

Returns
resultdict

Dict with the parameter fit scan values. Entries are:

  • parameter.name_scan : parameter values scan

  • “stat_scan” : fit statistic values scan

estimate_ts(datasets, parameter)#

Estimate parameter ts

Parameters
datasetsDatasets

Datasets

parameterParameter

For which parameter to get the value

Returns
resultdict

Dict with the TS of the best fit value compared to the null hypothesis. Entries are:

  • “ts” : fit statistic difference with null hypothesis

  • “npred” : predicted number of counts per dataset

estimate_ul(datasets, parameter)#

Estimate parameter ul.

Parameters
datasetsDatasets

The datasets used to estimate the model parameter

parameterParameter

For which parameter to get the value

Returns
resultdict

Dict with the parameter ULs. Entries are:

  • parameter.name_ul : upper limit on parameter value

get_scale_model(models)#

Set scale model

Parameters
modelsModels

Models

Returns
modelScaleSpectralModel

Scale spectral model

run(datasets)[source]#

Run the flux point estimator for all energy groups.

Parameters
datasetsDatasets

Datasets

Returns
flux_pointsFluxPoints

Estimated flux points.