def test_source2image(self): lensing_op = LensingOperator(self.lens_model, self.image_grid_class, self.source_grid_class_default, self.num_pix) source_1d = util.image2array(self.source_light_delensed) source_1d_lensed = lensing_op.source2image( source_1d, kwargs_lens=self.kwargs_lens) assert len(source_1d_lensed.shape) == 1 source_2d = self.source_light_delensed source_2d_lensed = lensing_op.source2image_2d( source_2d, kwargs_lens=self.kwargs_lens, update_mapping=True) assert len(source_2d_lensed.shape) == 2
def test_matrix_product(self): lensing_op = LensingOperator(self.lens_model, self.image_grid_class, self.source_grid_class_default, self.num_pix, source_interpolation='nearest_legacy') lensing_op.update_mapping(self.kwargs_lens) lensing_op_mat = LensingOperator(self.lens_model, self.image_grid_class, self.source_grid_class_default, self.num_pix, source_interpolation='nearest') lensing_op_mat.update_mapping(self.kwargs_lens) source_1d = util.image2array(self.source_light_delensed) image_1d = util.image2array(self.source_light_lensed) npt.assert_equal(lensing_op.source2image(source_1d), lensing_op_mat.source2image(source_1d)) npt.assert_equal(lensing_op.image2source(image_1d), lensing_op_mat.image2source(image_1d))
def test_interpol_mapping(self): """testing than image2source / source2image are close to the parametric mapping""" lensing_op = LensingOperator(self.lens_model, self.image_grid_class, self.source_grid_class_default, self.num_pix, source_interpolation='bilinear') lensing_op.update_mapping(self.kwargs_lens) source_1d = util.image2array(self.source_light_delensed) image_1d = util.image2array(self.source_light_lensed) source_1d_lensed = lensing_op.source2image(source_1d) image_1d_delensed = lensing_op.image2source(image_1d) assert source_1d_lensed.shape == image_1d.shape assert image_1d_delensed.shape == source_1d.shape npt.assert_almost_equal(source_1d_lensed / source_1d_lensed.max(), image_1d / image_1d.max(), decimal=0.8) npt.assert_almost_equal(image_1d_delensed / image_1d_delensed.max(), source_1d / source_1d.max(), decimal=0.8)