コード例 #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])

        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_fast, betay_fast = split._ray_shooting_fast(split._macro_args)

        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, betax_fast)
        npt.assert_almost_equal(betax_true, betax)
        npt.assert_almost_equal(betay_true, betay)
        npt.assert_almost_equal(betax_true, betax_fast)
        npt.assert_almost_equal(betay_true, betay_fast)
コード例 #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)
コード例 #3
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)