EnergyDependentTablePSF

class gammapy.irf.EnergyDependentTablePSF(energy, rad, exposure=None, psf_value=None, interp_kwargs=None)[source]

Bases: object

Energy-dependent radially-symmetric table PSF (gtpsf format).

TODO: add references and explanations.

Parameters
energyQuantity

Energy (1-dim)

radQuantity with angle units

Offset angle wrt source position (1-dim)

exposureQuantity

Exposure (1-dim)

psf_valueQuantity

PSF (2-dim with axes: psf[energy_index, offset_index]

interp_kwargsdict

Interpolation keyword arguments pass to ScaledRegularGridInterpolator.

Methods Summary

containment(self, energy, rad_max)

Compute containment of the PSF.

containment_radius(self, energy[, fraction])

Containment radius.

evaluate(self[, energy, rad, method])

Evaluate the PSF at a given energy and offset

from_fits(hdu_list)

Create EnergyDependentTablePSF from gtpsf format HDU list.

info(self)

Print basic info

plot_containment_vs_energy(self[, ax, fractions])

Plot containment versus energy.

plot_exposure_vs_energy(self)

Plot exposure versus energy.

plot_psf_vs_rad(self[, energies, ax])

Plot PSF vs radius.

read(filename)

Create EnergyDependentTablePSF from gtpsf-format FITS file.

stack(self, psf)

Stack two EnergyDependentTablePSF objects.s

table_psf_at_energy(self, energy[, method])

Create TablePSF at one given energy.

table_psf_in_energy_band(self, energy_band)

Average PSF in a given energy band.

to_fits(self)

Convert to FITS HDU list format.

write(self, \*args, \*\*kwargs)

Write to FITS file.

Methods Documentation

containment(self, energy, rad_max)[source]

Compute containment of the PSF.

Parameters
energyQuantity

Energy

rad_maxAngle

Maximum offset angle.

Returns
fractionarray_like

Containment fraction (in range 0 .. 1)

containment_radius(self, energy, fraction=0.68)[source]

Containment radius.

Parameters
energyQuantity

Energy

fractionfloat

Containment fraction.

Returns
radQuantity

Containment radius in deg

evaluate(self, energy=None, rad=None, method='linear')[source]

Evaluate the PSF at a given energy and offset

Parameters
energyQuantity

Energy value

radAngle

Offset wrt source position

method{“linear”, “nearest”}

Linear or nearest neighbour interpolation.

Returns
valuesQuantity

Interpolated value

classmethod from_fits(hdu_list)[source]

Create EnergyDependentTablePSF from gtpsf format HDU list.

Parameters
hdu_listHDUList

HDU list with THETA and PSF extensions.

info(self)[source]

Print basic info

plot_containment_vs_energy(self, ax=None, fractions=[0.68, 0.8, 0.95], **kwargs)[source]

Plot containment versus energy.

plot_exposure_vs_energy(self)[source]

Plot exposure versus energy.

plot_psf_vs_rad(self, energies=None, ax=None, **kwargs)[source]

Plot PSF vs radius.

Parameters
energyQuantity

Energies where to plot the PSF.

**kwargsdict

Keyword arguments pass to plot.

classmethod read(filename)[source]

Create EnergyDependentTablePSF from gtpsf-format FITS file.

Parameters
filenamestr

File name

stack(self, psf)[source]

Stack two EnergyDependentTablePSF objects.s

Parameters
psfEnergyDependentTablePSF

PSF to stack.

Returns
stacked_psfEnergyDependentTablePSF

Stacked PSF.

table_psf_at_energy(self, energy, method='linear', **kwargs)[source]

Create TablePSF at one given energy.

Parameters
energyQuantity

Energy

method{“linear”, “nearest”}

Linear or nearest neighbour interpolation.

Returns
psfTablePSF

Table PSF

table_psf_in_energy_band(self, energy_band, spectrum=None, n_bins=11, **kwargs)[source]

Average PSF in a given energy band.

Expected counts in sub energy bands given the given exposure and spectrum are used as weights.

Parameters
energy_bandQuantity

Energy band

spectrumSpectralModel

Spectral model used for weighting the PSF. Default is a power law with index=2.

n_binsint

Number of energy points in the energy band, used to compute the weigthed PSF.

Returns
psfTablePSF

Table PSF

to_fits(self)[source]

Convert to FITS HDU list format.

Returns
hdu_listHDUList

PSF in HDU list format.

write(self, *args, **kwargs)[source]

Write to FITS file.

Calls writeto, forwarding all arguments.