Example #1
0
def bpcl_term(lmax, s1, s2, w12, blm1, blm2, cltt):
    # "beam pseudo-cl term": implementation of Eq.~B3 from
    # arxiv:1003.0198, for fixed s1, s2

    blm1_lmax = blm1.shape[0] - 1
    blm2_lmax = blm1.shape[0] - 1
    cltt_lmax = len(cltt) - 1
    w12_lmax = len(w12) - 1

    lmin = np.max([abs(s1), abs(s2)])
    l1max = w12_lmax
    l2max = np.min([blm1_lmax, blm2_lmax, cltt_lmax])

    # get gauss legendre points and weights.
    ngl = (l1max + l2max + lmax) / 2 + 1
    glq = maths.gauss_legendre_quadrature(int(ngl))

    # prepare spectra
    twolpo = 2. * np.arange(0, max(l1max, l2max) + 1) + 1.

    def blm_pm(blm, l, m):
        if m < 0:
            return (-1)**m * np.conj(blm[l, -m])
        else:
            return blm[l, m]

    blv = np.zeros(l2max + 1, dtype=np.complex)
    blv[lmin:(l2max + 1)] = [
        blm_pm(blm1, l, -s1) * np.conj(blm_pm(blm2, l, -s2)) * cltt[l]
        for l in xrange(lmin, l2max + 1)
    ]

    if s1 == s2 == 0:
        # treat this term (which is generally quite large compared to other terms)
        # as a special case, to avoid numerical issues.
        w12_l0 = w12[0]
        w12 = np.copy(w12[:])
        w12[0] = 0.0

    # do l sums.
    cf1 = glq.cf_from_cl(s1, s2, w12[:] * twolpo[0:(l1max + 1)])
    cf2 = glq.cf_from_cl(-s1, -s2, blv[:] * twolpo[0:(l2max + 1)])

    # do z integral.
    ret = glq.cl_from_cf(lmax, 0, 0, cf1 * cf2)
    ret *= 1. / (8. * np.pi)

    if s1 == s2 == 0:
        ret += np.array([
            blm1[l, 0] * blm2[l, 0] * cltt[l] * w12_l0 / (4. * np.pi)
            for l in xrange(0, lmax + 1)
        ],
                        dtype=np.complex)

    return ret
Example #2
0
def ruzeblm(lmax, freq, lc, rms):
    import gauss_hermite
    assert(lmax >= 0)

    glq = maths.gauss_legendre_quadrature(lmax+1)
    blm = np.zeros( (lmax+1, 1), dtype=np.complex )

    val, gain = gauss_hermite.ruzeval( np.arccos(glq.zvec) * 180.*60./np.pi, freq, lc, rms )
    blm[:,0] = glq.cl_from_cf( lmax, 0, 0, val )

    lfac = np.array( [(2.*l+1.)/(4.*np.pi) for l in xrange(0, lmax+1)] )
    blm[:,0] *= (2.*np.pi)

    return blm
Example #3
0
def ruzeblm(lmax, freq, lc, rms):
    import gauss_hermite
    assert (lmax >= 0)

    glq = maths.gauss_legendre_quadrature(lmax + 1)
    blm = np.zeros((lmax + 1, 1), dtype=np.complex)

    val, gain = gauss_hermite.ruzeval(
        np.arccos(glq.zvec) * 180. * 60. / np.pi, freq, lc, rms)
    blm[:, 0] = glq.cl_from_cf(lmax, 0, 0, val)

    lfac = np.array([(2. * l + 1.) / (4. * np.pi)
                     for l in xrange(0, lmax + 1)])
    blm[:, 0] *= (2. * np.pi)

    return blm
Example #4
0
def bpcl_term(lmax, s1, s2, w12, blm1, blm2, cltt):
    # "beam pseudo-cl term": implementation of Eq.~B3 from
    # arxiv:1003.0198, for fixed s1, s2

    blm1_lmax = blm1.shape[0]-1
    blm2_lmax = blm1.shape[0]-1
    cltt_lmax = len(cltt) - 1
    w12_lmax  = len(w12) - 1

    lmin   = np.max( [abs(s1), abs(s2)] )
    l1max  = w12_lmax
    l2max  = np.min([blm1_lmax, blm2_lmax, cltt_lmax])

    # get gauss legendre points and weights.
    ngl = (l1max + l2max + lmax)/2 + 1
    glq = maths.gauss_legendre_quadrature( int(ngl) )

    # prepare spectra
    twolpo = 2.*np.arange(0, max(l1max, l2max)+1) + 1.

    def blm_pm(blm, l, m):
        if m < 0:
            return (-1)**m * np.conj(blm[l,-m])
        else:
            return blm[l,m]

    blv = np.zeros(l2max+1, dtype=np.complex)
    blv[lmin:(l2max+1)] = [ blm_pm(blm1, l, -s1) * np.conj(blm_pm(blm2, l, -s2)) * cltt[l] for l in xrange(lmin,l2max+1)]

    if s1 == s2 == 0:
        # treat this term (which is generally quite large compared to other terms)
        # as a special case, to avoid numerical issues.
        w12_l0 = w12[0]; w12 = np.copy(w12[:]); w12[0] = 0.0

    # do l sums.
    cf1 = glq.cf_from_cl(  s1,  s2, w12[:]*twolpo[0:(l1max+1)] )
    cf2 = glq.cf_from_cl( -s1, -s2, blv[:]*twolpo[0:(l2max+1)] )

    # do z integral.
    ret  = glq.cl_from_cf(lmax, 0, 0, cf1*cf2)
    ret *= 1./(8.*np.pi)

    if s1 == s2 == 0:
        ret += np.array([blm1[l,0] * blm2[l,0] * cltt[l] * w12_l0 / (4.*np.pi) for l in xrange(0, lmax+1)], dtype=np.complex)
    
    return ret
Example #5
0
def calc_cl_lensed(lmax, cl, dcl_g, dcl_c=None, do_r=True):
    """ calculates the first-order lensed temperature cl,
    for a lensing deflection field with (gradient,curl)
    power spectra given by (dcl_g, dcl_c).
        * by default the curl spectrum is zero
        * set do_r=False to neglect the term originating
        from the 2nd derivatve (eq. 4.13 of arxiv:0601594).
    """

    if dcl_c == None: dcl_c = np.zeros(len(dcl_g))
    assert (len(dcl_g) == len(dcl_c))

    lmax_cl = len(cl) - 1
    lmax_dd = len(dcl_g) - 1

    dcl_p = dcl_g + dcl_c
    dcl_m = dcl_g - dcl_c

    ngl = (lmax + lmax_cl + lmax_dd) / 2 + 1
    glq = maths.gauss_legendre_quadrature(int(ngl))

    ls = np.arange(0, np.max([lmax_cl, lmax_dd, lmax]) + 1)
    llpo = ls * (ls + 1.)
    twolpo = 2. * ls + 1.

    cf_p_cl = glq.cf_from_cl(
        1, 1, cl * twolpo[0:(lmax_cl + 1)] * llpo[0:(lmax_cl + 1)])
    cf_p_dd = glq.cf_from_cl(-1, -1, dcl_p * twolpo[0:(lmax_dd + 1)])

    cf_m_cl = glq.cf_from_cl(
        1, -1, cl * twolpo[0:(lmax_cl + 1)] * llpo[0:(lmax_cl + 1)])
    cf_m_dd = glq.cf_from_cl(-1, 1, dcl_m * twolpo[0:(lmax_dd + 1)])

    ret = glq.cl_from_cf(lmax, 0, 0, cf_p_cl * cf_p_dd + cf_m_cl * cf_m_dd)
    ret *= 1. / (16. * np.pi)

    ret += cl
    if do_r:
        rd = np.sum(twolpo[0:(lmax_dd + 1)] * dcl_p) / (8. * np.pi)
        ret -= cl * llpo[0:(lmax + 1)] * rd

    return ret