title: Healpy/Healpix: What is the relationship between the total pixels and total spherical harmonic coefficients?
body: <p>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 <code>healpy.sphtfunc.map2alm</code> function, which computes an array of the a_lm coefficients for a given map. (This question also applies to anafast.)</p>
  
  <p>My understanding is that a given pixel should correspond to a spherical harmonic coefficient. However, it doesn't. At all. </p>
  
  <p>Take a map with <code>nside = 8</code>. This program uses Healpy to read a CMB map in FITS format, manually set the <code>nside</code> value, read in the map, display it, and then calculate the spherical harmonic coefficients. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>So far so good. The <code>hp.map2alm()</code> function now returns 300 values, i.e. 300 spherical harmonic coefficients a_lm. </p>
  
  <pre><code>arr.shape
  </code></pre>
  
  <p>outputs " (300,) ". </p>
  
  <p>Why would 768 pixels calculate to 300 a_lm values? Is there a mathematical relationship here between <code>nside</code> and total number of spherical harmonic coefficients? Does each <code>nside</code> give a distinct number of a_lm coefficients? </p>
  
  <p>How many pixels does it take to calculate one a_lm? Any help/explanation is very appreciated!</p>
  
  <hr>
  
  <p>EDIT: 
  As discussed below, the total number of pixels is <code>npix = 12*nside**2</code>. <code>map2alm</code> uses the default <code>lmax = 3*nside-1</code>. So, the total number of spherical harmonic coefficients should be the sum of odd numbers up to <code>3*nside-1=23</code>. 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 <code>map2alm</code> doing? How can this be simply an approximation? </p>
  
  <p>I expect 2209 a_lm. I calculated 300. </p>