Example #1
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 #2
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