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:
energy : Quantity

Energy (1-dim)

rad : Quantity with angle units

Offset angle wrt source position (1-dim)

exposure : Quantity

Exposure (1-dim)

psf_value : Quantity

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

interp_kwargs : dict

Interpolation keyword arguments pass to ScaledRegularGridInterpolator.

Methods Summary

containment(energy, rad_max) Compute containment of the PSF.
containment_radius(energy[, fraction]) Containment radius.
evaluate([energy, rad, method]) Evaluate the PSF at a given energy and offset
from_fits(hdu_list) Create EnergyDependentTablePSF from gtpsf format HDU list.
info() Print basic info
plot_containment_vs_energy([ax, fractions]) Plot containment versus energy.
plot_exposure_vs_energy() Plot exposure versus energy.
plot_psf_vs_rad([energies, ax]) Plot PSF vs radius.
read(filename) Create EnergyDependentTablePSF from gtpsf-format FITS file.
stack(psf) Stack two EnergyDependentTablePSF objects.s
table_psf_at_energy(energy[, method]) Create TablePSF at one given energy.
table_psf_in_energy_band(energy_band[, …]) Average PSF in a given energy band.
to_fits() Convert to FITS HDU list format.
write(*args, **kwargs) Write to FITS file.

Methods Documentation

containment(energy, rad_max)[source]

Compute containment of the PSF.

Parameters:
energy : Quantity

Energy

rad_max : Angle

Maximum offset angle.

Returns:
fraction : array_like

Containment fraction (in range 0 .. 1)

containment_radius(energy, fraction=0.68)[source]

Containment radius.

Parameters:
energy : Quantity

Energy

fraction : float

Containment fraction.

Returns:
rad : Quantity

Containment radius in deg

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

Evaluate the PSF at a given energy and offset

Parameters:
energy : Quantity

Energy value

rad : Angle

Offset wrt source position

method : {“linear”, “nearest”}

Linear or nearest neighbour interpolation.

Returns:
values : Quantity

Interpolated value

classmethod from_fits(hdu_list)[source]

Create EnergyDependentTablePSF from gtpsf format HDU list.

Parameters:
hdu_list : HDUList

HDU list with THETA and PSF extensions.

info()[source]

Print basic info

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

Plot containment versus energy.

plot_exposure_vs_energy()[source]

Plot exposure versus energy.

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

Plot PSF vs radius.

Parameters:
energy : Quantity

Energies where to plot the PSF.

**kwargs : dict

Keyword arguments pass to plot.

classmethod read(filename)[source]

Create EnergyDependentTablePSF from gtpsf-format FITS file.

Parameters:
filename : str

File name

stack(psf)[source]

Stack two EnergyDependentTablePSF objects.s

Parameters:
psf : EnergyDependentTablePSF

PSF to stack.

Returns:
stacked_psf : EnergyDependentTablePSF

Stacked PSF.

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

Create TablePSF at one given energy.

Parameters:
energy : Quantity

Energy

method : {“linear”, “nearest”}

Linear or nearest neighbour interpolation.

Returns:
psf : TablePSF

Table PSF

table_psf_in_energy_band(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_band : Quantity

Energy band

spectrum : SpectralModel

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

n_bins : int

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

Returns:
psf : TablePSF

Table PSF

to_fits()[source]

Convert to FITS HDU list format.

Returns:
hdu_list : HDUList

PSF in HDU list format.

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

Write to FITS file.

Calls writeto, forwarding all arguments.