caustics.light package

Submodules

caustics.light.base module

class caustics.light.base.Source(name: str | None = None)[source]

Bases: Parametrized

This is an abstract base class used to represent a source in a strong gravitational lensing system. It provides the basic structure and required methods that any derived source class should implement. The Source class inherits from the Parametrized class, implying that it contains parameters that can be optimized or manipulated.

The class introduces one abstract method, brightness, that must be implemented in any concrete subclass. This method calculates the brightness of the source at given coordinates.

abstract brightness(x: Tensor, y: Tensor, *args, params: Packed | None = None, **kwargs) Tensor[source]

Abstract method that calculates the brightness of the source at the given coordinates. This method is expected to be implemented in any class that derives from Source.

Parameters:
  • x (Tensor) – The x-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • y (Tensor) – The y-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • params (Packed, optional) – Dynamic parameter container that might be required to calculate the brightness. The exact contents will depend on the specific implementation in derived classes.

Returns:

The brightness of the source at the given coordinate(s). The exact form of the output will depend on the specific implementation in the derived class.

Return type:

Tensor

Note

This method must be overridden in any class that inherits from Source.

caustics.light.pixelated module

class caustics.light.pixelated.Pixelated(image: Tensor | None = None, x0: Tensor | float | None = None, y0: Tensor | float | None = None, pixelscale: Tensor | float | None = None, shape: tuple[int, ...] | None = None, name: str | None = None)[source]

Bases: Source

Pixelated is a subclass of the abstract class Source. It representes the brightness profile of source with a pixelated grid of intensity values.

This class provides a concrete implementation of the brightness method required by the Source superclass. In this implementation, brightness is determined by interpolating values from the provided source image.

x0

The x-coordinate of the source image’s center.

Type:

Optional[Tensor]

y0

The y-coordinate of the source image’s center.

Type:

Optional[Tensor]

image

The source image from which brightness values will be interpolated.

Type:

Optional[Tensor]

pixelscale

The pixelscale of the source image in the lens plane in units of arcsec/pixel.

Type:

Optional[Tensor]

shape

The shape of the source image.

Type:

Optional[tuple[int, …]]

brightness(x, y, x0, y0, image, pixelscale, *args, params: Packed | None = None, **kwargs)[source]

Implements the brightness method for Pixelated. The brightness at a given point is determined by interpolating values from the source image.

Parameters:
  • x (Tensor) – The x-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • y (Tensor) – The y-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • params (Optional[Packed]) – A dictionary containing additional parameters that might be required to calculate the brightness.

Returns:

The brightness of the source at the given coordinate(s). The brightness is determined by interpolating values from the source image.

Return type:

Tensor

caustics.light.probes module

class caustics.light.probes.PROBESDataset(filepath, channels)[source]

Bases: Dataset

caustics.light.sersic module

class caustics.light.sersic.Sersic(x0: Tensor | float | None = None, y0: Tensor | float | None = None, q: Tensor | float | None = None, phi: Tensor | float | None = None, n: Tensor | float | None = None, Re: Tensor | float | None = None, Ie: Tensor | float | None = None, s: float = 0.0, use_lenstronomy_k=False, name: str | None = None)[source]

Bases: Source

Sersic is a subclass of the abstract class Source. It represents a source in a strong gravitational lensing system that follows a Sersic profile, a mathematical function that describes how the intensity I of a galaxy varies with distance r from its center.

The Sersic profile is often used to describe elliptical galaxies and spiral galaxies’ bulges.

x0

The x-coordinate of the Sersic source’s center.

Type:

Optional[Tensor]

y0

The y-coordinate of the Sersic source’s center.

Type:

Optional[Tensor]

q

The axis ratio of the Sersic source.

Type:

Optional[Tensor]

phi

The orientation of the Sersic source (position angle).

Type:

Optional[Tensor]

n

The Sersic index, which describes the degree of concentration of the source.

Type:

Optional[Tensor]

Re

The scale length of the Sersic source.

Type:

Optional[Tensor]

Ie

The intensity at the effective radius.

Type:

Optional[Tensor]

s

A small constant for numerical stability.

Type:

float

lenstronomy_k_mode

A flag indicating whether to use lenstronomy to compute the value of k.

Type:

bool

brightness(x, y, x0, y0, q, phi, n, Re, Ie, *args, params: Packed | None = None, **kwargs)[source]

Implements the brightness method for Sersic. The brightness at a given point is determined by the Sersic profile formula.

Parameters:
  • x (Tensor) – The x-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • y (Tensor) – The y-coordinate(s) at which to calculate the source brightness. This could be a single value or a tensor of values.

  • params (Packed, optional) – Dynamic parameter container.

Returns:

The brightness of the source at the given point(s). The output tensor has the same shape as x and y.

Return type:

Tensor

Notes

The Sersic profile is defined as: I(r) = Ie * exp(-k * ((r / r_e)^(1/n) - 1)), where Ie is the intensity at the effective radius r_e, n is the Sersic index that describes the concentration of the source, and k is a parameter that depends on n. In this implementation, we use elliptical coordinates ex and ey, and the transformation from Cartesian coordinates is handled by to_elliptical. The value of k can be calculated in two ways, controlled by lenstronomy_k_mode. If lenstronomy_k_mode is True, we use the approximation from Lenstronomy, otherwise, we use the approximation from Ciotti & Bertin (1999).

Module contents