Healpy/Healpix: What is the relationship between the total pixels and total spherical harmonic coefficients?

1.7k views Asked by At

Based on the Healpy/Healpix documentation, I cannot understand the relationship between one pixel in a sky map (which is some measured value) and the spherical harmonic coefficients produced by Healpy's healpy.sphtfunc.map2alm function, which computes an array of the a_lm coefficients for a given map. (This question also applies to anafast.)

My understanding is that a given pixel should correspond to a spherical harmonic coefficient. However, it doesn't. At all.

Take a map with nside = 8. This program uses Healpy to read a CMB map in FITS format, manually set the nside value, read in the map, display it, and then calculate the spherical harmonic coefficients.

import math
import matplotlib.pyplot as plt 
import numpy as np
import healpy as hp
import pyfits as pf

filename = "cmb_map.fits"    # the name of the full-sky map 

readmap = hp.read_map(filename)   # readmap i.e. input map
nside = 8    # manually input the side value

''' 
Here outputs: 
NSIDE = 8
ORDERING = RING in fits file
'''

view = hp.mollview(readmap)  # view the map, i.e. display it
'''
Shows sky map of the CMB
'''

totalnumberpixels = hp.nside2npix(nside)
print totalnumberpixels      # For nside = 8, this should be 12*nside**2 = 768

arr = hp.map2alm(readmap)    # This is an array of a_lm values

So far so good. The hp.map2alm() function now returns 300 values, i.e. 300 spherical harmonic coefficients a_lm.

arr.shape

outputs " (300,) ".

Why would 768 pixels calculate to 300 a_lm values? Is there a mathematical relationship here between nside and total number of spherical harmonic coefficients? Does each nside give a distinct number of a_lm coefficients?

How many pixels does it take to calculate one a_lm? Any help/explanation is very appreciated!


EDIT: As discussed below, the total number of pixels is npix = 12*nside**2. map2alm uses the default lmax = 3*nside-1. So, the total number of spherical harmonic coefficients should be the sum of odd numbers up to 3*nside-1=23. The total number of spherical harmonic coefficients should be (2*lmax+1)**2 = (6*nside-1)**2. (2*lmax+1)^2=(2*23+1)^2 = (47)^2 = 2209. So, where is this number 300 coming from? What exactly is map2alm doing? How can this be simply an approximation?

I expect 2209 a_lm. I calculated 300.

2

There are 2 answers

6
Asen Christov On BEST ANSWER

there is no direct relation between a pixel and and the spherical harmonic coefficients.

you can imagine it like this: the map pixels are the data and the spherical harmonic functions you "fit" to the data. The spherical harmonic functions is a system of infinitely many (orthonormal) functions.

Now you do not "fit" infinitely many functions to the data (the pixels), there is limit, you set lmax or mmax or both. (the spherical harmonic functions are usually labelled/identified by two numbers, l and m).

l and m are integers and l goes from 0 to infinity and for each l, m goes from -m to m.

So for instance if lmax is 2 and no limit on m you are dealing with 1+3+5=9 functions. Therefore you will have 9 alm coefficients, (=the results of the "fit"), independently on how many pixels the map has.

Ok so far so good. Now, the spherical harmonics are complex functions, and the coefficients as well. But the maps is purely real. So when one reads on Spherical harmonics (Wikipedia is good enough) one will find how to define a real basis of spherical harmonics, basically using the property that Y_l,m=(-1)^m Y*_l,-m , where the star denotes a complex conj.

now if you use complex numbers as the parameters for the function of this basis, how many you need? For given l you will need l+1 complex numbers (remember we count from l=0). And if you sum up to given l you get:

l=0 --> 1
l=1 --> 1+2=3
l=2 --> 1+2+3=6
l=3 --> 1+2+3+4=10
etc.

(note if you sum up this up to 3*nside-1 you get 300 for nside 8)

also important is to note that for exactly l+1 of these complex coefficients their imaginary part will be zero! (the ones corresponding to Y_l0). Now if you count the number of independent parameters, example for l=3:

l=3 --> 1+2+3+4=10

so 10 complex numbers = 20 independent parameters. But 4 of them have only real part 20-4=16. Exactly what one expects, because the full imaginary Y_lm has 32 independent parameters, so the real part will have half of that.

2
JianguoHisiang On

So, as discussed above, the parameter l_max determines the number of spherical harmonic coefficients, a_{lm}. For the l parameter, the number of a's go from a_0 to a_{lmax}. The m parameter is determined by l_{max}, l_{max}-1, l_{max}-2, ...., -l_{max}+2, -l_{max}+1, -l_{max}.

So, the total number of m values per l is given by 2l+1, e.g. l=0 gives 1 m, l=1 gives 3 m's, l=2 gives 5 m's, etc.

The map2alm function used by Healpix/Healpy takes in the input parameter nside, and then as a default calculates the spherical harmonics using 3*nside-1.

However, nside also determines the total number of pixels per map. The total number of pixels npix is given by npix = 12*nside**2.

To review:

npix = 12 * nside ** 2

l_max = 3 * nside - 1

Therefore, the total number of spherical harmonic coefficients is the sum series of i=0 to i= 2 * lmax + 1. Using the default parameter for map2alm, this gives us a sum from i=0 to i = 6 * nside - 1 (i.e. 2(3*nside-1) + 1)

For a given map, the total number of pixels is 12 * nside ** 2 and the total number of spherical harmonic coefficients a_lm is the sum of i=0 to i= 6*nside-1.

Correct?