def test_c_projection_striding(): # This is just a simple test to make sure that the striding is # handled correctly in the projection C extension coords = np.arange(10).reshape((5, 2)) model = projections.Sky2Pix_ZenithalPerspective(2, 30) phi, theta = model(coords[:, 0], coords[:, 1]) assert_almost_equal(phi, [0., 2.2790416, 4.4889294, 6.6250643, 8.68301]) assert_almost_equal( theta, [-76.4816918, -75.3594654, -74.1256332, -72.784558, -71.3406629])
def test_Sky2Pix_ZenithalPerspective_inverse(): model = projections.Sky2Pix_ZenithalPerspective(2, 30) inverse = model.inverse assert isinstance(inverse, projections.Pix2Sky_AZP) assert inverse.mu == model.mu == 2 assert_allclose(inverse.gamma, model.gamma) assert_allclose(inverse.gamma, 30) x = np.linspace(0, 1, 100) y = np.linspace(0, 1, 100) a, b = model(*inverse(x, y)) assert_allclose(a, x, atol=1e-12) assert_allclose(b, y, atol=1e-12) a, b = inverse(*model(x, y)) assert_allclose(a, x, atol=1e-12) assert_allclose(b, y, atol=1e-12)
def test_validate(self): message = "Zenithal perspective projection is not defined for mu = -1" with pytest.raises(InputParameterError) as err: projections.Pix2Sky_ZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Sky2Pix_ZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Pix2Sky_SlantZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Sky2Pix_SlantZenithalPerspective(-1) assert str(err.value) == message