示例#1
0
    def test_ang2pix(self):

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)

            theta = np.random.uniform(0, np.pi, 10000)
            phi = np.random.uniform(0, 2 * np.pi, 10000)

            assert_equal(hp.ang2pix(nside, theta, phi),
                         hpx.ang2pix_many(theta, phi))
示例#2
0
    def test_pix2ring(self):

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)
            npix = hpx.npix

            hpx_idx = np.random.random_integers(0, npix - 1, 10000)

            assert_equal(hp.pix2ring(nside, hpx_idx),
                         hpx.pix2ring_many(hpx_idx))
示例#3
0
    def test_get_ring_info_small(self):

        hpx = Healpix(64)

        assert hpx.get_ring_info_small(1) == (0, 4, True)
        assert hpx.get_ring_info_small(10) == (180, 40, True)
        assert hpx.get_ring_info_small(127) == (24192, 256, False)
        assert hpx.get_ring_info_small(128) == (24448, 256, True)
        assert hpx.get_ring_info_small(255) == (49148, 4, True)

        with pytest.raises(ValueError):
            hpx.get_ring_info_small(0)
        with pytest.raises(ValueError):
            hpx.get_ring_info_small(256)
示例#4
0
    def test_pix2ring(self):

        if not DO_HEALPY:
            # not possible on Windows
            return

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)
            npix = hpx.npix

            hpx_idx = np.random.random_integers(0, npix - 1, 10000)

            assert_equal(hp.pix2ring(nside, hpx_idx),
                         hpx.pix2ring_many(hpx_idx))
示例#5
0
    def test_ang2pix(self):

        if not DO_HEALPY:
            # not possible on Windows
            return

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)

            theta = np.random.uniform(0, np.pi, 10000)
            phi = np.random.uniform(0, 2 * np.pi, 10000)

            assert_equal(hp.ang2pix(nside, theta, phi),
                         hpx.ang2pix_many(theta, phi))
示例#6
0
    def test_query_disc(self):

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)
            disc_size = np.radians(0.5 / 60.)

            thetas = np.random.uniform(0, np.pi, 10)
            phis = np.random.uniform(0, 2 * np.pi, 10)

            for theta, phi in zip(thetas, phis):

                _vec = hp.ang2vec(theta, phi)
                hp_disc = hp.query_disc(nside, _vec, disc_size)
                assert_equal(hp_disc, hpx.query_disc(theta, phi, disc_size))
示例#7
0
    def test_get_ring_info_small(self):

        hpx = Healpix(64)

        assert hpx.get_ring_info_small(1) == (0, 4, True)
        assert hpx.get_ring_info_small(10) == (180, 40, True)
        assert hpx.get_ring_info_small(127) == (24192, 256, False)
        assert hpx.get_ring_info_small(128) == (24448, 256, True)
        assert hpx.get_ring_info_small(255) == (49148, 4, True)

        with pytest.raises(ValueError):
            hpx.get_ring_info_small(0)
        with pytest.raises(ValueError):
            hpx.get_ring_info_small(256)
示例#8
0
    def test_pix2ring(self):

        if not DO_HEALPY:
            # not possible on Windows
            return

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)
            npix = hpx.npix

            hpx_idx = np.random.random_integers(0, npix - 1, 10000)

            assert_equal(
                hp.pix2ring(nside, hpx_idx),
                hpx.pix2ring_many(hpx_idx)
                )
示例#9
0
    def test_ang2pix(self):

        if not DO_HEALPY:
            # not possible on Windows
            return

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)

            theta = np.random.uniform(0, np.pi, 10000)
            phi = np.random.uniform(0, 2 * np.pi, 10000)

            assert_equal(
                hp.ang2pix(nside, theta, phi),
                hpx.ang2pix_many(theta, phi)
                )
示例#10
0
    def test_query_disc(self):

        if not DO_HEALPY:
            # not possible on Windows
            return

        with NumpyRNGContext(12345):

            nside = 1024
            hpx = Healpix(nside)
            disc_size = np.radians(0.5 / 60.)

            thetas = np.random.uniform(0, np.pi, 10)
            phis = np.random.uniform(0, 2 * np.pi, 10)

            for theta, phi in zip(thetas, phis):

                _vec = hp.ang2vec(theta, phi)
                hp_disc = hp.query_disc(nside, _vec, disc_size)
                assert_equal(
                    hp_disc,
                    hpx.query_disc(theta, phi, disc_size)
                    )
示例#11
0
    def test_properties(self):

        eps = 1.e-10

        for nside, npface, npix, nrings, omega, order, reso in hpx_props:

            hpx = Healpix(nside)

            assert hpx.nside == nside
            assert hpx.npface == npface
            assert hpx.npix == npix
            assert hpx.nrings == nrings
            assert abs(hpx.omega - omega) < eps
            assert hpx.order == order
            assert abs(hpx.resolution - reso) < eps