SingleObsImageMaker

class gammapy.scripts.SingleObsImageMaker(obs, empty_image, energy_band, offset_band, exclusion_mask=None, ncounts_min=0, save_bkg_scale=True)[source]

Bases: object

Compute images for one observation.

The computed images are stored in a images attribute of type SkyImageList with the following keys:

  • counts : Counts
  • bkg : Background model
  • exposure : Exposure
  • excess : Excess
  • significance : Significance
Parameters:

obs : DataStoreObservation

Observation data

empty_image : SkyImage

Reference image

energy_band : Energy

Energy band selection

offset_band : astropy.coordinates.Angle

Offset band selection

exclusion_mask : SkyImage

Exclusion mask

ncounts_min : int

Minimum counts required for the observation (TODO: used how?)

save_bkg_scale: bool

True if you want to save the normalisation of the bkg computed outside the exlusion region in a Table

Methods Summary

background_norm_factor(counts, bkg) Determine the scaling factor to apply to the background image.
bkg_image([bkg_norm]) Make the background image for one observation from a bkg model.
counts_image() Fill the counts image for the events of one observation.
excess_image() Compute excess between counts and bkg image.
exposure_image([spectral_index, …]) Compute the exposure image for one observation.
make_1d_expected_counts([spectral_index, …]) Compute the 1D exposure table for one observation for an offset table.
significance_image(radius) Make the significance image from the counts and bkg images.

Methods Documentation

background_norm_factor(counts, bkg)[source]

Determine the scaling factor to apply to the background image.

Compares the events in the counts images and the bkg image outside the exclusion images.

Parameters:

counts : SkyImage

counts image

bkg : SkyImage

bkg image

Returns:

scale : float

scaling factor between the counts and the bkg images outside the exclusion region.

bkg_image(bkg_norm=True)[source]

Make the background image for one observation from a bkg model.

Parameters:

bkg_norm : bool

If true, apply the scaling factor from the number of counts outside the exclusion region to the bkg image

counts_image()[source]

Fill the counts image for the events of one observation.

excess_image()[source]

Compute excess between counts and bkg image.

exposure_image(spectral_index=2.3, for_integral_flux=False)[source]

Compute the exposure image for one observation.

Excess/exposure will give the differential flux at the energy Eref at the middle of the self.energy_band

If for_integral_flux is true, it will give the integrated flux over the self.energy_band

Exposure is define as follow:

\[EXPOSURE = \int_{E_1}^{E_2} A(E) \phi(E) * T \, dE\]

with T the observation livetime, A(E) the effective area, the energy integration range \([E_1,E_2]\) given by self.energy_range and assuming a power law for the flux \(\phi(E) = \phi_{Eref} \times \frac{E}{E_{ref}}^{\gamma}\) with \(\gamma\) the spectral index of the assumed power law.

If for_integral_flux is true, \(EXPOSURE = \int_{E_1}^{E_2} A(E) \phi_{E} * T \, dE / \int \phi_{E} \, dE\)

Parameters:

spectral_index : float

Assumed power-law spectral index

for_integral_flux : bool

True if you want that the total excess / exposure gives the integrated flux

make_1d_expected_counts(spectral_index=2.3, for_integral_flux=False, eref=None)[source]

Compute the 1D exposure table for one observation for an offset table.

Parameters:

spectral_index : float

Assumed power-law spectral index

for_integral_flux : bool

True if you want that the total excess / exposure gives the integrated flux

eref: `~gammapy.utils.energy.Energy`

Reference energy at which you want to compute the exposure. Default is the log center of the energy band of

the image.

Returns

——-

table : astropy.table.Table

Two columns: offset in the FOV “theta” and expected counts “npred”

significance_image(radius)[source]

Make the significance image from the counts and bkg images.

Parameters:

radius : float

Disk radius in pixels.