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


Python healpy.nside2npix方法代码示例

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


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

示例1: __init__

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

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import nside2npix [as 别名]
def save_as_image(region, filename):
    """
    Convert a MIMAS region (.mim) file into a image (eg .png)

    Parameters
    ----------
    region : :class:`AegeanTools.regions.Region`
        Region of interest.

    filename : str
        Output filename.
    """
    import healpy as hp
    pixels = list(region.get_demoted())
    order = region.maxdepth
    m = np.arange(hp.nside2npix(2**order))
    m[:] = 0
    m[pixels] = 1
    hp.write_map(filename, m, nest=True, coord='C')
    return 
开发者ID:PaulHancock,项目名称:Aegean,代码行数:22,代码来源:MIMAS.py

示例3: mapFromClm

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

示例4: makeHealpixMap

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

示例5: getGrid

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

示例6: anis_basis

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

示例7: orfFromMap_fast

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

示例8: array2healpix

# 需要导入模块: import healpy [as 别名]
# 或者: from healpy import nside2npix [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.nside2npix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。