SHTns  2.6.5
Spherical Harmonics storage and normalization

Spherical Harmonic coefficients layout

The collection of Alm (spherical harmonics coefficient of degree l and order m) is stored in an array of complex double floating point values. The spherical harmonic truncation is defined by a call to shtns_init or to shtns_create which returns an shtns_cfg object (pointer to shtns_info) from which the the size of the array, shtns_info::nlm, can be read (see examples).

The field A is decomposed on the basis of spherical harmonics Ylm (degree l, order m) :

\[ A(\theta,\phi) = \sum_{l,m} A_l^m Y_l^m(\theta,\phi)\]

The series is truncated at degree LMAX and order MMAX*MRES, and only order that are multiple of MRES are described.

The NLM coefficients Alm are stored in a one-dimensional array, grouped by m.
The details of the storage may depend on the algorithm, and to access a particular coefficient, you should always use the following macros :

Hence Alm[LM(l,m)] is the (complex) SH coefficient of degree l and order m.

Note
Since SHTns only deals with real spatial data, the Spherical Harmonic coefficients with negative m are related to the complex conjugate of the positive m coefficients : $ A_l^{-m} = (-1)^{m} (A_l^m)^*$. For efficiency purposes, only the coefficients with positive m are stored.
There is no test on bounds, so that LM(l,m) with l or m that is not described, will give undefined result (in particular for an m that is not a multiple of MRES)

To perform loops on all coefficients, use the macros LM_LOOP and LM_L_LOOP in combination of the arrays shtns_info::li which give the degree l and functions of it for any array index.

Allocation

Allocation for a SH description is simply done with :

Alm = fftw_malloc( NLM * sizeof(complex double) );

The use of fftw_malloc ensures proper alignment of data for SSE vectorization (if fftw has been properly compiled with –enable-sse2 or –enable-avx).

Normalization

Several normalizations for the spherical harmonics exist (details on wikipedia). SHTns lets you choose one of the following :

shtns_init uses the default (defined by SHT_DEFAULT_NORM) but you can choose another normalization by calling shtns_create instead.

The Legendre associated functions are defined by :

\[ P_l^m (x) = (-1)^m\ (1-x^2)^{m/2}\ \frac{d^m}{dx^m}P_l(x) \]

which includes the Condon-Shortley phase $ (-1)^m $ by default.

For reference, function SH_to_point gives a simple explicit implementation of the inverse SH transform (synthesis).

Normalization variations

Use shtns_create with SHT_NO_CS_PHASE to disable the Condon-Shortley phase. For example, to initialize a Schmidt semi-normalized transform of maximum degree 16 without Condon-Shortrley phase, use

By default, SHTns uses "complex" spherical harmonic normalization. However, as it deals only with real functions, the m<0 coefficients are not stored, since they are complex conjugate of the m>0 ones. Thus, one must pay attention, that the m>0 coefficient have to be counted twice in a total energy calculation.

An alternative to this "complex" normalization is the "real" normalization, for which the energy is simply the sum of the coefficients (m>=0) squared. Use shtns_create with SHT_REAL_NORM to use a "real" spherical harmonic normalization. This is the usual "real" spherical harmonics, if one takes the complex conjugate of the coefficients.

A few useful examples, for orthonormal spherical harmonics :

The functions sh00_1(), sh10_ct(), sh11_st() shlm_e1() will help to build simple spectral fields, no matter what normalization you choose.

Energy

Note
The energy of a scalar field can be retrieved from it's spherical harmonic representation as:

\[ \int ||q||^2 = \sum_{l,m \geq 0} C_m N_l \: |Q_l^m|^2 \]

where $ C_m $ and $ N_l $ are the following normalization factor:

Troubleshooting

If you have problems in getting your spherical harmonic coefficient right, you may check the following :