How to use the autoarray.array.full function in autoarray

To help you get started, we’ve selected a few autoarray examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__signal_to_noise_limit_above_max_signal_to_noise__signal_to_noise_map_unchanged(
            self
        ):
            image = aa.array.full(fill_value=20.0, shape_2d=(2,2))
            image[3] = 5.0

            noise_map_array = aa.array.full(fill_value=5.0, shape_2d=(2,2))
            noise_map_array[3] = 2.0

            imaging_data = al.ImagingData(
                image=image,
                psf=aa.kernel.zeros(shape_2d=(3,3)),
                noise_map=noise_map_array,
                background_noise_map=aa.array.full(fill_value=1.0, shape_2d=(2,2)),
                exposure_time_map=aa.array.full(fill_value=2.0, shape_2d=(2,2)),
                background_sky_map=aa.array.full(fill_value=3.0, shape_2d=(2,2)),
            )

            imaging_data = imaging_data.signal_to_noise_limited_data_from_signal_to_noise_limit(
                signal_to_noise_limit=100.0
            )

            assert (imaging_data.image.in_2d == np.array([[20.0, 20.0], [20.0, 5.0]])).all()

            assert (
                imaging_data.noise_map.in_2d == np.array([[5.0, 5.0], [5.0, 2.0]])
            ).all()

            assert (
                imaging_data.signal_to_noise_map.in_2d
                == np.array([[4.0, 4.0], [4.0, 2.5]])
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__signal_to_noise_limit_below_max_signal_to_noise__signal_to_noise_map_capped_to_limit(
            self
        ):
            image = aa.array.full(fill_value=20.0, shape_2d=(2,2))
            image[3] = 5.0

            noise_map_array = aa.array.full(fill_value=5.0, shape_2d=(2,2))
            noise_map_array[3] = 2.0

            imaging_data = al.ImagingData(
                image=image,
                psf=aa.kernel.zeros(shape_2d=(3,3)),
                noise_map=noise_map_array,
                background_noise_map=aa.array.full(fill_value=1.0, shape_2d=(2,2)),
                exposure_time_map=aa.array.full(fill_value=2.0, shape_2d=(2,2)),
                background_sky_map=aa.array.full(fill_value=3.0, shape_2d=(2,2)),
            )

            imaging_data_capped = imaging_data.signal_to_noise_limited_data_from_signal_to_noise_limit(
                signal_to_noise_limit=2.0
            )

            assert (
                imaging_data_capped.image.in_2d == np.array([[20.0, 20.0], [20.0, 5.0]])
            ).all()

            assert (
                imaging_data_capped.noise_map.in_2d
                == np.array([[10.0, 10.0], [10.0, 2.5]])
            ).all()
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__signal_to_noise_limit_above_max_signal_to_noise__signal_to_noise_map_unchanged(
            self
        ):
            image = aa.array.full(fill_value=20.0, shape_2d=(2,2))
            image[3] = 5.0

            noise_map_array = aa.array.full(fill_value=5.0, shape_2d=(2,2))
            noise_map_array[3] = 2.0

            imaging_data = al.ImagingData(
                image=image,
                psf=aa.kernel.zeros(shape_2d=(3,3)),
                noise_map=noise_map_array,
                background_noise_map=aa.array.full(fill_value=1.0, shape_2d=(2,2)),
                exposure_time_map=aa.array.full(fill_value=2.0, shape_2d=(2,2)),
                background_sky_map=aa.array.full(fill_value=3.0, shape_2d=(2,2)),
            )

            imaging_data = imaging_data.signal_to_noise_limited_data_from_signal_to_noise_limit(
                signal_to_noise_limit=100.0
            )

            assert (imaging_data.image.in_2d == np.array([[20.0, 20.0], [20.0, 5.0]])).all()
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
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.manual_2d(
            array=np.array([[0.0, 1.0, 0.0], [1.0, 2.0, 1.0], [0.0, 1.0, 0.0]]),
        )

        exposure_time_map = aa.array.full(fill_value=20.0, shape_2d=image.mask.shape
        )

        imaging_data_simulated = al.SimulatedImagingData.from_image_and_exposure_arrays(
            image=image,
            exposure_time=20.0,
            exposure_time_map=exposure_time_map,
            psf=psf,
            add_noise=True,
            noise_seed=1,
        )

        assert (
            imaging_data_simulated.exposure_time_map.in_2d == 20.0 * np.ones((3, 3))
        ).all()
        assert imaging_data_simulated.image.in_2d == pytest.approx(
            np.array([[0.0, 1.05, 0.0], [1.3, 2.35, 1.05], [0.0, 1.05, 0.0]]), 1e-2
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_uv_plane.py View on Github external
def test__setup_with_all_features_off(self, transformer_7x7_7):
        image = aa.array.manual_2d([[2.0, 0.0, 0.0], [0.0, 1.0, 0.0], [3.0, 0.0, 0.0]])

        exposure_time_map = aa.array.full(
            fill_value=1.0, pixel_scales=0.1, shape_2d=image.shape_2d
        )

        uv_plane_data_simulated = al.SimulatedUVPlaneData.from_image_and_exposure_arrays(
            image=image,
            exposure_time=1.0,
            exposure_time_map=exposure_time_map,
            pixel_scales=0.1,
            transformer=transformer_7x7_7,
            noise_sigma=None,
        )

        simulated_visibilities = transformer_7x7_7.visibilities_from_image(
            image=image
        )
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__image_all_1s__bg_noise_all_2s__exposure_time_all_1s__noise_map_all_sqrt_5s(
            self
        ):
            imaging_data = aa.array.ones(shape_2d=(2,2))
            background_noise_map = aa.array.full(fill_value=2.0, shape_2d=(2,2))
            exposure_time_map = aa.array.ones(shape_2d=(2,2))

            noise_map = al.NoiseMap.from_image_and_background_noise_map(
                image=imaging_data,
                background_noise_map=background_noise_map,
                gain=1.0,
                exposure_time_map=exposure_time_map,
            )

            assert (
                noise_map.in_2d
                == np.array(
                    [[np.sqrt(5.0), np.sqrt(5.0)], [np.sqrt(5.0), np.sqrt(5.0)]]
                )
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__same_as_above_but_different_image_values_in_each_pixel_and_new_background_values(
            self
        ):
            # Can use pattern from previous test_autoarray for values

            image = aa.array.manual_2d(
                array=[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]
            )

            exposure_time = aa.array.ones(shape_2d=(3,2))
            background_noise = aa.array.full(fill_value=12.0, shape_2d=(3,2))

            imaging_data = al.ImagingData(
                image=image,
                pixel_scales=1.0,
                psf=aa.kernel.ones(shape_2d=(3,3)),
                exposure_time_map=exposure_time,
                background_noise_map=background_noise,
            )

            assert imaging_data.estimated_noise_map.in_2d == pytest.approx(
                np.array(
                    [
                        [np.sqrt(1.0 + 144.0), np.sqrt(2.0 + 144.0)],
                        [np.sqrt(3.0 + 144.0), np.sqrt(4.0 + 144.0)],
                        [np.sqrt(5.0 + 144.0), np.sqrt(6.0 + 144.0)],
                    ]
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__image_and_exposure_times_range_of_values__background_has_value_9___noise_estimates_correct(
            self
        ):
            # Use same pattern as above, noting that here our background values are now being converts to counts using
            # different exposure time and then being squared.

            image = aa.array.manual_2d(
                array=[[5.0, 3.0], [10.0, 20.0]]
            )

            exposure_time = aa.array.manual_2d(
                array=[[1.0, 2.0], [3.0, 4.0]]
            )
            background_noise = aa.array.full(fill_value=9.0, 
                    shape_2d=((2, 2))
            )

            imaging_data = al.ImagingData(
                image=image,
                pixel_scales=1.0,
                psf=aa.kernel.ones(shape_2d=(3,3)),
                exposure_time_map=exposure_time,
                background_noise_map=background_noise,
            )

            assert imaging_data.estimated_noise_map.in_2d == pytest.approx(
                np.array(
                    [
                        [np.sqrt(5.0 + 81.0), np.sqrt(6.0 + 18.0 ** 2.0) / 2.0],
                        [
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
self
        ):
            # Imaging (eps) = 1.0
            # Background (eps) = 5.0
            # Exposure times = 1.0 s
            # Imaging (counts) = 1.0
            # Background (counts) = 5.0

            # Noise (counts) = sqrt(1.0 + 5**2)
            # Noise (eps) = sqrt(1.0 + 5**2) / 1.0

            image = aa.array.ones(shape_2d=(2,3))

            exposure_time = aa.array.ones(shape_2d=(2,3))

            background_noise = aa.array.full(fill_value=5.0, shape_2d=(2,3))

            imaging_data = al.ImagingData(
                image=image,
                pixel_scales=1.0,
                psf=aa.kernel.ones(shape_2d=(3,3)),
                exposure_time_map=exposure_time,
                background_noise_map=background_noise,
            )

            assert imaging_data.estimated_noise_map.in_2d == pytest.approx(
                np.array(
                    [
                        [np.sqrt(1.0 + 25.0), np.sqrt(1.0 + 25.0), np.sqrt(1.0 + 25.0)],
                        [np.sqrt(1.0 + 25.0), np.sqrt(1.0 + 25.0), np.sqrt(1.0 + 25.0)],
                    ]
                ),
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
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, 
                    shape_2d=((3, 3)),
                ),
            )

            assert imaging_data.image.in_2d == pytest.approx(
                np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), 1e-2
            )
            assert (imaging_data.psf.in_2d == 3.0 * np.ones((3, 3))).all()
            assert (imaging_data.noise_map.in_2d == 5.0 * np.ones((3, 3))).all()
            assert (
                imaging_data.background_noise_map.in_2d == 7.0 * np.ones((3, 3))
            ).all()
            assert (imaging_data.poisson_noise_map.in_2d == 9.0 * np.ones((3, 3))).all()
            assert (
                imaging_data.exposure_time_map.in_2d == 11.0 * np.ones((3, 3))
            ).all()