Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
array_2d=background_noise_map_array.in_2d, bin_up_factor=2
)
exposure_time_map_array = aa.array.ones(shape_2d=(6,6), pixel_scales=1.0)
exposure_time_map_array[21:24] = 5.0
binned_exposure_time_map_util = aa.binning_util.binned_array_2d_using_sum_from_array_2d_and_bin_up_factor(
array_2d=exposure_time_map_array.in_2d, bin_up_factor=2
)
background_sky_map_array = aa.array.ones(shape_2d=(6,6), pixel_scales=1.0)
background_sky_map_array[21:24] = 6.0
binned_background_sky_map_util = aa.binning_util.binned_up_array_2d_using_mean_from_array_2d_and_bin_up_factor(
array_2d=background_sky_map_array.in_2d, bin_up_factor=2
)
psf = aa.kernel.ones(shape_2d=(3,5), pixel_scales=1.0)
psf_util = psf.rescaled_with_odd_dimensions_from_rescale_factor(
rescale_factor=0.5, renormalize=True
)
imaging_data = al.ImagingData(
image=image,
pixel_scales=1.0,
psf=psf,
noise_map=noise_map_array,
background_noise_map=background_noise_map_array,
exposure_time_map=exposure_time_map_array,
background_sky_map=background_sky_map_array,
)
imaging_data = imaging_data.binned_data_from_bin_up_factor(
bin_up_factor=2
def test__data_with_resized_primary_beam(self):
uv_plane_data = al.UVPlaneData(
shape_2d=(2, 2),
pixel_scales=1.0,
visibilities=np.array([[1, 1]]),
primary_beam=aa.kernel.zeros(shape_2d=(5,5), pixel_scales=1.0),
noise_map=1,
exposure_time_map=1,
uv_wavelengths=1,
)
uv_plane_data = uv_plane_data.resized_primary_beam_from_new_shape(
new_shape=(1, 1)
)
assert (uv_plane_data.primary_beam.in_2d == np.zeros((1, 1))).all()
def __new__(cls, shape, value, pixel_scales=1.0, *args, **kwargs):
return aa.kernel(
array_1d=value * np.ones(shape=shape),
pixel_scales=pixel_scales,
origin=(0.0, 0.0),
)
def test__setup_with_background_sky_and_psf_on__psf_does_no_blurring__image_and_sky_both_trimmed(
self
):
image = aa.array.manual_2d(
array=np.array(
[
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
]
),
)
psf = aa.kernel.no_blur()
exposure_time_map = aa.array.ones(shape_2d=image.mask.shape
)
background_sky_map = aa.array.full(fill_value=16.0, shape_2d=image.mask.shape
)
imaging_data_simulated = al.SimulatedImagingData.from_image_and_exposure_arrays(
image=image,
exposure_time=1.0,
exposure_time_map=exposure_time_map,
psf=psf,
background_sky_map=background_sky_map,
add_noise=False,
noise_seed=1,
)
def test__setup_image__correct_attributes(self):
image = aa.array.manual_2d(
array=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
)
psf = aa.kernel.full(fill_value=3.0, shape_2d=(3,3))
noise_map = aa.array.manual_2d(
array=5.0 * np.ones((3, 3)),
)
imaging_data = al.ImagingData(
image=image,
pixel_scales=0.1,
noise_map=noise_map,
psf=psf,
background_noise_map=aa.array.full(fill_value=7.0,
shape_2d=((3, 3)),
),
poisson_noise_map=aa.array.full(fill_value=9.0,
shape_2d=((3, 3)),
),
exposure_time_map=aa.array.full(fill_value=11.0,
def __new__(cls, shape, value, pixel_scales=1.0, *args, **kwargs):
return aa.kernel.manual_2d(
array_2d=value * np.ones(shape=shape),
pixel_scales=pixel_scales,
origin=(0.0, 0.0),
)
noise_map_array = aa.array.ones(shape_2d=(4,4))
noise_map_array[10] = 3.0
background_noise_map_array = aa.array.ones(shape_2d=(4,4))
background_noise_map_array[10] = 4.0
exposure_time_map_array = aa.array.ones(shape_2d=(4,4))
exposure_time_map_array[10] = 5.0
background_sky_map_array = aa.array.ones(shape_2d=(4,4))
background_sky_map_array[10] = 6.0
imaging_data = al.ImagingData(
image=image,
pixel_scales=1.0,
psf=aa.kernel.zeros(shape_2d=(3,3)),
noise_map=noise_map_array,
background_noise_map=background_noise_map_array,
exposure_time_map=exposure_time_map_array,
background_sky_map=background_sky_map_array,
)
modified_image = aa.array.ones(shape_2d=(4,4), pixel_scales=1.0)
modified_image[10] = 10.0
imaging_data = imaging_data.modified_image_from_image(
image=modified_image
)
assert (
imaging_data.image.in_2d
== np.array(
cls,
shape=(401, 401),
pixel_scales=0.03,
psf_shape=(31, 31),
psf_sigma=0.05,
exposure_time=2000.0,
background_sky_level=1.0,
add_noise=True,
noise_if_add_noise_false=0.1,
noise_seed=-1,
):
"""Default settings for an observation with the Hubble Space Telescope which has been upscaled to a higher \
pixel-scale to better sample the PSF.
This can be customized by over-riding the default input values."""
psf = aa.kernel.from_gaussian(
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
)
return ImagingSimulator(
shape_2d=shape,
pixel_scales=pixel_scales,
psf=psf,
exposure_time=exposure_time,
background_sky_level=background_sky_level,
add_noise=add_noise,
noise_if_add_noise_false=noise_if_add_noise_false,
noise_seed=noise_seed
)
def lsst(
cls,
shape=(101, 101),
pixel_scales=0.2,
psf_shape=(31, 31),
psf_sigma=0.5,
exposure_time=100.0,
background_sky_level=1.0,
add_noise=True,
noise_if_add_noise_false=0.1,
noise_seed=-1,
):
"""Default settings for an observation with the Large Synotpic Survey Telescope.
This can be customized by over-riding the default input values."""
psf = aa.kernel.from_gaussian(
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
)
return ImagingSimulator(
shape_2d=shape,
pixel_scales=pixel_scales,
psf=psf,
exposure_time=exposure_time,
background_sky_level=background_sky_level,
add_noise=add_noise,
noise_if_add_noise_false=noise_if_add_noise_false,
noise_seed=noise_seed,
)