FluxPointsEstimator#
- class gammapy.estimators.FluxPointsEstimator(energy_edges=<Quantity [ 1., 10.] TeV>, sum_over_energy_groups=False, n_jobs=None, parallel_backend=None, **kwargs)[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_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, 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.
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 None: apply the estimator in each energy bin of the parent dataset. For further explanation see Estimators (DL4 to DL5, and DL6).
- fit
Fit
Fit instance specifying the backend and fit options.
- reoptimizebool
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 if fitted, and all other parameters are frozen at their current values.
- sum_over_energy_groupsbool
Whether to sum over the energy groups or fit the norm on the full energy grid.
- n_jobsint
Number of processes used in parallel for the computation. Default is one, unless
N_JOBS_DEFAULT
was modified. The number of jobs is limited to the number of physical CPUs.- parallel_backend{“multiprocessing”, “ray”}
Which backend to use for multiprocessing.
- norm
Parameter
or dict 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 and derived from the source model, unless the source model does not have one and only one norm parameter. If a dict is given the entries should be a subset of
Parameter
arguments.
Attributes Summary
Configuration parameters.
Number of jobs as an integer.
Parallel backend as a string.
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 statistic 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#
Configuration parameters.
- n_jobs#
Number of jobs as an integer.
- parallel_backend#
Parallel backend as a string.
- selection_optional#
- tag = 'FluxPointsEstimator'#
Methods Documentation
- copy()#
Copy estimator.
- estimate_best_fit(datasets, parameter)#
Estimate parameter asymmetric errors.
- Parameters:
- datasets
Datasets
Datasets.
- parameter
Parameter
For which parameter to get the value.
- datasets
- Returns:
- resultdict
Dictionary 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
Dictionary 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:
- datasets
Datasets
Datasets.
- parameter
Parameter
For which parameter to get the value.
- datasets
- Returns:
- resultdict
Dictionary 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.
- static estimate_npred(datasets)#
Estimate npred for the flux point.
- Parameters:
- datasets
Datasets
Datasets.
- datasets
- Returns:
- resultdict
Dictionary 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
Dictionary with an array with one entry per dataset with the sum of the masked npred excess.
- estimate_scan(datasets, parameter)#
Estimate parameter statistic scan.
- estimate_ts(datasets, parameter)#
Estimate parameter ts.
- Parameters:
- datasets
Datasets
Datasets.
- parameter
Parameter
For which parameter to get the value.
- datasets
- Returns:
- resultdict
Dictionary with the test statistic 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.
“stat_null” : total stat corresponding to the null hypothesis
- estimate_ul(datasets, parameter)#
Estimate parameter ul.
- get_scale_model(models)#
Set scale model.
- Parameters:
- models
Models
Models.
- models
- Returns:
- model
ScaleSpectralModel
Scale spectral model.
- model
- run(datasets)[source]#
Run the flux point estimator for all energy groups.
- Parameters:
- datasets
Datasets
Datasets.
- datasets
- Returns:
- flux_points
FluxPoints
Estimated flux points.
- flux_points