当前位置: 首页>>代码示例>>Python>>正文


Python healpy.ang2pix方法代码示例

本文整理汇总了Python中healpy.ang2pix方法的典型用法代码示例。如果您正苦于以下问题:Python healpy.ang2pix方法的具体用法?Python healpy.ang2pix怎么用?Python healpy.ang2pix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在healpy的用法示例。


在下文中一共展示了healpy.ang2pix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeHealpixMap

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def makeHealpixMap(ra, dec, nside=1024, nest=False):
    # convert a ra/dec catalog into healpix map with counts per cell
    import healpy as hp
    ipix = hp.ang2pix(nside, (90-dec)/180*np.pi, ra/180*np.pi, nest=nest)
    return np.bincount(ipix, minlength=hp.nside2npix(nside)) 
开发者ID:pmelchior,项目名称:skymapper,代码行数:7,代码来源:example1.py

示例2: __call__

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def __call__(self,j,jk,ra,dec):
        """
        NAME:
           __call__
        PURPOSE:
           Evaluate the selection function for multiple (J,J-Ks) 
           and single (RA,Dec)
        INPUT:
           j - apparent J magnitude
           jk - J-Ks color
           ra, dec - sky coordinates (deg)
        OUTPUT
           selection fraction
        HISTORY:
           2017-01-18 - Written - Bovy (UofT/CCA)
        """
        # Parse j, jk
        if isinstance(j,float):
            j= numpy.array([j])
        if isinstance(jk,float):
            jk= numpy.array([jk])
        # Parse RA, Dec
        theta= numpy.pi/180.*(90.-dec)
        phi= numpy.pi/180.*ra
        pix= healpy.ang2pix(_BASE_NSIDE,theta,phi,nest=True)
        if self._exclude_mask_skyonly[pix]:
            return numpy.zeros_like(j)
        jkbin= numpy.floor((jk-self._jkmin)\
                               /(self._jkmax-self._jkmin)*3.).astype('int')
        tjt= jt(jk,j)
        out= numpy.zeros_like(j)
        for ii in range(3):
            out[jkbin == ii]= self._sf_splines[ii](tjt[jkbin == ii])
        out[out < 0.]= 0.
        out[(j < self._jmin)+(j > self._jmax)]= 0.
        return out 
开发者ID:jobovy,项目名称:gaia_tools,代码行数:38,代码来源:tgasSelect.py

示例3: getCountAtLocations

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def getCountAtLocations(ra, dec, nside=512, per_area=True, return_vertices=False):
    """Get number density of objects from RA/Dec in HealPix cells.

    Args:
        ra: list of rectascensions
        dec: list of declinations
        nside: HealPix nside
        per_area: return counts in units of 1/arcmin^2
        return_vertices: whether to also return the boundaries of HealPix cells

    Returns:
        bc, ra_, dec_, [vertices]
        bc: count of objects in a HealPix cell if count > 0
        ra_: rectascension of the cell center (same format as ra/dec)
        dec_: declinations of the cell center (same format as ra/dec)
        vertices: (N,4,2), RA/Dec coordinates of 4 boundary points of cell
    """
    import healpy as hp
    # get healpix pixels
    ipix = hp.ang2pix(nside, (90-dec)/180*np.pi, ra/180*np.pi, nest=False)
    # count how often each pixel is hit
    bc = np.bincount(ipix)
    pixels = np.nonzero(bc)[0]
    bc = bc[bc>0]
    if per_area:
        bc = bc.astype('f8')
        bc /= hp.nside2resol(nside, arcmin=True)**2 # in arcmin^-2
    # get position of each pixel in RA/Dec
    theta, phi = hp.pix2ang(nside, pixels, nest=False)
    ra_ = phi*180/np.pi
    dec_ = 90 - theta*180/np.pi

    # get the vertices that confine each pixel
    # convert to RA/Dec (thanks to Eric Huff)
    if return_vertices:
        vertices = getHealpixVertices(pixels, nside)
        return bc, ra_, dec_, vertices
    return bc, ra_, dec_ 
开发者ID:pmelchior,项目名称:skymapper,代码行数:40,代码来源:healpix.py

示例4: reduceAtLocations

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def reduceAtLocations(ra, dec, value, reduce_fct=np.mean, nside=512, return_vertices=False):
    """Reduce values at given RA/Dec in HealPix cells to a scalar.

    Args:
        ra: list of rectascensions
        dec: list of declinations
        value: list of values to be reduced
        reduce_fct: function to operate on values in each cell
        nside: HealPix nside
        per_area: return counts in units of 1/arcmin^2
        return_vertices: whether to also return the boundaries of HealPix cells

    Returns:
        v, ra_, dec_, [vertices]
        v: reduction of values in a HealPix cell if count > 0
        ra_: rectascension of the cell center (same format as ra/dec)
        dec_: declinations of the cell center (same format as ra/dec)
        vertices: (N,4,2), RA/Dec coordinates of 4 boundary points of cell
    """
    import healpy as hp
    # get healpix pixels
    ipix = hp.ang2pix(nside, (90-dec)/180*np.pi, ra/180*np.pi, nest=False)
    # count how often each pixel is hit, only use non-empty pixels
    pixels = np.nonzero(np.bincount(ipix))[0]

    v = np.empty(pixels.size)
    for i in xrange(pixels.size):
        sel = (ipix == pixels[i])
        v[i] = reduce_fct(value[sel])

    # get position of each pixel in RA/Dec
    theta, phi = hp.pix2ang(nside, pixels, nest=False)
    ra_ = phi*180/np.pi
    dec_ = 90 - theta*180/np.pi

    # get the vertices that confine each pixel
    # convert to RA/Dec (thanks to Eric Huff)
    if return_vertices:
        vertices = getHealpixVertices(pixels, nside)
        return v, ra_, dec_, vertices
    return v, ra_, dec_ 
开发者ID:pmelchior,项目名称:skymapper,代码行数:43,代码来源:healpix.py

示例5: sky_within

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def sky_within(self, ra, dec, degin=False):
        """
        Test whether a sky position is within this region

        Parameters
        ----------
        ra, dec : float
            Sky position.

        degin : bool
            If True the ra/dec is interpreted as degrees, otherwise as radians.
            Default = False.

        Returns
        -------
        within : bool
            True if the given position is within one of the region's pixels.
        """
        sky = self.radec2sky(ra, dec)

        if degin:
            sky = np.radians(sky)

        theta_phi = self.sky2ang(sky)
        # Set values that are nan to be zero and record a mask
        mask = np.bitwise_not(np.logical_and.reduce(np.isfinite(theta_phi), axis=1))
        theta_phi[mask, :] = 0

        theta, phi = theta_phi.transpose()
        pix = hp.ang2pix(2**self.maxdepth, theta, phi, nest=True)
        pixelset = self.get_demoted()
        result = np.in1d(pix, list(pixelset))
        # apply the mask and set the shonky values to False
        result[mask] = False
        return result 
开发者ID:PaulHancock,项目名称:Aegean,代码行数:37,代码来源:regions.py

示例6: radec2pix

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def radec2pix(nside,ra,dec,nest=True):
	_,__=np.pi/2-np.deg2rad(dec),np.deg2rad(ra)
	return healpy.ang2pix(nside,_,__,nest=nest) 
开发者ID:segasai,项目名称:astrolibpy,代码行数:5,代码来源:my_healpy.py

示例7: array2healpix

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import ang2pix [as 别名]
def array2healpix(image_array, nside=16, max_iter=3, **kwargs):
    """Return a healpix ring-ordered map corresponding to a lat-lon map image array."""
    if hp is None:
        raise ImportError(
            "Please install the `healpy` Python package to "
            "enable this feature. See `https://healpy.readthedocs.io`."
        )

    # Starting value for the zoom
    zoom = 2

    # Keep track of the number of unseen pixels
    unseen = 1
    ntries = 0
    while unseen > 0:

        # Make the image bigger so we have good angular coverage
        image_array = ndimage.zoom(image_array, zoom)

        # Convert to a healpix map
        theta = np.linspace(0, np.pi, image_array.shape[0])[:, None]
        phi = np.linspace(-np.pi, np.pi, image_array.shape[1])[::-1]
        pix = hp.ang2pix(nside, theta, phi, nest=False)
        healpix_map = (
            np.ones(hp.nside2npix(nside), dtype=np.float64) * hp.UNSEEN
        )
        healpix_map[pix] = image_array

        # Count the unseen pixels
        unseen = np.count_nonzero(healpix_map == hp.UNSEEN)

        # Did we do this too many times?
        ntries += 1
        if ntries > max_iter:
            raise ValueError(
                "Maximum number of iterations exceeded. Either decreaser `nside` or increase `max_iter`."
            )

    return healpix_map 
开发者ID:rodluger,项目名称:starry,代码行数:41,代码来源:_sht.py


注:本文中的healpy.ang2pix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。