TablePSF

class gammapy.irf.TablePSF(rad, psf_value, interp_kwargs=None)[source]

Bases: object

Radially-symmetric table PSF.

Parameters:
rad : Quantity with angle units

Offset wrt source position

psf_value : Quantity with sr^-1 units

PSF value array

interp_kwargs : dict

Keyword arguments passed to ScaledRegularGridInterpolator

Methods Summary

broaden(self, factor[, normalize]) Broaden PSF by scaling the offset array.
containment(self, rad_max) Compute PSF containment fraction.
containment_radius(self, fraction) Containment radius.
evaluate(self, rad) Evaluate PSF.
from_shape(shape, width, rad) Make TablePSF objects with commonly used shapes.
info(self) Print basic info.
normalize(self) Normalize PSF to unit integral.
plot_psf_vs_rad(self[, ax]) Plot PSF vs radius.

Methods Documentation

broaden(self, factor, normalize=True)[source]

Broaden PSF by scaling the offset array.

For a broadening factor \(f\) and the offset array \(r\), the offset array scaled in the following way:

\[r_{new} = f \times r_{old} \frac{dP}{dr}(r_{new}) = \frac{dP}{dr}(r_{old})\]
Parameters:
factor : float

Broadening factor

normalize : bool

Normalize PSF after broadening

containment(self, rad_max)[source]

Compute PSF containment fraction.

Parameters:
rad_max : Quantity

Offset angle range

Returns:
integral : float

PSF integral

containment_radius(self, fraction)[source]

Containment radius.

Parameters:
fraction : array_like

Containment fraction (range 0 .. 1)

Returns:
rad : Angle

Containment radius angle

evaluate(self, rad)[source]

Evaluate PSF.

The following PSF quantities are available:

  • ‘dp_domega’: PDF per 2-dim solid angle \(\Omega\) in sr^-1

    \[\frac{dP}{d\Omega}\]
Parameters:
rad : Angle

Offset wrt source position

Returns:
psf_value : Quantity

PSF value

classmethod from_shape(shape, width, rad)[source]

Make TablePSF objects with commonly used shapes.

This function is mostly useful for examples and testing.

Parameters:
shape : {‘disk’, ‘gauss’}

PSF shape.

width : Quantity with angle units

PSF width angle (radius for disk, sigma for Gauss).

rad : Quantity with angle units

Offset angle

Returns:
psf : TablePSF

Table PSF

Examples

>>> import numpy as np
>>> from astropy.coordinates import Angle
>>> from gammapy.irf import TablePSF
>>> rad = Angle(np.linspace(0, 0.7, 100), 'deg')
>>> psf = TablePSF.from_shape(shape='gauss', width='0.2 deg', rad=rad)
info(self)[source]

Print basic info.

normalize(self)[source]

Normalize PSF to unit integral.

Computes the total PSF integral via the \(dP / dr\) spline and then divides the \(dP / dr\) array.

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

Plot PSF vs radius.

Parameters:
ax : ``
kwargs : dict

Keyword arguments passed to matplotlib.pyplot.plot