Example #1
0
def build_cmb_2d(shape, wcs, cl_cmb, dtype=np.float32):
    lmap = enmap.lmap(shape, wcs)
    l = np.sum(lmap**2, 0)**0.5
    cmb = enmap.samewcs(utils.interp(l, np.arange(cl_cmb.shape[-1]), cl_cmb),
                        l).astype(dtype)
    # Rotate [TEB,EB] -> [TQU,TQU]. FIXME: not a perfect match
    R = enmap.queb_rotmat(lmap, spin=2, inverse=True)
    cmb[1:, :] = np.einsum("abyx,bcyx->acyx", R, cmb[1:, :])
    cmb[:, 1:] = np.einsum("abyx,cbyx->acyx", cmb[:, 1:], R)
    return cmb
Example #2
0
def rotate_pol_power(shape,wcs,cov,iau=False,inverse=False):
    """Rotate a 2D power spectrum from TQU to TEB (inverse=False) or
    back (inverse=True). cov is a (3,3,Ny,Nx) 2D power spectrum.
    WARNING: This function is duplicated from orphics.maps to make 
    this module independent. Ideally, it should be implemented in
    enlib.enmap.
    """
    rot = np.zeros((3,3,cov.shape[-2],cov.shape[-1]))
    rot[0,0,:,:] = 1
    prot = enmap.queb_rotmat(enmap.lmap(shape,wcs), inverse=inverse, iau=iau)
    rot[1:,1:,:,:] = prot
    Rt = np.transpose(rot, (1,0,2,3))
    tmp = np.einsum("ab...,bc...->ac...",rot,cov)
    rp2d = np.einsum("ab...,bc...->ac...",tmp,Rt)    
    return rp2d