Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions enmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,20 @@ def rotate_pol(emap, angle, comps=[-2,-1]):
res[...,comps[1],:,:] = s*emap[...,comps[0],:,:] + c*emap[...,comps[1],:,:]
return res

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.
"""
rot = np.zeros((3,3,cov.shape[-2],cov.shape[-1]))
rot[0,0,:,:] = 1
prot = queb_rotmat(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


def map_mul(mat, vec):
"""Elementwise matrix multiplication mat*vec. Result will have
the same shape as vec. Multiplication happens along the first indices.
Expand Down