How to use the autoarray.array.manual_2d 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__image_and_exposure_times_and_background_are_all_ranges_of_values__noise_estimates_correct(
            self
        ):
            # Use same pattern as above, noting that we are now also using a variable background signal_to_noise_ratio map.

            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.manual_2d(
                array=[[5.0, 6.0], [7.0, 8.0]]
            )

            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(
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__via_edges__5x5_image_simple_gaussian_two_edges__ignores_central_pixel(
            self
        ):
            image = aa.array.manual_2d(
                [
                    [1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1],
                    [1, 1, 100, 1, 1],
                    [1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1],
                ]
            )

            imaging_data = al.ImagingData(
                image=image,
                noise_map=np.ones((3, 3)),
                psf=aa.kernel.ones(shape_2d=(3,3)),
                pixel_scales=0.1,
            )
            sky_noise = imaging_data.background_noise_from_edges(no_edges=2)
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__via_edges__input_all_ones__sky_bg_level_1(self):
            imaging_data = al.ImagingData(
                image=aa.array.manual_2d(np.ones((3, 3))),
                noise_map=np.ones((3, 3)),
                psf=aa.kernel.ones(shape_2d=(3,3)),
                pixel_scales=0.1,
            )

            sky_noise = imaging_data.background_noise_from_edges(no_edges=1)

            assert sky_noise == 0.0
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__via_edges__4x4_image_simple_gaussian__ignores_central_pixels(self):
            image = aa.array.manual_2d(
                [[1, 1, 1, 1], [1, 100, 100, 1], [1, 100, 100, 1], [1, 1, 1, 1]]
            )

            imaging_data = al.ImagingData(
                image=image,
                noise_map=np.ones((3, 3)),
                psf=aa.kernel.ones(shape_2d=(3,3)),
                pixel_scales=0.1,
            )
            sky_noise = imaging_data.background_noise_from_edges(no_edges=1)

            assert sky_noise == 0.0
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_uv_plane.py View on Github external
def test__setup_with_noise(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=20.0, pixel_scales=0.1, shape_2d=image.shape_2d
        )

        uv_plane_data_simulated = al.SimulatedUVPlaneData.from_image_and_exposure_arrays(
            image=image,
            pixel_scales=0.1,
            exposure_time=20.0,
            exposure_time_map=exposure_time_map,
            transformer=transformer_7x7_7,
            noise_sigma=0.1,
            noise_seed=1,
        )

        simulated_visibilities = transformer_7x7_7.visibilities_from_image(
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
def test__setup_with_psf_blurring_on__blurs_image_and_trims_psf_edge_off(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.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.ones(shape_2d=image.mask.shape
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_abstract_data.py View on Github external
def test__image_and_noise_are_values__signal_to_noise_is_absolute_image_value_over_noise(
        self
    ):
        array = aa.array.manual_2d([[-1.0, 2.0], [3.0, -4.0]])
        noise_map = aa.array.manual_2d([[10.0, 10.0], [30.0, 4.0]])

        data = al.AbstractData(data=array, noise_map=noise_map)

        assert (
            data.potential_chi_squared_map.in_2d
            == np.array([[0.1 ** 2.0, 0.2 ** 2.0], [0.1 ** 2.0, 1.0 ** 2.0]])
        ).all()
        assert data.potential_chi_squared_max == 1.0
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
):
        imaging_data = al.load_imaging_data_from_fits(
            pixel_scales=0.1,
            image_path=test_data_dir + "3x3_ones.fits",
            psf_path=test_data_dir + "3x3_twos.fits",
            noise_map_from_image_and_background_noise_map=True,
            background_noise_map_path=test_data_dir + "3x3_fours.fits",
            poisson_noise_map_path=test_data_dir + "3x3_fives.fits",
            exposure_time_map_path=test_data_dir + "3x3_sixes.fits",
            background_sky_map_path=test_data_dir + "3x3_sevens.fits",
            convert_from_electrons=True,
            renormalize_psf=False,
        )

        image = aa.array.ones(shape_2d=(3,3))
        background_noise_map = aa.array.manual_2d(
            array=4.0 * np.ones((3, 3))
        )

        noise_map_converted = al.NoiseMap.from_image_and_background_noise_map(
            image=image,
            background_noise_map=background_noise_map,
            gain=None,
            exposure_time_map=imaging_data.exposure_time_map,
            convert_from_electrons=True,
        )

        noise_map_converted = noise_map_converted / 6.0

        assert (imaging_data.image.in_2d == np.ones((3, 3)) / 6.0).all()
        assert (imaging_data.psf.in_2d == 2.0 * np.ones((3, 3))).all()
        assert (imaging_data.noise_map.in_2d == noise_map_converted.in_2d).all()
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_imaging.py View on Github external
imaging_data = al.load_imaging_data_from_fits(
            pixel_scales=0.1,
            image_path=test_data_dir + "3x3_ones.fits",
            psf_path=test_data_dir + "3x3_twos.fits",
            noise_map_from_image_and_background_noise_map=True,
            background_noise_map_path=test_data_dir + "3x3_fours.fits",
            poisson_noise_map_path=test_data_dir + "3x3_fives.fits",
            exposure_time_map_path=test_data_dir + "3x3_sixes.fits",
            background_sky_map_path=test_data_dir + "3x3_sevens.fits",
            gain=2.0,
            convert_from_adus=True,
            renormalize_psf=False,
        )

        image = aa.array.ones(shape_2d=(3,3))
        background_noise_map = aa.array.manual_2d(
            array=4.0 * np.ones((3, 3)),
        )

        noise_map_converted = al.NoiseMap.from_image_and_background_noise_map(
            image=image,
            background_noise_map=background_noise_map,
            gain=2.0,
            exposure_time_map=imaging_data.exposure_time_map,
            convert_from_adus=True,
        )

        noise_map_converted = 2.0 * noise_map_converted / 6.0

        assert (imaging_data.image.in_2d == 2.0 * np.ones((3, 3)) / 6.0).all()
        assert (imaging_data.psf.in_2d == 2.0 * np.ones((3, 3))).all()
        assert (imaging_data.noise_map.in_2d == noise_map_converted.in_2d).all()
github Jammy2211 / PyAutoLens / test_autolens / unit / data / test_abstract_data.py View on Github external
def test__weight_map_no_zeros__uses_1_over_sqrt_value(self):
            weight_map = aa.array.manual_2d([[1.0, 4.0, 16.0], [1.0, 4.0, 16.0]])

            noise_map = al.AbstractNoiseMap.from_weight_map(
                weight_map=weight_map,
            )

            assert (
                noise_map.in_2d == np.array([[1.0, 0.5, 0.25], [1.0, 0.5, 0.25]])
            ).all()