CatalogImageEstimator¶
-
class
gammapy.image.CatalogImageEstimator(reference, emin, emax)[source]¶ Bases:
objectCompute model image for given energy band from a catalog.
Sources are only filled when their center lies within the image boundaries.
Parameters: reference :
SkyImageReference sky image.
emin :
QuantityLower bound of energy range.
emax :
QuantityUpper bound of energy range.
Examples
Here is an example how to compute a flux image from a catalog:
from astropy import units as u from gammapy.image import SkyImage, CatalogImageEstimator from gammapy.catalog import SourceCatalogGammaCat
- reference = SkyImage.empty(xref=265, yref=-1.5, nxpix=201,
- nypix=201, binsz=0.04)
- image_estimator = CatalogImageEstimator(reference=reference,
- emin=1 * u.TeV, emax=10 * u.TeV)
catalog = SourceCatalogGammaCat() result = image_estimator.run(catalog) result[‘flux’].show()
Currently the
CatalogImageEstimatorclass does not support to compute model cubes of catalogs. But this can achieved with only a little more of python code:from astropy import units as u from gammapy.image import CatalogImageEstimator, SkyImage from gammapy.cube import SkyCube from gammapy.catalog import SourceCatalogGammaCat from gammapy.utils.energy import EnergyBounds
- reference = SkyImage.empty(xref=265, yref=-1.5, nxpix=201,
- nypix=201, binsz=0.04)
energies = EnergyBounds.equal_log_spacing(1 * u.TeV, 100 * u.TeV, 3)
flux_cube = SkyCube.empty_like(reference=reference, energies=energies)
catalog = SourceCatalogGammaCat()
- for idx in range(energies.size - 1):
- image_estimator = CatalogImageEstimator(reference=reference,
- emin=energies[idx], emax=energies[idx + 1])
result = image_estimator.run(catalog) flux_cube.data[idx, :, :] = result[‘flux’].data
flux_cube.show()
Methods Summary
flux(catalog)Compute flux image from catalog. run(catalog[, which])Run catalog image estimator. Methods Documentation
-
flux(catalog)[source]¶ Compute flux image from catalog.
Sources are only filled when their center lies within the image boundaries.
Parameters: catalog :
SourceCatalogSource catalog instance.
Returns: image :
SkyImageFlux sky image.
-
run(catalog, which='flux')[source]¶ Run catalog image estimator.
Parameters: catalog :
SourceCatalogSource catalog instance.
Returns: sky_images :
SkyImageListList of sky images