caustics.sims package

Submodules

caustics.sims.lens_source module

class caustics.sims.lens_source.Lens_Source(lens, source, pixelscale: float, pixels_x: int, lens_light=None, psf=None, pixels_y: int | None = None, upsample_factor: int = 1, psf_pad=True, psf_mode='fft', z_s=None, name: str = 'sim')[source]

Bases: Simulator

Lens image of a source.

Striaghtforward simulator to sample a lensed image of a source object. Constructs a sampling grid internally based on the pixelscale and gridding parameters. It can automatically upscale and fine sample an image. This is the most straightforward simulator to view the image if you aready have a lens and source chosen.

Example usage:

import matplotlib.pyplot as plt
import caustics

cosmo = caustics.FlatLambdaCDM()
lens = caustics.lenses.SIS(cosmology = cosmo, x0 = 0., y0 = 0., th_ein = 1.)
source = caustics.sources.Sersic(x0 = 0., y0 = 0., q = 0.5, phi = 0.4, n = 2., Re = 1., Ie = 1.)
sim = caustics.sims.Lens_Source(lens, source, pixelscale = 0.05, gridx = 100, gridy = 100, upsample_factor = 2, z_s = 1.)

img = sim()
plt.imshow(img, origin = "lower")
plt.show()
lens

caustics lens mass model object

source

caustics light object which defines the background source

pixelscale

pixelscale of the sampling grid.

pixels_x

number of pixels on the x-axis for the sampling grid

lens_light

caustics light object which defines the lensing object’s light

Type:

optional

psf

An image to convolve with the scene. Note that if upsample_factor > 1 the psf must also be at the higher resolution.

Type:

optional

pixels_y

number of pixels on the y-axis for the sampling grid. If left as None then this will simply be equal to gridx

Type:

optional

upsample_factor

Amount of upsampling to model the image. For example upsample_factor = 2 indicates that the image will be sampled at double the resolution then summed back to the original resolution (given by pixelscale and gridx/y).

Type:

default 1

psf_pad

If convolving the PSF it is important to sample the model in a larger FOV equal to half the PSF size in order to account for light that scatters from outside the requested FOV inwards. Internally this padding will be added before sampling, then cropped off before returning the final image to the user.

Type:

default True

z_s

redshift of the source

Type:

optional

name

a name for this simulator in the parameter DAG.

Type:

default “sim”

forward(params, source_light=True, lens_light=True, lens_source=True, psf_convolve=True)[source]

params: Packed object source_light: when true the source light will be sampled lens_light: when true the lens light will be sampled lens_source: when true, the source light model will be lensed by the lens mass distribution psf_convolve: when true the image will be convolved with the psf

caustics.sims.simulator module

class caustics.sims.simulator.Simulator(name: str | None = None)[source]

Bases: Parametrized

A caustic simulator using Parametrized framework.

Defines a simulator class which is a callable function that operates on the Parametrized framework. Users define the forward method which takes as its first argument an object which can be packed, all other args and kwargs are simply passed to the forward method.

See Parametrized for details on how to add/access parameters.

Module contents