Exemple #1
0
def map2alm(m,lmax=None,mmax=None,iter=1,use_weights=False,regression=True):
    """Computes the alm of an Healpix map.

    Input:
      - m: a ndarray (not polarized) or a list of 3 ndarray (polarized)
    Parameters:
      - lmax : maximum l of the power spectrum. Default: 3*nside-1
      - mmax : maximum m of the alm. Default: lmax
      - iter : number of iteration (default: 1)
      - use_weights: whether to use ring weights or not. Default: False.
      - regression: if True, subtract map average before computing alm. Default: True.
    Return:
      - alm as one ndarray or a tuple of 3 ndarrays
    """
    datapath = DATAPATH #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3*nside-1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath+'/'+weightfile):
            raise IOError('File not found : '+datapath+'/'+weightfile)
    alm = sphtlib._map2alm(m,lmax=lmax,mmax=mmax,cl=False,
                           iter=iter,
                           use_weights=use_weights,data_path=datapath,regression=regression)
    return alm
Exemple #2
0
def anafast(m,lmax=None,mmax=None,iter=1,alm=False, use_weights=False, regression=True):
    """Computes the power spectrum of an Healpix map.

    Input:
      - m : either an array representing a map, or a list of 3 arrays
            representing I, Q, U maps
    Parameters:
      - lmax : maximum l of the power spectrum (default: 3*nside-1)
      - mmax : maximum m of the alm (default: lmax)
      - iter : number of iteration (default: 1)
      - alm : (boolean) whether to return alm or not (if True, both are
               returned in a tuple)
      - regression : if True, map average is removed before computing alm. Default: True.
    Return:
      - if alm==False: return cl or a list of cl's (TT,TE,EE,BB)
      - if alm==True: return a tuple with cl or a list of cl's and alm
                      or a list of alm's
    """
    datapath = DATAPATH #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3*nside-1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath+'/'+weightfile):
            raise IOError('File not found : '+datapath+'/'+weightfile)
    clout,almout = sphtlib._map2alm(m,lmax=lmax,mmax=mmax,iter=iter,cl=True,
                                    use_weights=use_weights,data_path=datapath,regression=regression)
    if alm:
        return (clout,almout)
    else:
        return clout
Exemple #3
0
def anafast(m,
            lmax=None,
            mmax=None,
            iter=1,
            alm=False,
            use_weights=False,
            regression=True):
    """Computes the power spectrum of an Healpix map.

    Parameters
    ----------
    m : float, array-like shape (Npix,) or (3, Npix)
      Either an array representing a map, or a sequence of 3 arrays
      representing I, Q, U maps
    lmax : int, scalar, optional
      Maximum l of the power spectrum (default: 3*nside-1)
    mmax : int, scalar, optional
      Maximum m of the alm (default: lmax)
    iter : int, scalar, optional
      Number of iteration (default: 1)
    alm : bool, scalar, optional
      If True, returns both cl and alm, otherwise only cl is returned
    regression : bool, scalar, optional
      If True, map average is removed before computing alm. Default: True.
    
    Returns
    -------
    res : array or sequence of arrays
      If *alm* is False, returns cl or a list of cl (TT, EE, BB, TE for
      polarized input map)
      Otherwise, returns a tuple (cl, alm), where cl is as above and
      alm is the spherical harmonic transform or a list of almT, almE, almB
      for polarized input
    """
    datapath = DATAPATH  #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3 * nside - 1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath + '/' + weightfile):
            raise IOError('File not found : ' + datapath + '/' + weightfile)
    # Replace UNSEEN pixels with zeros
    m[m == UNSEEN] = 0
    clout, almout = sphtlib._map2alm(m,
                                     lmax=lmax,
                                     mmax=mmax,
                                     iter=iter,
                                     cl=True,
                                     use_weights=use_weights,
                                     data_path=datapath,
                                     regression=regression)
    if alm:
        return (clout, almout)
    else:
        return clout
Exemple #4
0
def map2alm(m,
            lmax=None,
            mmax=None,
            iter=1,
            use_weights=False,
            regression=True):
    """Computes the alm of an Healpix map.

    Parameters
    ----------
    m : array-like, shape (Npix,) or (3, Npix)
      The input map or a list of 3 input maps (polariztion).
    lmax : int, scalar, optional
      Maximum l of the power spectrum. Default: 3*nside-1
    mmax : int, scalar, optional
      Maximum m of the alm. Default: lmax
    iter : int, scalar, optional
      Number of iteration (default: 1)
    use_weights: bool, scalar, optional
      If True, use the ring weighting. Default: False.
    regression: bool, scalar, optional
      If True, subtract map average before computing alm. Default: True.
    
    Returns
    -------
    alm : array or tuple of array
      alm or a tuple of 3 alm (almT, almE, almB) if polarized input.
    """
    datapath = DATAPATH  #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3 * nside - 1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Replace UNSEEN pixels with zeros
    m[m == UNSEEN] = 0
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath + '/' + weightfile):
            raise IOError('File not found : ' + datapath + '/' + weightfile)
    alm = sphtlib._map2alm(m,
                           lmax=lmax,
                           mmax=mmax,
                           cl=False,
                           iter=iter,
                           use_weights=use_weights,
                           data_path=datapath,
                           regression=regression)
    return alm
Exemple #5
0
def anafast(m,lmax=None,mmax=None,iter=1,alm=False, use_weights=False, regression=True):
    """Computes the power spectrum of an Healpix map.

    Parameters
    ----------
    m : float, array-like shape (Npix,) or (3, Npix)
      Either an array representing a map, or a sequence of 3 arrays
      representing I, Q, U maps
    lmax : int, scalar, optional
      Maximum l of the power spectrum (default: 3*nside-1)
    mmax : int, scalar, optional
      Maximum m of the alm (default: lmax)
    iter : int, scalar, optional
      Number of iteration (default: 1)
    alm : bool, scalar, optional
      If True, returns both cl and alm, otherwise only cl is returned
    regression : bool, scalar, optional
      If True, map average is removed before computing alm. Default: True.
    
    Returns
    -------
    res : array or sequence of arrays
      If *alm* is False, returns cl or a list of cl (TT, EE, BB, TE for
      polarized input map)
      Otherwise, returns a tuple (cl, alm), where cl is as above and
      alm is the spherical harmonic transform or a list of almT, almE, almB
      for polarized input
    """
    datapath = DATAPATH #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3*nside-1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath+'/'+weightfile):
            raise IOError('File not found : '+datapath+'/'+weightfile)
    # Replace UNSEEN pixels with zeros
    m[m == UNSEEN] = 0
    clout,almout = sphtlib._map2alm(m,lmax=lmax,mmax=mmax,iter=iter,cl=True,
                                    use_weights=use_weights,data_path=datapath,
                                    regression=regression)
    if alm:
        return (clout,almout)
    else:
        return clout
def anafast(m,
            lmax=None,
            mmax=None,
            iter=1,
            alm=False,
            use_weights=False,
            regression=True):
    """Computes the power spectrum of an Healpix map.

    Input:
      - m : either an array representing a map, or a list of 3 arrays
            representing I, Q, U maps
    Parameters:
      - lmax : maximum l of the power spectrum (default: 3*nside-1)
      - mmax : maximum m of the alm (default: lmax)
      - iter : number of iteration (default: 1)
      - alm : (boolean) whether to return alm or not (if True, both are
               returned in a tuple)
      - regression : if True, map average is removed before computing alm. Default: True.
    Return:
      - if alm==False: return cl or a list of cl's (TT,EE,BB,TE)
      - if alm==True: return a tuple with cl or a list of cl's and alm
                      or a list of alm's
    """
    datapath = DATAPATH  #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3 * nside - 1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath + '/' + weightfile):
            raise IOError('File not found : ' + datapath + '/' + weightfile)
    clout, almout = sphtlib._map2alm(m,
                                     lmax=lmax,
                                     mmax=mmax,
                                     iter=iter,
                                     cl=True,
                                     use_weights=use_weights,
                                     data_path=datapath,
                                     regression=regression)
    if alm:
        return (clout, almout)
    else:
        return clout
Exemple #7
0
def map2alm(m,lmax=None,mmax=None,iter=1,use_weights=False,regression=True):
    """Computes the alm of an Healpix map.

    Parameters
    ----------
    m : array-like, shape (Npix,) or (3, Npix)
      The input map or a list of 3 input maps (polariztion).
    lmax : int, scalar, optional
      Maximum l of the power spectrum. Default: 3*nside-1
    mmax : int, scalar, optional
      Maximum m of the alm. Default: lmax
    iter : int, scalar, optional
      Number of iteration (default: 1)
    use_weights: bool, scalar, optional
      If True, use the ring weighting. Default: False.
    regression: bool, scalar, optional
      If True, subtract map average before computing alm. Default: True.
    
    Returns
    -------
    alm : array or tuple of array
      alm or a tuple of 3 alm (almT, almE, almB) if polarized input.
    """
    datapath = DATAPATH #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3*nside-1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Replace UNSEEN pixels with zeros
    m[m == UNSEEN] = 0
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath+'/'+weightfile):
            raise IOError('File not found : '+datapath+'/'+weightfile)
    alm = sphtlib._map2alm(m,lmax=lmax,mmax=mmax,cl=False,
                           iter=iter,
                           use_weights=use_weights,data_path=datapath,
                           regression=regression)
    return alm
def map2alm(m,
            lmax=None,
            mmax=None,
            iter=1,
            use_weights=False,
            regression=True):
    """Computes the alm of an Healpix map.

    Input:
      - m: a ndarray (not polarized) or a list of 3 ndarray (polarized)
    Parameters:
      - lmax : maximum l of the power spectrum. Default: 3*nside-1
      - mmax : maximum m of the alm. Default: lmax
      - iter : number of iteration (default: 1)
      - use_weights: whether to use ring weights or not. Default: False.
      - regression: if True, subtract map average before computing alm. Default: True.
    Return:
      - alm as one ndarray or a tuple of 3 ndarrays
    """
    datapath = DATAPATH  #os.path.dirname(__file__)+'/data'
    nside = _get_nside(m)
    if lmax is None:
        lmax = 3 * nside - 1
    if mmax is None or mmax < 0 or mmax > lmax:
        mmax = lmax
    # Check the presence of weights file
    if use_weights:
        weightfile = 'weight_ring_n%05d.fits' % (nside)
        if not os.path.isfile(datapath + '/' + weightfile):
            raise IOError('File not found : ' + datapath + '/' + weightfile)
    alm = sphtlib._map2alm(m,
                           lmax=lmax,
                           mmax=mmax,
                           cl=False,
                           iter=iter,
                           use_weights=use_weights,
                           data_path=datapath,
                           regression=regression)
    return alm