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


Python healpy.pix2ang方法代码示例

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


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

示例1: __init__

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def __init__(self,comp=1.,ramin=None,ramax=None,keepexclude=False,
                 **kwargs):
        self._comp= comp
        if ramin is None: self._ramin= -1.
        else: self._ramin= ramin
        if ramax is None: self._ramax= 361.
        else: self._ramax= ramax
        gaia_tools.select.tgasSelect.__init__(self,**kwargs)
        if not keepexclude:
            self._exclude_mask_skyonly[:]= False
        if not ramin is None:
            theta,phi= healpy.pix2ang(2**5,
                                      numpy.arange(healpy.nside2npix(2**5)),
                                      nest=True)
            ra= 180./numpy.pi*phi
            self._exclude_mask_skyonly[(ra < ramin)+(ra > ramax)]= True
        return None 
开发者ID:jobovy,项目名称:gaia_tools,代码行数:19,代码来源:tgasSelect.py

示例2: mapFromClm

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def mapFromClm(clm, nside):
    """
    Given an array of C_{lm} values, produce a pixel-power-map (non-Nested) for
    healpix pixelation with nside

    @param clm:     Array of C_{lm} values (inc. 0,0 element)
    @param nside:   Nside of the healpix pixelation

    return:     Healpix pixels

    Use real_sph_harm for the map
    """
    npixels = hp.nside2npix(nside)
    pixels = hp.pix2ang(nside, np.arange(npixels), nest=False)

    h = np.zeros(npixels)

    ind = 0
    maxl = int(np.sqrt(len(clm))) - 1
    for ll in range(maxl + 1):
        for mm in range(-ll, ll + 1):
            h += clm[ind] * real_sph_harm(mm, ll, pixels[1], pixels[0])
            ind += 1

    return h 
开发者ID:nanograv,项目名称:enterprise,代码行数:27,代码来源:anis_coefficients.py

示例3: clmFromMap

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def clmFromMap(h, lmax):
    """
    Given a pixel map, and a maximum l-value, return the corresponding C_{lm}
    values.

    @param h:       Sky power map
    @param lmax:    Up to which order we'll be expanding

    return: clm values

    Use real_sph_harm for the map
    """
    npixels = len(h)
    nside = hp.npix2nside(npixels)
    pixels = hp.pix2ang(nside, np.arange(npixels), nest=False)

    clm = np.zeros((lmax + 1) ** 2)

    ind = 0
    for ll in range(lmax + 1):
        for mm in range(-ll, ll + 1):
            clm[ind] += np.sum(h * real_sph_harm(mm, ll, pixels[1], pixels[0]))
            ind += 1

    return clm * 4 * np.pi / npixels 
开发者ID:nanograv,项目名称:enterprise,代码行数:27,代码来源:anis_coefficients.py

示例4: pix2vert

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def pix2vert(nside,ipix,nest=False):
		"""
		NAME:
		   pix2vert
		PURPOSE:
		   calculate the locations of the vertices (theta,phi)
		   of a given HEALPix pixel
		INPUT:
		   nside - HEALPix resolution parameter
		   ipix - pixel number
		   nest - if True, use NESTED scheme (default: RING)
		OUTPUT:
		   numpy.array([4,2]) theta,phi [rad] NWSE
		HISTORY:
		   2010-01-21 - Written - Bovy (NYU)
		"""
		(centerTheta,centerPhi)= healpy.pix2ang(nside,ipix,nest=nest)
		#Are we in the polar regime or in the equatorial regime?
		z= sc.cos(centerTheta)
		if z > -2./3. and z < 2./3.:
			return bovy_healpy._ang2vert_eq(nside,centerTheta,centerPhi,z)
		else:
			return bovy_healpy._ang2vert(nside,centerTheta,centerPhi,z) 
开发者ID:segasai,项目名称:astrolibpy,代码行数:25,代码来源:healmap.py

示例5: _setup_skyonly

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def _setup_skyonly(self,min_nobs,max_nobs_std,max_plxerr,max_scd,min_lat):
        self._tgas_sid= (self._full_tgas['source_id']/2**(35.\
                               +2*(12.-numpy.log2(_BASE_NSIDE)))).astype('int')
        self._tgas_sid_skyonlyindx= (self._full_jk > 0.)\
            *(self._full_jk < 0.8)\
            *(self._full_twomass['j_mag'] > 6.)\
            *(self._full_twomass['j_mag'] < 10.)
        nstar, e= numpy.histogram(self._tgas_sid[self._tgas_sid_skyonlyindx],
                                  range=[-0.5,_BASE_NPIX-0.5],bins=_BASE_NPIX)
        self._nstar_tgas_skyonly= nstar
        self._nobs_tgas_skyonly= self._compute_mean_quantity_tgas(\
            'astrometric_n_good_obs_al',lambda x: x/9.)
        self._nobsstd_tgas_skyonly= numpy.sqrt(\
            self._compute_mean_quantity_tgas(\
                'astrometric_n_good_obs_al',lambda x: (x/9.)**2.)
            -self._nobs_tgas_skyonly**2.)
        self._scank4_tgas_skyonly= self._compute_mean_quantity_tgas(\
            'scan_direction_strength_k4')
        self._plxerr_tgas_skyonly= self._compute_mean_quantity_tgas(\
            'parallax_error')
        tmp_decs, ras= healpy.pix2ang(_BASE_NSIDE,numpy.arange(_BASE_NPIX),
                                      nest=True)
        coos= apco.SkyCoord(ras,numpy.pi/2.-tmp_decs,unit="rad")
        coos= coos.transform_to(apco.GeocentricTrueEcliptic)
        self._eclat_skyonly= coos.lat.to('deg').value
        self._exclude_mask_skyonly= \
            (self._nobs_tgas_skyonly < min_nobs)\
            +(self._nobsstd_tgas_skyonly > max_nobs_std)\
            +(numpy.fabs(self._eclat_skyonly) < min_lat)\
            +(self._plxerr_tgas_skyonly > max_plxerr)\
            +(self._scank4_tgas_skyonly > max_scd)
        return None 
开发者ID:jobovy,项目名称:gaia_tools,代码行数:34,代码来源:tgasSelect.py

示例6: getHealpixCoords

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def getHealpixCoords(pixels, nside, nest=False):
    # convert healpix cell indices to center ra/dec
    import healpy as hp
    theta, phi = hp.pix2ang(nside, pixels, nest=nest)
    return phi * 180. / np.pi, 90 - theta * 180. / np.pi 
开发者ID:pmelchior,项目名称:skymapper,代码行数:7,代码来源:example1.py

示例7: getGrid

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def getGrid(nside, nest=False, return_vertices=False):
    pixels = np.arange(hp.nside2npix(nside))
    theta, phi = hp.pix2ang(nside, pixels, nest=nest)
    ra = phi*180/np.pi
    dec = 90 - theta*180/np.pi
    if return_vertices:
        vertices = getHealpixVertices(pixels, nside, nest=nest)
        return pixels, ra, dec, vertices
    return pixels, ra, dec 
开发者ID:pmelchior,项目名称:skymapper,代码行数:11,代码来源:healpix.py

示例8: getCountAtLocations

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [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

示例9: reduceAtLocations

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [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

示例10: grid_s2

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def grid_s2(resol):
    Nside = 2**resol
    Npix = 12*Nside*Nside
    theta, phi = hp.pix2ang(Nside, np.arange(Npix), nest=True)
    return theta, phi 
开发者ID:zhonge,项目名称:cryodrgn,代码行数:7,代码来源:so3_grid.py

示例11: get_s2_neighbor

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def get_s2_neighbor(mini, curr_res):
    '''
    Return the 4 nearest neighbors on S2 at the next resolution level
    '''
    Nside = 2**(curr_res+1)
    ind = np.arange(4)+4*mini
    return hp.pix2ang(Nside, ind, nest=True), ind 
开发者ID:zhonge,项目名称:cryodrgn,代码行数:9,代码来源:so3_grid.py

示例12: anis_basis

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def anis_basis(psr_locs, lmax, nside=32):
    """
    Calculate the correlation basis matrices using the pixel-space
    transormations

    @param psr_locs:    Location of the pulsars [phi, theta]
    @param lmax:        Maximum l to go up to
    @param nside:       What nside to use in the pixelation [32]

    Note: GW directions are in direction of GW propagation
    """
    pphi = psr_locs[:, 0]
    ptheta = psr_locs[:, 1]

    # Create the pixels
    npixels = hp.nside2npix(nside)
    pixels = hp.pix2ang(nside, np.arange(npixels), nest=False)
    gwtheta = pixels[0]
    gwphi = pixels[1]

    # Create the signal response matrix
    F_e = signalResponse_fast(ptheta, pphi, gwtheta, gwphi)

    # Loop over all (l,m)
    basis = []
    nclm = (lmax + 1) ** 2
    clmindex = 0
    for ll in range(0, lmax + 1):
        for mm in range(-ll, ll + 1):
            clm = np.zeros(nclm)
            clm[clmindex] = 1.0

            basis.append(getCov(clm, nside, F_e))
            clmindex += 1

    return np.array(basis) 
开发者ID:nanograv,项目名称:enterprise,代码行数:38,代码来源:anis_coefficients.py

示例13: orfFromMap_fast

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import pix2ang [as 别名]
def orfFromMap_fast(psr_locs, usermap, response=None):
    """
    Calculate an ORF from a user-defined sky map.

    @param psr_locs:    Location of the pulsars [phi, theta]
    @param usermap:     Provide a healpix map for GW power

    Note: GW directions are in direction of GW propagation
    """
    if response is None:
        pphi = psr_locs[:, 0]
        ptheta = psr_locs[:, 1]

        # Create the pixels
        nside = hp.npix2nside(len(usermap))
        npixels = hp.nside2npix(nside)
        pixels = hp.pix2ang(nside, np.arange(npixels), nest=False)
        gwtheta = pixels[0]
        gwphi = pixels[1]

        # Create the signal response matrix
        F_e = signalResponse_fast(ptheta, pphi, gwtheta, gwphi)
    elif response is not None:
        F_e = response

    # Double the power (one for each polarization)
    sh = np.array([usermap, usermap]).T.flatten()

    # Create the cross-pulsar covariance
    hdcov_F = np.dot(F_e * sh, F_e.T)

    # The pulsar term is added (only diagonals: uncorrelated)
    return hdcov_F + np.diag(np.diag(hdcov_F)) 
开发者ID:nanograv,项目名称:enterprise,代码行数:35,代码来源:anis_coefficients.py

示例14: pix2radec

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


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