@classmethod<EOL><INDENT>def simulate_to_target_signal_to_noise(cls, array, pixel_scale, target_signal_to_noise, exposure_time_map,<EOL>psf=None, background_sky_map=None, seed=-<NUM_LIT:1>):<DEDENT>
max_index = np.unravel_index(array.argmax(), array.shape)<EOL>max_image = array[max_index]<EOL>max_effective_exposure_time = exposure_time_map[max_index]<EOL>max_array_counts = np.multiply(max_image, max_effective_exposure_time)<EOL>if background_sky_map is not None:<EOL><INDENT>max_background_sky_map = background_sky_map[max_index]<EOL>max_background_sky_map_counts = np.multiply(max_background_sky_map, max_effective_exposure_time)<EOL><DEDENT>else:<EOL><INDENT>max_background_sky_map_counts = None<EOL><DEDENT>scale_factor = <NUM_LIT:1.><EOL>if background_sky_map is None:<EOL><INDENT>scale_factor = target_signal_to_noise ** <NUM_LIT> / max_array_counts<EOL><DEDENT>elif background_sky_map is not None:<EOL><INDENT>scale_factor = (max_array_counts + max_background_sky_map_counts) * target_signal_to_noise ** <NUM_LIT>/ max_array_counts ** <NUM_LIT><EOL><DEDENT>scaled_effective_exposure_time = np.multiply(scale_factor, exposure_time_map)<EOL>return cls.simulate_variable_arrays(array=array, pixel_scale=pixel_scale,<EOL>exposure_time_map=scaled_effective_exposure_time,<EOL>psf=psf, background_sky_map=background_sky_map,<EOL>add_noise=True, noise_seed=seed)<EOL>
Create a realistic simulated image by applying effects to a plain simulated image.

Parameters
----------
target_signal_to_noise
array : ndarray
    The image before simulating (e.g. the lens and source galaxies before optics blurring and CCD read-out).
pixel_scale: float
    The scale of each pixel in arc seconds
exposure_time_map : ndarray
    An array representing the effective exposure time of each pixel.
psf: PSF
    An array describing the PSF the simulated image is blurred with.
background_sky_map : ndarray
    The value of background sky in every image pixel (electrons per second).
seed: int
    A seed for random noise_maps generation