Healpy map2alm function does not return expected number of alm values

1k views Asked by At

healpy.map2alm computes an array of alm values for an input Healpix map.

The function is

healpy.sphtfunc.map2alm(maps, lmax=None, mmax=None, iter=3, pol=True, use_weights=False, regression=True, datapath=None)`

The parameter lmax determines the number of alm coefficients. One sets the input lmax and the code returns '(lmax+1)**2` number of alm coefficients.

l=0 returns a00.

l=1 returns a11, a10, a1-1 + a00, i.e. 4 coefficients.

l=2 returns a22, a21, a20, a2-1, a2-2, i.e. 5+3+1 = 9 coefficients. That is (lmax+1)**2 = 3**2 = 9 coefficients.

However, using healpy, this is NOT the output I get, irrespective on the map I chose.

import numpy as np
import healpy as hp
nside = 16                         # healpix nside parameter

filename = "cmb_fullsky_map.fits"  # generic name for sky map

readmap = hp.read_map(filename)    # read in the map

# We then use healpy.map2alm(readmap) to generate an array of alm values

ell0 = hp.map2alm(readmap, lmax = 0)    # lmax = 0 should output a00
ell0.shape                              # 1 value
print "l=0 has " + str(len(ell0))
print ell0

ell1 = hp.map2alm(readmap, lmax = 1)    # lmax = 1 should outputs
ell1.shape                              # a11, a10, a1-1 
print "l=1 has " + str(len(ell1))       # 3 values
print ell1

ell2 = hp.map2alm(readmap, lmax = 2)    # lmax = 2 should output
ell2.shape                              # a22, a21, a20, a2-1, a2-2
print "l=2 has " + str(len(ell2))       # 5 values
print ell2

ell3 = hp.map2alm(readmap, lmax = 3)    # lmax = 3 should output 
ell3.shape                              # a33, a32, a31, a30, a3-1, a3-2, a3-3
print "l=3 has " + str(len(ell3))       # 7 values
print ell3

ell4 = hp.map2alm(readmap, lmax = 4)    # lmax = 4 should output
ell4.shape                              # a44, a43, a42, a41, a40, a4-1, a4-2,
print "l=4 has " + str(len(ell4))       # a4-3 a4-4
print ell4                              # 9 values

ell32 = hp.map2alm(readmap, lmax = 32)  # lmax = 32 should output
ell32.shape                             # (lmax+1)**2 = 33**2 = 1089 coefficients
print "l=32 has " + str(len(ell32))     # 65 values

My output is not what I would expect by (lmax+1)**2.

l=0 has 1
[  2.39883065e-06+0.j]
l=1 has 3
[  2.39883065e-06 +0.00000000e+00j   4.49747594e-06 +0.00000000e+00j
  -5.39401197e-07 +1.07974023e-06j]
l=2 has 6
[  2.38695037e-06 +0.00000000e+00j   4.49747594e-06 +0.00000000e+00j
  -2.93559509e-05 +0.00000000e+00j  -5.39401197e-07 +1.07974023e-06j
  -1.75256654e-05 -1.57729954e-05j   1.65489261e-05 -1.41571515e-05j]
l=3 has 10
[  2.38695037e-06 +0.00000000e+00j   4.51148696e-06 +0.00000000e+00j
  -2.93559509e-05 +0.00000000e+00j   1.19817810e-05 +0.00000000e+00j
  -5.37909950e-07 +1.07783971e-06j  -1.75256654e-05 -1.57729954e-05j
  -7.17416081e-06 +9.14176685e-06j   1.65489261e-05 -1.41571515e-05j
  -2.64725172e-06 -3.09988314e-05j  -7.25462692e-06 -6.33251313e-07j]
l=4 has 15
[  2.38534350e-06 +0.00000000e+00j   4.51148696e-06 +0.00000000e+00j
  -2.93586471e-05 +0.00000000e+00j   1.19817810e-05 +0.00000000e+00j
  -1.72252485e-06 +0.00000000e+00j  -5.37909950e-07 +1.07783971e-06j
  -1.75253044e-05 -1.57728790e-05j  -7.17416081e-06 +9.14176685e-06j
  -1.30606717e-05 -4.21675061e-06j   1.65464103e-05 -1.41578955e-05j
  -2.64725172e-06 -3.09988314e-05j   1.09072312e-05 +3.22054569e-06j
  -7.25462692e-06 -6.33251313e-07j  -1.10079209e-06 +9.39495982e-07j
  -8.01588627e-06 -8.03762608e-06j]
l=32 has 561

Do you see the discrepancy?

For lmax=0, I expect a total of 1. healpy outputs 1

For lmax=1, I expect a total of 4. healpy outputs 3

For lmax=2, I expect a total of 9. healpy outputs 6

For lmax=3, I expect a total of 16. healpy outputs 10

For lmax=4, I expect a total of 25. healpy outputs 15

For lmax=32, I expect a total of 1089. healpy outputs 561

Question: Should I act together outputs in order to get the correct total number of arrays?

Please how map2alm executes this operation.

2

There are 2 answers

8
Andrea Zonca On BEST ANSWER

It is due to symmetry. m=-1 and m=1 have the same transform, so HEALPix considers only m>=0.

So for example lmax=2 we have:

  • a00
  • a10
  • a11
  • a20
  • a21
  • a22

6 coefficients total.

The length of the alm array is expected to be: mmax * (2 * lmax + 1 - mmax) / 2 + lmax + 1).

0
Patrick Adams On

I has also recently come across this problem. Healpix give all the positive m values. The negatives can be found with a(l,m1) = -a(l,-m)*, where * is the complex conjugate.