public void test_query_disc_strict() throws Exception { System.out.println("Testing non-inclusive queryDisc()"); Random rng = new Random(5); for (int o = 0; o <= 5; ++o) { int npix = (int) HealpixProc.order2Npix(o); boolean[] map = new boolean[npix]; Vec3[] vmap = new Vec3[npix]; for (int m = 0; m < npix; ++m) { map[m] = false; vmap[m] = HealpixProc.pix2vecRing(o, m); } for (int m = 0; m < nsamples; ++m) { Pointing ptg = random_dir(rng); double rad = Math.PI * rng.nextDouble(); RangeSet rs = HealpixProc.queryDiscRing(o, ptg, rad); Vec3 vptg = new Vec3(ptg); double cosrad = Math.cos(rad); for (int i = 0; i < rs.nranges(); ++i) for (long j = rs.ivbegin(i); j < rs.ivend(i); ++j) map[(int) j] = true; for (int i = 0; i < npix; ++i) { boolean inside = vmap[i].dot(vptg) > cosrad; assertFalse("query_disc_strict problem", inside ^ map[i]); } for (int i = 0; i < rs.nranges(); ++i) for (long j = rs.ivbegin(i); j < rs.ivend(i); ++j) map[(int) j] = false; } } }
public void test_ringnestring() throws Exception { System.out.println("Testing identity ring2nest(nest2ring(i))==i"); Random rng = new Random(5); for (int o = 0; o <= HealpixBase.order_max; ++o) { for (int m = 0; m < nsamples; ++m) { long pix = (long) (rng.nextDouble() * HealpixProc.order2Npix(o)); assertEquals( "ringnestring problem", HealpixProc.ring2nest(o, HealpixProc.nest2ring(o, pix)), pix); } } }
public void test_pixangpix() throws Exception { System.out.println("Testing identity pix2ang(ang2pix(i))==i"); int omax = HealpixBase.order_max; Random rng = new Random(5); for (int o = 0; o <= omax; ++o) { for (int m = 0; m < nsamples; ++m) { long pix = (long) (rng.nextDouble() * HealpixProc.order2Npix(o)); assertEquals( "pixangpix problem", pix, HealpixProc.ang2pixNest(o, HealpixProc.pix2angNest(o, pix))); assertEquals( "pixangpix problem", pix, HealpixProc.ang2pixRing(o, HealpixProc.pix2angRing(o, pix))); } } }
public void test() throws Exception { int o = 8; for (int i = 0; i < HealpixProc.order2Npix(o); ++i) { assertEquals( "pixel mismatch_nest", i, HealpixProc.ang2pixNest(o, HealpixProc.pix2angNest(o, i))); assertEquals( "pixel mismatch_nest", i, HealpixProc.vec2pixNest(o, HealpixProc.pix2vecNest(o, i))); assertEquals( "pixel mismatch_ring", i, HealpixProc.ang2pixRing(o, HealpixProc.pix2angRing(o, i))); assertEquals( "pixel mismatch_ring", i, HealpixProc.vec2pixRing(o, HealpixProc.pix2vecRing(o, i))); assertEquals( "pixel mismatch", i, HealpixProc.ring2nest(o, HealpixProc.ang2pixRing(o, HealpixProc.pix2angNest(o, i)))); assertEquals( "pixel mismatch_ringnestring", i, HealpixProc.ring2nest(o, HealpixProc.nest2ring(o, i))); } }
public void test_neighbours() throws Exception { System.out.println("Testing neighbour function"); int omax = HealpixBase.order_max; Random rng = new Random(5); for (int o = 0; o <= omax; ++o) { double maxang = 2.01 * HealpixProc.maxPixrad(o); for (int m = 0; m < nsamples; ++m) { long pix = (long) (rng.nextDouble() * HealpixProc.order2Npix(o)); Vec3 v = HealpixProc.pix2vecRing(o, pix); long[] nb = HealpixProc.neighboursRing(o, pix); long[] nb2 = HealpixProc.neighboursNest(o, HealpixProc.ring2nest(o, pix)); int nnb = 0; for (int n = 0; n < 8; ++n) { if (nb[n] < 0) assertTrue("neighbour problem 1", nb2[n] < 0); else { ++nnb; assertEquals("neighbour problem 2", HealpixProc.ring2nest(o, nb[n]), nb2[n]); assertTrue("neighbour problem 3", HealpixProc.pix2vecRing(o, nb[n]).angle(v) < maxang); } } assertTrue("neighbour problem 4 " + o + " " + nnb, (nnb >= 7) || ((o == 0) && (nnb >= 6))); } } }