Exemplo n.º 1
0
    def test_validate(self):
        message0 = "CYP projection is not defined for mu = -lambda"
        message1 = "CYP projection is not defined for lambda = -mu"

        # Pix2Sky_CylindricalPerspective
        with pytest.raises(InputParameterError) as err:
            projections.Pix2Sky_CylindricalPerspective(1, -1)
        assert str(err.value) == message0 or str(err.value) == message1
        with pytest.raises(InputParameterError) as err:
            projections.Pix2Sky_CylindricalPerspective(-1, 1)
        assert str(err.value) == message0 or str(err.value) == message1
        model = projections.Pix2Sky_CylindricalPerspective()
        with pytest.raises(InputParameterError) as err:
            model.mu = -1
        assert str(err.value) == message0
        with pytest.raises(InputParameterError) as err:
            model.lam = -1
        assert str(err.value) == message1

        # Sky2Pix_CylindricalPerspective
        with pytest.raises(InputParameterError) as err:
            projections.Sky2Pix_CylindricalPerspective(1, -1)
        assert str(err.value) == message0 or str(err.value) == message1
        with pytest.raises(InputParameterError) as err:
            projections.Sky2Pix_CylindricalPerspective(-1, 1)
        assert str(err.value) == message0 or str(err.value) == message1
        model = projections.Sky2Pix_CylindricalPerspective()
        with pytest.raises(InputParameterError) as err:
            model.mu = -1
        assert str(err.value) == message0
        with pytest.raises(InputParameterError) as err:
            model.lam = -1
        assert str(err.value) == message1
Exemplo n.º 2
0
 def setup_class(self):
     ID = "CYP"
     wcs_map = os.path.join(MAPS_DIR, f"1904-66_{ID}.hdr")
     test_file = get_pkg_data_filename(wcs_map)
     header = fits.Header.fromfile(test_file, endcard=False, padding=False)
     self.wazp = wcs.WCS(header)
     self.wazp.wcs.crpix = np.array([0., 0.])
     self.wazp.wcs.crval = np.array([0., 0.])
     self.wazp.wcs.cdelt = np.array([1., 1.])
     self.pv_kw = [kw[2] for kw in self.wazp.wcs.get_pv()]
     self.azp = projections.Pix2Sky_CylindricalPerspective(*self.pv_kw)
Exemplo n.º 3
0
def test_Pix2Sky_CylindricalPerspective_inverse():
    model = projections.Pix2Sky_CylindricalPerspective(2, 30)
    inverse = model.inverse
    assert isinstance(inverse, projections.Sky2Pix_CylindricalPerspective)
    assert inverse.mu == model.mu == 2
    assert inverse.lam == model.lam == 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)