SHTns
2.6.5
|
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) :
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.
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 for a SH description is simply done with :
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).
Several normalizations for the spherical harmonics exist (details on wikipedia). SHTns lets you choose one of the following :
Orthonormalized is the default (also used in the GSL)
Four-pi normalized
Schmidt semi-normalized
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 :
which includes the Condon-Shortley phase by default.
For reference, function SH_to_point gives a simple explicit implementation of the inverse SH transform (synthesis).
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.
where and are the following normalization factor:
If you have problems in getting your spherical harmonic coefficient right, you may check the following :