autolens.SimulatorImaging#
- class SimulatorImaging[source]#
Bases:
SimulatorImagingSimulates observations of Imaging data, including simulating the image, noise, blurring due to the telescope optics via the Point Spread Function (PSF) and the background sky.
The simulation of an Imaging dataset uses the following steps:
Receive as input a raw image of what the data looks like before any simulation process is applied.
Include diffraction due to the telescope optics by convolving the image with an input Point Spread Function (PSF).
Use input values of the background sky level in every pixel of the image to add the background sky to the PSF convolved image.
Add Poisson noise to the image, which represents noise due to whether photons hits the CCD and are converted to photo-electrons which are successfully detected by the CCD and converted to counts.
Subtract the background sky from the image, so that the returned simulated dataset is background sky subtracted.
The inputs of the SimulatorImaging object can toggle these steps on and off, for example if psf=None the PSF convolution step is omitted.
The inputs add_poisson_noise_to_data and include_poisson_noise_in_noise_map provide flexibility in handling Poisson noise during simulations:
add_poisson_noise_to_data determines whether Poisson noise is added to the simulated data.
include_poisson_noise_in_noise_map decides if Poisson noise is included in the noise_map of the dataset.
These options allow you to create a dataset without adding Poisson noise to the data while still using a noise_map that represents the noise levels expected if Poisson noise had been included.
This approach is particularly useful for diagnostic purposes. By simulating noise-free data but retaining realistic noise levels in the noise_map, you can test whether the model-fitting process accurately recovers the input parameters. Unlike noisy data, where random Poisson noise introduces offsets in each simulation, this method ensures the posterior peaks precisely around the input values. This is a powerful way to identify potential systematic biases in a model-fitting analysis.
- Parameters:
exposure_time (
float) – The exposure time of the simulated imaging.background_sky_level (
float) – The level of the background sky of the simulated imaging.subtract_background_sky (
bool) – If True, the background sky level is subtracted from the simulated dataset, otherwise it is left in.psf (
Convolver) – An array describing the PSF kernel of the image, if None no PSF convolution is applied.use_real_space_convolution (
bool) – If True, the PSF convolution is performed in real space, if False it is performed in Fourier space. Real space convolution avoids aliasing effects that can occur in Fourier space convolution, but is slower. If the PSF kernel is small (e.g. 11x11) then real space convolution is recommended, whereas if the PSF kernel is large (e.g. 51x51) then Fourier space convolution with care to pad the image to avoid aliasing is recommended.normalize_psf (
bool) – If True, the PSF kernel is normalized so all values sum to 1.0.add_poisson_noise_to_data (
bool) – Whether Poisson noise corresponding to photon count statistics on the imaging observation is added.include_poisson_noise_in_noise_map (
bool) – Whether Poisson noise is included in the noise-map of the dataset. If False the noise-map is filled with the value noise_if_add_noise_false.noise_if_add_noise_false (
float) – If noise is not added to the simulated dataset a noise_map must still be returned. This value gives the value of noise assigned to every pixel in the noise-map.noise_seed (
int) – The random seed used to add random noise, where -1 corresponds to a random seed every run.use_jax (
bool) – IfTrue,via_image_fromdefaultsxptojax.numpyand the simulator’s internal noise generation routes throughjax.random. The returnedImagingcarriesjax.Arraydata — useful for JAX-eager batched simulation (parameter sweeps, mock-data studies). Defaults toFalse.
Methods
Simulate an Imaging dataset from an input deflection angle map and list of galaxies.
Simulate an Imaging dataset from an input list of Galaxy objects and a 2D grid of (y,x) coordinates.
via_image_fromSimulate an Imaging dataset from an input image.
Simulate an Imaging dataset from an input image of a source galaxy.
Simulate an Imaging dataset from an input Tracer object and a 2D grid of (y,x) coordinates.
- via_tracer_from(tracer, grid, xp=None)[source]#
Simulate an Imaging dataset from an input Tracer object and a 2D grid of (y,x) coordinates.
The mass profiles of each galaxy in the tracer are used to perform ray-tracing of the input 2D grid and their light profiles are used to generate the image of the galaxies which are simulated.
The steps of the SimulatorImaging simulation process (e.g. PSF convolution, noise addition) are described in the SimulatorImaging __init__ method docstring, found in the PyAutoArray project.
If one of more galaxy light profiles are a LightProfileSNR object, the intensity of the light profile is automatically set such that the signal-to-noise ratio of the light profile is equal to its input signal_to_noise_ratio value.
For example, if a LightProfileSNR object has a signal_to_noise_ratio of 5.0, the intensity of the light profile is set such that the peak surface brightness of the profile is 5.0 times the background noise level of the image.
- Parameters:
tracer (
Tracer) – The tracer, which describes the ray-tracing and strong lens configuration used to simulate the imaging dataset as well as the light profiles of the galaxies used to simulate the image of the galaxies.grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D grid of (y,x) coordinates which the mass profiles of the galaxies in the tracer are ray-traced using in order to generate the image of the galaxies via their light profiles.
- via_galaxies_from(galaxies, grid)[source]#
Simulate an Imaging dataset from an input list of Galaxy objects and a 2D grid of (y,x) coordinates.
The galaxies are used to create a Tracer. The mass profiles of each galaxy in the tracer are used to perform ray-tracing of the input 2D grid and their light profiles are used to generate the image of the galaxies which are simulated.
The steps of the SimulatorImaging simulation process (e.g. PSF convolution, noise addition) are described in the SimulatorImaging __init__ method docstring.
If one of more galaxy light profiles are a LightProfileSNR object, the intensity of the light profile is automatically set such that the signal-to-noise ratio of the light profile is equal to its input signal_to_noise_ratio value.
For example, if a LightProfileSNR object has a signal_to_noise_ratio of 5.0, the intensity of the light profile is set such that the peak surface brightness of the profile is 5.0 times the background noise level of the image.
- Parameters:
galaxies (
List[Galaxy]) – The galaxies used to create the tracer, which describes the ray-tracing and strong lens configuration used to simulate the imaging dataset.grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The image-plane 2D grid of (y,x) coordinates grid which the image of the strong lens is generated on.
- via_deflections_and_galaxies_from(deflections, galaxies)[source]#
Simulate an Imaging dataset from an input deflection angle map and list of galaxies.
The input deflection angle map ray-traces the image-plane coordinates from the image-plane to source-plane, via the lens equation.
This traced grid is then used to evaluate the light of the list of galaxies, which therefore simulate the image of the strong lens.
This function is used in situations where one has access to a deflection angle map which does not suit being ray-traced using a Tracer object (e.g. deflection angles from a cosmological simulation of a galaxy).
The steps of the SimulatorImaging simulation process (e.g. PSF convolution, noise addition) are described in the SimulatorImaging __init__ method docstring.
- via_source_image_from(tracer, grid, source_image)[source]#
Simulate an Imaging dataset from an input image of a source galaxy.
This input image is on a uniform and regular 2D array, meaning it can simulate the source’s irregular and asymmetric source galaxy morphological features.
The typical use case is inputting the image of an irregular galaxy in the source-plane (whose values are on a uniform array) and using this function to compute the lensed image of this source galaxy.
The tracer is used to perform ray-tracing and generate the image of the strong lens galaxies (e.g. the lens light, lensed source light, etc) which is simulated.
The source galaxy light profiles are ignored in favour of the input source image, but the emission of other galaxies (e.g. the lems galaxy’s light) are included.
The steps of the SimulatorImaging simulation process (e.g. PSF convolution, noise addition) are described in the SimulatorImaging __init__ method docstring.
- Parameters:
tracer (
Tracer) – The tracer, which describes the ray-tracing and strong lens configuration used to simulate the imaging dataset.grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The image-plane 2D grid of (y,x) coordinates grid which the image of the strong lens is generated on.source_image (
Array2D) – The image of the source-plane and source galaxy which is interpolated to compute the lensed image.