Ejemplo n.º 1
0
 def setnside(self, nside):
     if self._nside is not None:
         raise ValueError("nside is immutable")
     if not isinstance(nside, int):
         raise TypeError("nside must be an integer")
     b = bin(nside)[2:]
     if b[0] != "1" or int(b[1:], 2) != 0:
         raise ValueError("nside has invalid value")
     self._nside = nside
Ejemplo n.º 2
0
def _mk_xy2pix():
    global _x2pix
    global _y2pix
    _x2pix = np.zeros(128, int)
    _y2pix = np.zeros(128, int)
    for i in range(128):
        b = bin(i)[2:]
        _x2pix[i] = int(b, 4)
        _y2pix[i] = 2 * int(b, 4)
Ejemplo n.º 3
0
def ring2nest_ind(ind, nside):
    global _n2r

    b = bin(nside)[2:]
    if b[0] != "1" or int(b[1:], 2) != 0:
        raise ValueError("ring2nest_ind: nside has invalid value")
    if not _n2r.has_key(nside):
        _init_n2r(nside)

    return _n2r[nside][ind]
Ejemplo n.º 4
0
def nest2ring_ind(ind, nside):
    global _r2n

    b = bin(nside)[2:]
    if b[0] != "1" or int(b[1:], 2) != 0:
        raise ValueError("nest2ring_ind: nside has invalid value")

    if not _r2n.has_key(nside):
        _init_r2n(nside)

    return _r2n[nside][ind]
Ejemplo n.º 5
0
def _mk_pix2xy():
    global _pix2x
    global _pix2y
    _pix2x = np.zeros(1024, int)
    _pix2y = np.zeros(1024, int)

    # pix2x contains the integer repr. of all odd bits, pix2y all the even ones.
    for i in range(1024):
        b = bin(i)[2:]
        _pix2x[i] = int(b[-1::-2][::-1], 2)
        if len(b) == 1:
            _pix2y[i] = 0
        else:
            _pix2y[i] = int(b[-2::-2][::-1], 2)