Beispiel #1
0
    def test_split_multiplane_rayshooting(self):

        model = self.lens_model_full

        kwargs = self.kwargs_lens_full

        xpos,ypos = self.x_pos_simple, self.y_pos_simple

        split = MultiPlaneLensing(model, xpos, ypos, kwargs,
                                  1.5, 0.5, self.cosmo, [0, 1], {}, None)

        betax_true, betay_true = model.ray_shooting(xpos, ypos, kwargs)

        args = self.kwargs_lens_full[0:2]

        betax, betay = split._ray_shooting_fast(macromodel_args=args,
                                                thetax=xpos, thetay=ypos, force_compute=True)

        betax_func, betay_func = split.ray_shooting(0, 0.5, self.kwargs_lens_full)
        betax_true_2, betay_true_2 = self.lens_model_full.ray_shooting(0, 0.5, self.kwargs_lens_full)

        npt.assert_almost_equal(betax_func,betax_true_2)
        npt.assert_almost_equal(betay_func,betay_true_2)

        npt.assert_almost_equal(betax_true, betax)
        npt.assert_almost_equal(betay_true, betay)
        npt.assert_almost_equal(betax_true, betax)
        npt.assert_almost_equal(betay_true, betay)
Beispiel #2
0
    def test_split_multi_plane_magnification(self):

        split = MultiPlaneLensing(self.lens_model_full, self.x_pos_simple,
                                  self.y_pos_simple, self.kwargs_lens_full,
                                  1.5, 0.5, self.cosmo, [0, 1], {}, None)

        _ = split._ray_shooting_fast(self.kwargs_lens_full[0:2])

        magnification_true = np.absolute(
            self.lens_model_full.magnification(self.x_pos_simple,
                                               self.y_pos_simple,
                                               self.kwargs_lens_full))
        magnification_split = split._magnification_fast(
            self.kwargs_lens_simple)

        npt.assert_almost_equal(
            magnification_true * max(magnification_true)**-1,
            magnification_split * max(magnification_split)**-1, 2)

        mag_true = self.lens_model_full.magnification(np.array([0, 0.2]),
                                                      np.array([0.4, 0.6]),
                                                      self.kwargs_lens_full)
        mag_true_split = split.magnification(np.array([0, 0.2]),
                                             np.array([0.4, 0.6]),
                                             self.kwargs_lens_full)

        npt.assert_almost_equal(mag_true, mag_true_split, decimal=4)
Beispiel #3
0
    def test_split_multi_plane_lensmodels(self):

        split = MultiPlaneLensing(self.lens_model_full,self.x_pos_simple,self.y_pos_simple,self.kwargs_lens_full,
                                  1.5,0.5,self.cosmo,[0,1], {}, None)

        macromodel_lensmodel, macro_args, halos_lensmodel, halos_args = \
            split._split_lensmodel(self.lens_model_full, self.kwargs_lens_full, [0, 1], None, self.convention_idx)

        assert macro_args == self.kwargs_lens_simple

        assert halos_args == self.front_args+self.main_args+self.back_args

        fore = split._foreground

        _ = fore.ray_shooting(split._halo_args, macro_args, offset_index=0, force_compute=False)

        assert fore._z_to_vary == 0.5

        output = fore._rays[0]['x'],fore._rays[0]['y'],fore._rays[0]['alphax'],fore._rays[0]['alphay']
        output_true = self.lens_model_front.lens_model.ray_shooting_partial(np.zeros_like(self.x_pos_simple),
                                                                            np.zeros_like(self.y_pos_simple),
                                                                            self.x_pos_simple, self.y_pos_simple, 0, 0.5,
                                                                            self.kwargs_front)

        for (_split,true) in zip(output,output_true):
            npt.assert_almost_equal(_split,true)
Beispiel #4
0
    def test_split_multiplane_hessian(self):

        split = MultiPlaneLensing(self.lens_model_full, self.x_pos_simple,
                                  self.y_pos_simple, self.kwargs_lens_full,
                                  1.5, 0.5, self.cosmo, [0, 1], {}, None)

        _ = split._ray_shooting_fast(self.kwargs_lens_full[0:2])

        f1, f2, f3, f4 = split._hessian_fast(self.kwargs_lens_simple)
        t1, t2, t3, t4 = self.lens_model_full.hessian(self.x_pos_simple,
                                                      self.y_pos_simple,
                                                      self.kwargs_lens_full)

        npt.assert_almost_equal(f1, t1, decimal=6)
        npt.assert_almost_equal(f2, t2, decimal=6)
        npt.assert_almost_equal(f3, t3, decimal=6)
        npt.assert_almost_equal(f4, t4, decimal=6)

        f1, f2, f3, f4 = split.hessian(0.5, 0.5, self.kwargs_lens_full)
        t1, t2, t3, t4 = self.lens_model_full.hessian(0.5, 0.5,
                                                      self.kwargs_lens_full)

        npt.assert_almost_equal(f1, t1)
        npt.assert_almost_equal(f2, t2)
        npt.assert_almost_equal(f3, t3)
        npt.assert_almost_equal(f4, t4)