slsim.ImageSimulation package¶
Submodules¶
slsim.ImageSimulation.image_quality_lenstronomy module¶
- slsim.ImageSimulation.image_quality_lenstronomy.kwargs_single_band(band, observatory='LSST', **kwargs)[source]¶
This is the function for returning the band information.
- Parameters:
band (str) – ‘u’, ‘g’, ‘r’, ‘i’, ‘z’ or ‘y’ supported. Determines imaging bands.
observatory (str) – observatory chosen
kwargs (dict) – additional keyword arguments for the bands
- Returns:
configuration of imaging data
- Return type:
dict
slsim.ImageSimulation.image_simulation module¶
- slsim.ImageSimulation.image_simulation.centered_coordinate_system(num_pix, transform_pix2angle)[source]¶
Returns dictionary for Coordinate Grid such that (0,0) is centered with given input orientation coordinate transformation matrix.
- Parameters:
num_pix (int) – number of pixels
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
- Returns:
dict with ra_at_xy_0, dec_at_xy_0, transfrom_pix2angle
- slsim.ImageSimulation.image_simulation.deflector_images_with_different_zeropoint(lens_class, band, mag_zero_point, delta_pix, num_pix)[source]¶
Creates deflector images with different magnitude zero point. This function is useful when one wants to simulate variable lens images. For this, we need to simulate delctor images for different exposure (where we want to inject lenses) and those exposure could have different magnitude zero point.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – list of magnitude zero point in band for sequence of exposure
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
- Returns:
list of deflector images with different zero point
- slsim.ImageSimulation.image_simulation.image_data_class(lens_class, band, mag_zero_point, delta_pix, num_pix, transform_pix2angle)[source]¶
Provides data class for image.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
- Returns:
image data class
- slsim.ImageSimulation.image_simulation.image_plus_poisson_noise(image, exposure_time, gain=1, coadd_zero_point=27, single_visit_zero_point=27)[source]¶
Creates an image with possion noise.
- Parameters:
image – an image
exposure_time – exposure time or exposure map for an image
band – imaging band
gain – Amplifier gain (default 1).
coadd_zero_point – Zero point of the coadded image (default 27).
single_visit_zero_point – Zero point of the single-visit image (default 27 for g-band).
- Returns:
image with possion noise. The function returns ADU/sec in all cases, regardless of whether gain = 1 or not. The noise is applied in the electron domain, but the final image is converted back to ADU/sec.
- slsim.ImageSimulation.image_simulation.image_plus_poisson_noise_for_list_of_image(images, exposure_times)[source]¶
Creates an image with possion noise.
- Parameters:
images – list of images
exposure_time – list of exposure times or exposure maps
- Returns:
list of images with possion noise
- slsim.ImageSimulation.image_simulation.lens_image(lens_class, band, mag_zero_point, num_pix, psf_kernel, transform_pix2angle, exposure_time=None, t_obs=None, std_gaussian_noise=None, with_source=True, with_deflector=True, gain=0.7, single_visit_mag_zero_points={'g': 32.33, 'i': 31.85, 'r': 32.17, 'y': 30.63, 'z': 31.45})[source]¶
Creates lens image on the basis of given information. It can simulate both static lens image and variable lens image.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point for the exposure
num_pix – number of pixels per axis
psf_kernels – psf kernel for the exposures being.
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
exposure_time – exposure time for for the exposure. It could be single exposure time or a exposure map.
t_obs – an observation time [day]. This is applicable only for variable source. In case of point source, if we do not provide t_obs, considers no variability in the lens.
std_gaussian_noise – standard deviation for a gaussian noise
with_source – If True, simulates image with extended source in lens configuration.
with_deflector – If True, simulates image with deflector.
gain – Amplifier gain (default 0.7 for LSST).
single_visit_mag_zero_points – Zero points of the single-visit image in different bands. It is a dictionary of the form: { ‘g’: 32.33, ‘r’: 32.17, ‘i’: 31.85, ‘z’: 31.45, ‘y’: 30.63 }. It sould contain at least values for the band in which one need to simulate images. Default values are average magnitude zero points for LSST single visists in each band.
- Returns:
lens image
- slsim.ImageSimulation.image_simulation.lens_image_series(lens_class, band, mag_zero_point, num_pix, psf_kernel, transform_pix2angle, exposure_time=None, t_obs=None, std_gaussian_noise=None, with_source=True, with_deflector=True, gain=0.7, single_visit_mag_zero_points={'g': 32.33, 'i': 31.85, 'r': 32.17, 'y': 30.63, 'z': 31.45})[source]¶
Creates lens image on the basis of given information. This function is designed to simulate time series images of a lens.
- Parameters:
lens_class – Lens() object
band – imaging band (or list of bands). if float: assumed to apply to the full image series.
mag_zero_point – list of magnitude zero point for sequence of exposure
num_pix – number of pixels per axis
psf_kernels – list of psf kernel for each exposure.
transform_pix2angle – list of transformation matrix (2x2) of pixels into coordinate displacements for each exposure
exposure_time – list of exposure time for each exposure. It could be single exposure time or a exposure map.
t_obs – array of image observation time [day] for a lens.
std_gaussian_noise – array of standard deviation for gaussian noise for each image
with_source – If True, simulates image with extended source in lens configuration.
with_deflector – If True, simulates image with deflector.
gain – Amplifier gain (default 0.7 for LSST).
single_visit_mag_zero_points –
Zero points of the single-visit image in different bands. It is a dictionary of the form: {
’g’: 32.33, ‘r’: 32.17, ‘i’: 31.85, ‘z’: 31.45, ‘y’: 30.63
}. It sould contain at least values for the band in which one need to simulate images. Default values are average magnitude zero points for LSST single visists in each band.
- Returns:
list of series of images of a lens
- slsim.ImageSimulation.image_simulation.point_source_coordinate_properties(lens_class, band, mag_zero_point, delta_pix, num_pix, transform_pix2angle)[source]¶
Provides pixel coordinates for deflector and images. Currently, this function only works for point source.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
- Returns:
Dictionary of deflector and image coordinate in pixel unit and other coordinate properties.
- slsim.ImageSimulation.image_simulation.point_source_image_at_time(lens_class, band, mag_zero_point, delta_pix, num_pix, psf_kernel, transform_pix2angle, time)[source]¶
Creates lensed point source images with variability at a given time on the basis of given information.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
psf_kernel – psf kernel for the given exposure.
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
time – time is an image observation time [day].
- Returns:
point source images with variability
- slsim.ImageSimulation.image_simulation.point_source_image_with_variability(lens_class, band, mag_zero_point, delta_pix, num_pix, psf_kernels, transform_pix2angle, t_obs)[source]¶
Creates lensed point source images with variability for series of time on the basis of given information.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point for each exposure
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
psf_kernels – psf kernels in the sequence of exposures being simulated.
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
t_obs – array of image observation time [day].
- Returns:
array of point source images with variability
- slsim.ImageSimulation.image_simulation.point_source_image_without_variability(lens_class, band, mag_zero_point, delta_pix, num_pix, psf_kernel, transform_pix2angle)[source]¶
Creates lensed point source images without variability on the basis of given information.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
psf_kernel – psf kernel for an image.
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
- Returns:
point source images
- slsim.ImageSimulation.image_simulation.rgb_image_from_image_list(image_list, stretch)[source]¶
Creates a rgb image using list of images in r, g, and b.
- Parameters:
image_list – images in r, g, and b band. Here, ‘i’, ‘r’, and ‘g’ band are consider as r, g, and b respectively.
- Returns:
rgb image
- slsim.ImageSimulation.image_simulation.sharp_image(lens_class, band, mag_zero_point, delta_pix, num_pix, with_source=True, with_deflector=True)[source]¶
Creates an unconvolved image of a selected lens. Point source image is not included in this function.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
with_source – bool, if True computes source
with_deflector – bool, if True includes deflector light
- Returns:
2d array unblurred image
- slsim.ImageSimulation.image_simulation.sharp_rgb_image(lens_class, rgb_band_list, mag_zero_point, delta_pix, num_pix)[source]¶
Creates an unconvolved rgb image of a selected lens.
- Parameters:
lens_class – Lens() object
rgb_band_list – imaging band list. Here, ‘i’, ‘r’, and ‘g’ band are consider as r, g, and b respectively.
mag_zero_point – magnitude zero point in band
delta_pix – pixel scale of image generated
num_pix – number of pixels per axis
- Returns:
rgb image
- slsim.ImageSimulation.image_simulation.simulate_image(lens_class, band, num_pix, add_noise=True, observatory='LSST', kwargs_psf=None, kwargs_numerics=None, **kwargs)[source]¶
Creates an image of a selected lens with noise.
- Parameters:
lens_class – class object containing all information of the lensing system (e.g., Lens())
band – imaging band
num_pix – number of pixels per axis
add_noise – if True, add noise
observatory (str) – telescope type to be simulated
kwargs_psf (dict) – (optional) specific PSF quantities to overwrite default options (“psf_type”, “kernel_point_source”, “point_source_supersampling_factor”)
kwargs (dict) – additional keyword arguments for the bands
kwargs_numerics (dict) – options are “point_source_supersampling_factor”, “supersampling_factor”, and more in lenstronomy.ImSim.Numerics.numerics class
- Returns:
simulated image
- Return type:
2d numpy array
slsim.ImageSimulation.roman_image_simulation module¶
- slsim.ImageSimulation.roman_image_simulation.add_roman_background(image, band, detector, num_pix, exposure_time, ra, dec, date)[source]¶
Adds a sky and thermal background to image, corresponding to a specific band, detector, date, and coordinate in the sky.
- Parameters:
image (galsim Image class) – image to add the background to
band (string) – imaging band
detector (integer from 1 to 18) – The specific Roman detector being used to generate the psf
num_pix (integer) – number of pixels per axis
ra (float between 15 and 45) – Coordinate in space used to generate sky background
dec (float between -45 and -15) – Coordinate in space used to generate sky background
date (datetime.datetime class) – Date used to generate sky background
- Returns:
image with added background
- Return type:
galsim Image class
- slsim.ImageSimulation.roman_image_simulation.get_bandpass(band)[source]¶
- Parameters:
band (string) – imaging band
- Returns:
galsim bandpass object corresponding to specific band
- Return type:
galsim Bandpass class
- slsim.ImageSimulation.roman_image_simulation.get_bandpass_key(band)[source]¶
Translates the Roman bands to keys used in galsim.
- Parameters:
band (string) – The Roman band to be translated
- Returns:
Translated band
- Return type:
string
- slsim.ImageSimulation.roman_image_simulation.get_psf(band, detector, detector_pos, oversample, psf_directory)[source]¶
Obtain galsim psf corresponding to specific band, using stpsf.
- Parameters:
band (string) – The specific band corresponding to the psf
detector (integer from 1 to 18) – The specific Roman detector being used to generate the psf
detector_pos (integer between 4 + num_pix * oversample and 4092 - num_pix * oversample) – The position of the detector being used to generate the psf
oversample (integer) – Number of times that each pixel’s side is subdivided for higher accuracy psf convolution
psf_directory (string) – Path to directory containing psf file(s) where the psf can be loaded. Otherwise, the psf will be generated by stpsf which is very slow
- Returns:
An image of the psf generated by stpsf
- Return type:
galsim’s InterpolatedImage class
- slsim.ImageSimulation.roman_image_simulation.lens_image_roman(lens_class, band, mag_zero_point, num_pix, transform_pix2angle, detector=1, detector_pos=(2000, 2000), oversample=5, psf_directory=None, t_obs=None, with_source=True, with_deflector=True, ra=30, dec=-30, date=datetime.datetime(2027, 7, 7, 0, 0), add_noise=True, poisson_noise=True, seed=None)[source]¶
Creates lens image on the basis of given information. It can simulate both static lens image and variable lens image.
Note: This function might evolve in near future.
Note: This function might be changed in future.
- Parameters:
lens_class – Lens() object
band – imaging band
mag_zero_point – magnitude zero point for the exposure
num_pix – number of pixels per axis
transform_pix2angle – transformation matrix (2x2) of pixels into coordinate displacements
detector (integer from 1 to 18) – The specific Roman detector being used to generate the psf
detector_pos (integer between 4 + num_pix * oversample and 4092 - num_pix * oversample) – The position of the detector being used to generate the psf
oversample (integer) – Number of times that each pixel’s side is subdivided for higher accuracy psf convolution
psf_directory (string) –
Path to directory containing psf file(s) where the psf can be loaded. the user can download psfs from cached_webb_psf (https://github.com/LSST-strong-lensing/data_public/stpsf), where the
psfs have been generated ahead of time so that they can be loaded from a file. The directory containing these psfs should be passed into the “psf_directory”.
t_obs – an observation time [day]. This is applicable only for variable source. In case of point source, if we do not provide t_obs, considers no variability in the lens.
with_source – If True, simulates image with extended source in lens configuration.
with_deflector – If True, simulates image with deflector.
ra (float between 15 and 45) – Coordinate in space used to generate sky background
dec (float between -45 and -15) – Coordinate in space used to generate sky background
date (datetime.datetime class) – Date used to generate sky background
add_noise – determines whether sky background and detector effects are added or not
poisson_noise (bool) – determines whether poisson noise is added or not
seed (integer or None) – An rng seed used for generating detector effects in galsim
- Returns:
lens image in roman filter
- slsim.ImageSimulation.roman_image_simulation.simulate_roman_image(lens_class, band, num_pix, observatory='Roman', oversample=3, add_noise=True, with_source=True, with_deflector=True, detector=1, detector_pos=(2000, 2000), seed=None, ra=30, dec=-30, date=datetime.datetime(2027, 7, 7, 0, 0), psf_directory=None, **kwargs)[source]¶
Creates an image of a selected lens with noise.
- Parameters:
lens_class – class object containing all information of the lensing system (e.g., Lens())
band (string) – imaging band
num_pix (integer) – number of pixels per axis
add_noise – determines whether sky background and detector effects are added or not
with_source (bool) – determines whether source is included in image
with_deflector (bool) – determines whether deflector is included in image
detector (integer from 1 to 18) – The specific Roman detector being used to generate the psf
detector_pos (integer between 4 + num_pix * oversample and 4092 - num_pix * oversample) – The position of the detector being used to generate the psf
seed (integer or None) – An rng seed used for generating detector effects in galsim
ra (float between 15 and 45) – Coordinate in space used to generate sky background
dec (float between -45 and -15) – Coordinate in space used to generate sky background
date (datetime.datetime class) – Date used to generate sky background
psf_directory (string) – Path to directory containing psf file(s) where the psf can be loaded. Otherwise, the psf will be generated by stpsf which is very slow
kwargs (dict) – additional keyword arguments for the bands
- Returns:
simulated image
- Return type:
2d numpy array