FluxCollectionEstimator#
- class gammapy.estimators.FluxCollectionEstimator[source]#
Bases:
objectEstimate the flux points from a collection of sources simultaneously.
This estimator computes spectral flux points for a collection of sources over a set of predefined energy bins. The normalisations of all
SkyModelobjects listed inmodelsare fitted jointly in each energy bin, while all otherSkyModelcomponents in the datasets remain frozen. Re-optimization of each dataset’s background model is optional.The operation can be performed either with the standard likelihood optimizer (
Fit) or with a sampler (Sampler), which can be used to derive asymmetric errors and upper limits.By default, this requires the ultranest package to be installed.
- Parameters:
- energy_edges
Quantity Energy edges of the flux point bins.
- models
Modelsor list Source models for which the flux points are computed (others are frozen).
- 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.
- norm
Parameter, optional Norm parameter used for the fit. Default is None and a new parameter is created with value=1, name=”norm”. If the
solveris a sampler the default prior is uniform between [-10, 10].- solver
FitorSampler, optional Fit or Sampler instance specifying the backend and options. Default is an “ultranest” Sampler with options min_num_live_points=300, frac_remain=0.3.
- reoptimizebool, optional
Whether to reoptimize each dataset.background_model. Default is False. Only SkyModel given in
modelswill be fitted the others remain frozen, regardless of this option.- selection_optionallist of str, optional
Which additional quantities to estimate. Available options are:
“errn-errp”: estimate asymmetric errors on flux.
Fit solver computes upper limits if sqrt(TS) < n_sigma_ul. Sampler solver always compute errn-errp and ul.
- energy_edges
Examples
>>> from astropy.coordinates import SkyCoord >>> import astropy.units as u >>> from gammapy.datasets import MapDataset >>> from gammapy.estimators import FluxCollectionEstimator >>> from gammapy.modeling.models import FoVBackgroundModel, SkyModel >>> dataset = MapDataset.read( ... "$GAMMAPY_DATA/cta-1dc-gc/cta-1dc-gc.fits.gz", name="dataset-cta" ... ) >>> model = SkyModel.create("pl", "point", name="gc") >>> model.spatial_model.position = SkyCoord("0d", "0d", frame="galactic") >>> model_bkg = FoVBackgroundModel(dataset_name=dataset.name) >>> dataset.models = [model, model_bkg] >>> model_fce = dataset.models["gc"] >>> fce = FluxCollectionEstimator( ... energy_edges=[1.0, 3.0, 10.0] * u.TeV, ... models=[model_fce], ... ) >>> results = fce.run(dataset)
For a usage example see here.
Attributes Summary
Methods Summary
run(datasets)Compute flux point in each energy band.
Attributes Documentation
- tag = 'FluxCollectionEstimator'#
Methods Documentation
- run(datasets)[source]#
Compute flux point in each energy band.
- Parameters:
- datasets
Datasets Datasets used to compute the flux points. They must share the same geometry.
- datasets
- Returns:
- resultdict
Dictionary with results
- __init__(energy_edges, models, n_sigma=1, n_sigma_ul=2, norm=None, solver=None, reoptimize=False, selection_optional=None)[source]#
- classmethod __new__(*args, **kwargs)#