MultiGauss2D

class gammapy.image.models.MultiGauss2D(sigmas, norms=None)[source]

Bases: object

Sum of multiple 2D Gaussians.

Parameters:

sigmas : ndarray

widths of the Gaussians to add

norms : ndarray, optional

normalizations of the Gaussians to add

Notes

  • This sum is no longer a PDF, it is not normalized to 1.
  • The “norm” of each component represents the 2D integral, not the amplitude at the origin.

Attributes Summary

amplitude Amplitude at the center (float)
eff_sigma Effective Gaussian width for single-Gauss approximation (float)
integral Integral as sum of norms (ndarray)
max_sigma Largest Gaussian width (float)
n_components Number of components (int)
sigmas Array of Gaussian widths (ndarray)

Methods Summary

__call__(x[, y]) dp / (dx dy) at position (x, y)
containment_fraction(theta) Containment fraction.
containment_radius(containment_fraction) Containment angle for a given containment fraction.
dpdtheta2(theta2) dp / dtheta2 at position theta2 = theta ^ 2
gauss_convolve(sigma[, norm]) Convolve with another Gauss.
match_sigma(containment_fraction) Compute equivalent Gauss width.
normalize() Normalize function.

Attributes Documentation

amplitude

Amplitude at the center (float)

eff_sigma

Effective Gaussian width for single-Gauss approximation (float)

Notes

The effective Gaussian width is given by:

\[\sigma_\mathrm{eff} = \sqrt{\sum_i N_i \sigma_i^2}\]

where N is normalization and sigma is width.

integral

Integral as sum of norms (ndarray)

max_sigma

Largest Gaussian width (float)

n_components

Number of components (int)

sigmas

Array of Gaussian widths (ndarray)

Methods Documentation

__call__(x, y=0)[source]

dp / (dx dy) at position (x, y)

Parameters:

x : ndarray

x coordinate

y : ndarray, optional

y coordinate

Returns:

total : ndarray

dp / (dx dy)

containment_fraction(theta)[source]

Containment fraction.

Parameters:

theta : ndarray

Offset

Returns:

containment_fraction : ndarray

Containment fraction

containment_radius(containment_fraction)[source]

Containment angle for a given containment fraction.

Parameters:

containment_fraction : ndarray

Containment fraction

Returns:

containment_radius : ndarray

Containment radius

dpdtheta2(theta2)[source]

dp / dtheta2 at position theta2 = theta ^ 2

Parameters:

theta2 : ndarray

Offset squared

Returns:

dpdtheta2 : ndarray

dp / dtheta2

gauss_convolve(sigma, norm=1)[source]

Convolve with another Gauss.

Compute new norms and sigmas of all the components such that the new distribution represents the convolved old distribution by a Gaussian of width sigma and then multiplied by norm.

This MultiGauss2D is unchanged, a new one is created and returned. This is useful if you need to e.g. compute theta for one PSF and many sigmas.

Parameters:

sigma : ndarray or float

Gaussian width of the new Gaussian 2D PDF to covolve with.

norm : ndarray or float

Normalization of the new Gaussian 2D PDF to covolve with.

Returns:

new_multi_gauss_2d : MultiGauss2D

Convolution as new MultiGauss2D

match_sigma(containment_fraction)[source]

Compute equivalent Gauss width.

Find the sigma of a single-Gaussian distribution that approximates this one, such that theta matches for a given containment.

Parameters:

containment_fraction : ndarray

Containment fraction

Returns:

sigma : ndarray

Equivalent containment radius

normalize()[source]

Normalize function.

Returns:

norm_multigauss : MultiGauss2D

normalized function