How to use the healpy.vec2pix function in healpy

To help you get started, we’ve selected a few healpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gammapy / gammapy / gammapy / maps / hpx.py View on Github external
def match_hpx_pix(nside, nest, nside_pix, ipix_ring):
    """TODO: document."""
    import healpy as hp

    ipix_in = np.arange(12 * nside * nside)
    vecs = hp.pix2vec(nside, ipix_in, nest)
    pix_match = hp.vec2pix(nside_pix, vecs[0], vecs[1], vecs[2]) == ipix_ring
    return ipix_in[pix_match]
github gammapy / gammapy / gammapy / _fermipy / hpx_utils.py View on Github external
def match_hpx_pixel(nside, nest, nside_pix, ipix_ring):
    """
    """
    import healpy as hp
    ipix_in = np.arange(12 * nside * nside)
    vecs = hp.pix2vec(nside, ipix_in, nest)
    pix_match = hp.vec2pix(nside_pix, vecs[0], vecs[1], vecs[2]) == ipix_ring
    return ipix_in[pix_match]
github fermiPy / fermipy / fermipy / hpx_utils.py View on Github external
def match_hpx_pixel(nside, nest, nside_pix, ipix_ring):
    """
    """
    ipix_in = np.arange(12 * nside * nside)
    vecs = hp.pix2vec(nside, ipix_in, nest)
    pix_match = hp.vec2pix(nside_pix, vecs[0], vecs[1], vecs[2]) == ipix_ring
    return ipix_in[pix_match]
github HERA-Team / aipy / aipy / healpix.py View on Github external
def crd2px(self, c1, c2, c3=None, interpolate=False):
        """Convert 1 dimensional arrays of input coordinates to pixel indices. If only c1,c2 provided, then read them as th,phi.  If c1,c2,c3 provided, read them as x,y,z. If interpolate is False, return a single pixel coordinate.  If interpolate is True, return px,wgts where each entry in px contains the 4 pixels adjacent to the specified location, and wgt contains the 4 corresponding weights of those pixels."""
        is_nest = (self._scheme == 'NEST')
        if not interpolate:
            if c3 is None: # th/phi angle mode
                px = healpy.ang2pix(self._nside, c1, c2, nest=is_nest)
            else: # x,y,z mode
                px = healpy.vec2pix(self._nside, c1, c2, c3, nest=is_nest)
            return px
        else:
            if c3 is not None: # need to translate xyz to th/phi
                c1,c2 = healpy.vec2ang(np.array([c1,c2,c3]).T)
            px,wgts = healpy.get_interp_weights(self._nside, c1, c2, nest=is_nest)
            return px.T, wgts.T
    def px2crd(self, px, ncrd=3):
github CRPropa / CRPropa3 / python / crpropa / gamale.py View on Github external
def generateLensPart(fname, nside=64):
    """
    Generate a lens part from the given CRPropa 3 simulation.
    """
    f = np.genfromtxt(fname, names=True)
    row = healpy.vec2pix(nside, f['P0x'], f['P0y'], f['P0z']) # earth
    col = healpy.vec2pix(nside, f['Px'],  f['Py'],  f['Pz'] ) # galaxy
    npix = healpy.nside2npix(nside)
    data = np.ones(len(row))
    M = sparse.coo_matrix((data, (row, col)), shape=(npix, npix))
    M = M.tocsc()
    normalizeRowSum(M)
    return M