Esempio n. 1
0
def check_ringnestring(vlen, ntry, nside):
    base = ph.Healpix_Base(nside, "NEST")
    for cnt in range(ntry):
        inp = rng.integers(low=0, high=12*nside*nside-1, size=vlen)
        out = base.nest2ring(base.ring2nest(inp))
        if not np.array_equal(inp, out):
            raise ValueError("Test failed")
Esempio n. 2
0
def check_pixxyfpix(vlen, ntry, nside, isnest):
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    for cnt in range(ntry):
        inp = rng.integers(low=0, high=12*nside*nside-1, size=vlen)
        out = base.xyf2pix(base.pix2xyf(inp))
        if not np.array_equal(inp, out):
            raise ValueError("Test failed")
Esempio n. 3
0
def check_vecpixvec(vlen, ntry, nside, isnest):
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    for cnt in range(ntry):
        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")
Esempio n. 4
0
    def __init__(self, spin2ecliptic_quats, obs, bore2spin_quat, nside):
        self.obs = obs

        self.keydict = {"timestamps": obs.get_times()}
        nsamples = len(self.keydict["timestamps"])

        self.keydict["flags"] = np.zeros(nsamples, dtype="uint8")

        pointings = lbs.get_pointings(
            obs=obs,
            spin2ecliptic_quats=spin2ecliptic_quats,
            detector_quats=obs.quat,
            bore2spin_quat=bore2spin_quat,
        )
        healpix_base = healpix.Healpix_Base(nside=nside, scheme="NEST")
        for (i, det) in enumerate(obs.name):
            if pointings[i].dtype == np.float64:
                curpnt = pointings[i]
            else:
                logging.warning(
                    "converting pointings for %s from %s to float64",
                    obs.name[i],
                    str(pointings[i].dtype),
                )
                curpnt = np.array(pointings[i], dtype=np.float64)

            if obs.tod[i].dtype == np.float64:
                self.keydict[f"signal_{det}"] = obs.tod[i]
            else:
                logging.warning(
                    "converting TODs for %s from %s to float64",
                    obs.name[i],
                    str(pointings[i].dtype),
                )
                self.keydict[f"signal_{det}"] = np.array(obs.tod[i], dtype=np.float64)

            self.keydict[f"pixels_{det}"] = healpix_base.ang2pix(curpnt[:, 0:2])
            self.keydict[f"weights_{det}"] = np.stack(
                (np.ones(nsamples), np.cos(2 * curpnt[:, 2]), np.sin(2 * curpnt[:, 2]))
            ).transpose()
Esempio n. 5
0
def test_ringnestring(vlen, nside_nest):
    base = ph.Healpix_Base(nside_nest, "NEST")
    rng = np.random.default_rng(42)
    inp = rng.integers(low=0, high=12 * nside_nest * nside_nest - 1, size=vlen)
    out = base.ring2nest(base.nest2ring(inp))
    assert_equal(np.all(out == inp), True)
Esempio n. 6
0
def test_vecpixvec_ring(vlen, nside_ring):
    base = ph.Healpix_Base(nside_ring, "RING")
    rng = np.random.default_rng(42)
    inp = ph.ang2vec(random_ptg(rng, vlen))
    out = base.pix2vec(base.vec2pix(inp))
    assert_equal(np.all(ph.v_angle(inp, out) < base.max_pixrad()), True)
Esempio n. 7
0
def test_pixangpix_ring(vlen, nside_ring):
    base = ph.Healpix_Base(nside_ring, "RING")
    rng = np.random.default_rng(42)
    inp = rng.integers(low=0, high=12 * nside_ring * nside_ring - 1, size=vlen)
    out = base.ang2pix(base.pix2ang(inp))
    assert_equal(inp, out)
Esempio n. 8
0
def test_pixangpix_nest(vlen, nside_nest):
    base = ph.Healpix_Base(nside_nest, "NEST")
    rng = np.random.default_rng(42)
    inp = rng.integers(low=0, high=12 * nside_nest * nside_nest - 1, size=vlen)
    out = base.ang2pix(base.pix2ang(inp))
    assert_equal(inp, out)
Esempio n. 9
0
def perf_neighbors(vlen, ntry, nside, isnest):
    inp = random_pix(nside, vlen)
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    genperf(base.neighbors, "neighbors", inp, vlen, ntry, nside, isnest)
Esempio n. 10
0
def perf_ring2nest(vlen, ntry, nside, isnest):
    inp = random_pix(nside, vlen)
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    genperf(base.ring2nest, "ring2nest", inp, vlen, ntry, nside, isnest)
Esempio n. 11
0
def perf_vec2pix(vlen, ntry, nside, isnest):
    inp = ph.ang2vec(random_ptg(vlen))
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    genperf(base.vec2pix, "vec2pix", inp, vlen, ntry, nside, isnest)
Esempio n. 12
0
def perf_pix2vec(vlen, ntry, nside, isnest):
    inp = random_pix(nside, vlen)
    base = ph.Healpix_Base(nside, "NEST" if isnest else "RING")
    genperf(base.pix2vec, "pix2vec", inp, vlen, ntry, nside, isnest)