|
| 1 | +""" |
| 2 | +Elliptical Gaussian light profile with m=3 and m=4 Fourier multipole perturbations |
| 3 | +applied to the eccentric radius before evaluating the Gaussian profile. |
| 4 | +
|
| 5 | +With both ``multipole_*_comps`` set to ``(0.0, 0.0)`` (the default), the profile |
| 6 | +reduces exactly to ``Gaussian``. |
| 7 | +""" |
| 8 | + |
| 9 | +from typing import Optional, Tuple |
| 10 | + |
| 11 | +import numpy as np |
| 12 | + |
| 13 | +import autoarray as aa |
| 14 | + |
| 15 | +from autogalaxy.profiles.light.decorators import check_operated_only |
| 16 | +from autogalaxy.profiles.light.standard._multipole_mixin import ( |
| 17 | + _LightProfileMultipoleMixin, |
| 18 | +) |
| 19 | +from autogalaxy.profiles.light.standard.gaussian import Gaussian |
| 20 | + |
| 21 | + |
| 22 | +class GaussianMultipole(_LightProfileMultipoleMixin, Gaussian): |
| 23 | + def __init__( |
| 24 | + self, |
| 25 | + centre: Tuple[float, float] = (0.0, 0.0), |
| 26 | + ell_comps: Tuple[float, float] = (0.0, 0.0), |
| 27 | + intensity: float = 0.1, |
| 28 | + sigma: float = 1.0, |
| 29 | + multipole_3_comps: Tuple[float, float] = (0.0, 0.0), |
| 30 | + multipole_4_comps: Tuple[float, float] = (0.0, 0.0), |
| 31 | + ): |
| 32 | + """ |
| 33 | + The elliptical Gaussian light profile with m=3 and m=4 Fourier multipole |
| 34 | + perturbations on the eccentric radius. |
| 35 | +
|
| 36 | + Parameters |
| 37 | + ---------- |
| 38 | + centre |
| 39 | + The (y,x) arc-second coordinates of the profile centre. |
| 40 | + ell_comps |
| 41 | + The first and second ellipticity components of the elliptical coordinate |
| 42 | + system. The multipole perturbation is applied to the eccentric radius and |
| 43 | + therefore follows this ellipticity. |
| 44 | + intensity |
| 45 | + Overall intensity normalisation of the light profile. |
| 46 | + sigma |
| 47 | + The sigma value of the Gaussian. |
| 48 | + multipole_3_comps |
| 49 | + The ``(cos, sin)`` components of the m=3 Fourier perturbation. Defaults to |
| 50 | + ``(0.0, 0.0)`` which reduces the profile to ``Gaussian``. |
| 51 | + multipole_4_comps |
| 52 | + The ``(cos, sin)`` components of the m=4 Fourier perturbation. Defaults to |
| 53 | + ``(0.0, 0.0)`` which reduces the profile to ``Gaussian``. |
| 54 | + """ |
| 55 | + super().__init__( |
| 56 | + centre=centre, ell_comps=ell_comps, intensity=intensity, sigma=sigma |
| 57 | + ) |
| 58 | + self.multipole_3_comps = multipole_3_comps |
| 59 | + self.multipole_4_comps = multipole_4_comps |
| 60 | + |
| 61 | + def image_2d_via_radii_from( |
| 62 | + self, grid_radii: np.ndarray, xp=np, **kwargs |
| 63 | + ) -> np.ndarray: |
| 64 | + """ |
| 65 | + Returns the 2D Gaussian image evaluated at the input radial values. |
| 66 | +
|
| 67 | + Unlike ``Gaussian.image_2d_via_radii_from``, this override accepts a raw backend |
| 68 | + array (the output of ``perturbed_radii_from``) rather than an autoarray-wrapped |
| 69 | + grid, since the perturbation step strips the wrapper. |
| 70 | + """ |
| 71 | + return xp.multiply( |
| 72 | + self._intensity, |
| 73 | + xp.exp( |
| 74 | + -0.5 |
| 75 | + * xp.square( |
| 76 | + xp.divide(grid_radii, self.sigma / xp.sqrt(self.axis_ratio(xp))) |
| 77 | + ) |
| 78 | + ), |
| 79 | + ) |
| 80 | + |
| 81 | + @aa.over_sample |
| 82 | + @aa.decorators.to_array |
| 83 | + @check_operated_only |
| 84 | + @aa.decorators.transform |
| 85 | + def image_2d_from( |
| 86 | + self, |
| 87 | + grid: aa.type.Grid2DLike, |
| 88 | + xp=np, |
| 89 | + operated_only: Optional[bool] = None, |
| 90 | + **kwargs, |
| 91 | + ) -> aa.Array2D: |
| 92 | + """ |
| 93 | + Returns the 2D image of the multipole-perturbed Gaussian profile. |
| 94 | + """ |
| 95 | + perturbed_radii = self.perturbed_radii_from(grid=grid, xp=xp, **kwargs) |
| 96 | + return self.image_2d_via_radii_from(grid_radii=perturbed_radii, xp=xp, **kwargs) |
0 commit comments