FluxProfileEstimator#
- class gammapy.estimators.FluxProfileEstimator(regions, spectrum=None, **kwargs)[source]#
Bases:
gammapy.estimators.points.sed.FluxPointsEstimator
Estimate flux profiles
- Parameters
- regionslist of
SkyRegion
regions to use
- spectrum
SpectralModel
(optional) Spectral model to compute the fluxes or brightness. Default is power-law with spectral index of 2.
- **kwargsdict
Keywords forwarded to the
FluxPointsEstimator
(see documentation there for further description of valid keywords)
- regionslist of
Examples
This example shows how to compute a counts profile for the Fermi galactic center region:
>>> from astropy import units as u >>> from astropy.coordinates import SkyCoord >>> from gammapy.data import GTI >>> from gammapy.estimators import FluxProfileEstimator >>> from gammapy.utils.regions import make_orthogonal_rectangle_sky_regions >>> from gammapy.datasets import MapDataset >>> from gammapy.maps import RegionGeom
>>> # load example data >>> dataset = MapDataset.read("$GAMMAPY_DATA/fermi-3fhl-gc/fermi-3fhl-gc.fits.gz", name="fermi_dataset")
>>> # configuration >>> dataset.gti = GTI.create("0s", "1e7s", "2010-01-01")
>>> # creation of the boxes and axis >>> start_pos = SkyCoord("-1d", "0d", frame='galactic') >>> end_pos = SkyCoord("1d", "0d", frame='galactic')
>>> regions = make_orthogonal_rectangle_sky_regions(start_pos=start_pos, end_pos=end_pos, wcs=dataset.counts.geom.wcs, height=2.*u.deg, nbin=21)
>>> # set up profile estimator and run >>> prof_maker = FluxProfileEstimator(regions=regions, energy_edges=[10, 2000] * u.GeV) >>> fermi_prof = prof_maker.run(dataset) >>> print(fermi_prof) FluxPoints ---------- geom : RegionGeom axes : ['lon', 'lat', 'energy', 'projected-distance'] shape : (1, 1, 1, 21) quantities : ['norm', 'norm_err', 'ts', 'npred', 'npred_excess', 'stat', 'counts', 'success'] ref. model : pl n_sigma : 1 n_sigma_ul : 2 sqrt_ts_threshold_ul : 2 sed type init : likelihood
Attributes Summary
Config parameters
Get projected distance from the first region.
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 flux profile estimation
Attributes Documentation
- config_parameters#
Config parameters
- projected_distance_axis#
Get projected distance from the first region.
For normal region this is defined as the distance from the center of the region. For annulus shaped regions it is the mean between the inner and outer radius.
- Returns
- axis
MapAxis
Projected distance axis
- axis
- selection_optional#
- tag = 'FluxProfileEstimator'#
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
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
- datasets
Datasets
Datasets
- parameter
Parameter
For which parameter to get the value
- datasets
- 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)#
Estimate flux point for a single energy group.
- Parameters
- datasets
Datasets
Datasets
- energy_min, energy_max
Quantity
Energy bounds to compute the flux point for.
- datasets
- 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
- datasets
Datasets
The datasets used to estimate the model parameter
- parameter
Parameter
For which parameter to get the value
- datasets
- 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
- datasets
Datasets
Datasets
- parameter
Parameter
For which parameter to get the value
- datasets
- 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
- datasets
Datasets
The datasets used to estimate the model parameter
- parameter
Parameter
For which parameter to get the value
- datasets
- 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
- models
Models
Models
- models
- Returns
- model
ScaleSpectralModel
Scale spectral model
- model
- run(datasets)[source]#
Run flux profile estimation
- Parameters
- datasetslist of
MapDataset
Map datasets.
- datasetslist of
- Returns
- profile
FluxPoints
Profile flux points.
- profile