import ducc_0_1.healpix as ph import numpy as np import math rng = np.random.default_rng(42) def random_ptg(vlen): res = np.empty((vlen, 2), dtype=np.float64) res[:,0] = np.arccos((rng.random(vlen)-0.5)*2) res[:,1] = rng.random(vlen)*2*math.pi return res def check_pixangpix(vlen,ntry,nside,isnest): base = ph.Healpix_Base (nside, "NEST" if isnest else "RING") cnt = 0 while cnt < ntry: cnt += 1 inp = rng.integers(low=0, high=12*nside*nside-1, size=vlen) out = base.ang2pix(base.pix2ang(inp)) if not np.array_equal(inp, out): raise ValueError("Test failed") def check_vecpixvec(vlen, ntry, nside, isnest): base = ph.Healpix_Base (nside, "NEST" if isnest else "RING") cnt = 0 while cnt < ntry: cnt += 1 inp = ph.ang2vec(random_ptg(vlen)) out = base.pix2vec(base.vec2pix(inp)) if np.any(ph.v_angle(inp,out) > base.max_pixrad()): raise ValueError("Test failed") def check_pixangvecpix(vlen, ntry, nside, isnest): base = ph.Healpix_Base (nside, "NEST" if isnest else "RING") cnt = 0 while cnt < ntry: cnt += 1 inp = rng.integers(low=0, high=12*nside*nside-1, size=vlen) out = base.vec2pix(ph.ang2vec(base.pix2ang(inp))) if not np.array_equal(inp,out): raise ValueError("Test failed") def check_pixvecangpix(vlen, ntry, nside, isnest): base = ph.Healpix_Base (nside, "NEST" if isnest else "RING") cnt = 0 while cnt < ntry: cnt += 1 inp = rng.integers(low=0, high=12*nside*nside-1, size=vlen) out = base.ang2pix(ph.vec2ang(base.pix2vec(inp))) if not np.array_equal(inp,out): raise ValueError("Test failed") def check_pixvecpix(vlen,ntry,nside,isnest): base=ph.Healpix_Base (nside,"NEST" if isnest else "RING") cnt=0 while (cnt