title | keywords | sidebar | permalink | summary | toc |
---|---|---|---|---|---|
Implementation details |
spherical harmonics software package, spherical harmonic transform, legendre functions, multitaper spectral analysis, fortran, Python, gravity, magnetic field |
mydoc_sidebar |
implementation-details.html |
The spherical harmonic transforms in SHTOOLS make use of integrations over longitude that involve fast Fourier transforms and integrations over latitude that utilize either Gauss-Legendre quadrature or exact quadrature rules for regularly spaced grids. The transforms and reconstructions are accurate to about degree 2800. |
true |
If the spherical harmonic coefficients of a function
\begin{equation} f\left(\theta,\phi\right) = \sum_{l=0}^{L} \sum_{m=-l}^l f_{lm} , Y_{lm}\left(\theta,\phi \right). \end{equation}
Using the separate variables
$$ \begin{equation} f\left(\theta,\phi\right) = \sum_{m=0}^L \sum_{l=m}^{L} \left( C_{lm} , \bar{P}{lm}(\cos \theta) , \cos m\phi + S{lm} , \bar{P}_{lm}(\cos \theta) , \sin m\phi\right). \end{equation} $$
Defining the two component vector
The function
For a given latitude band, the function
The coefficients
The spherical harmonic coefficients of a function can be calculated from the relation
Defining the two intermediary variables
it is seen that for a given colatitude
$$ \begin{equation} \left[C_{lm}, S_{lm}\right] = \frac{1}{4 \pi} \sum_{i=1}^N w_i , \bar{P}{lm}(\cos \theta_i) \left[c{lm}^{(i)}, s_{lm}^{(i)}\right]. \label{eq:quadrature} \end{equation} $$
Here,
It is possible to choose the weights
Acronym | Name | Shape ( |
|
---|---|---|---|
DH | Driscoll and Healy | ||
DH2 | Driscoll and Healy | ||
GLQ | Gauss-Legendre Quadrature |
For the case of Gauss-Legendre quadrature (GLQ
), the quadrature is exact when the function
The second type of grid is for data that are sampled on regular grids. As shown by Driscoll and Healy [1994], an exact quadrature exists when the function DH
), the grids make use of the longitude band at 90$$^{\circ}$$ N, but not 90$$^{\circ}$$ S, and the number of samples is
For geographic data, it is common to work with grids that are equally spaced in degrees latitude and longitude. SHTOOLS provides the option of using grids of size DH2
), the coefficients
{% include image.html file="grids.png" alt="Spherical harmonic grid formats" caption="Figure 1. Schematic diagram illustrating the properties of the grids used with the Gauss-Legendre quadrature and Driscoll and Healy routines in SHTOOLS." %}
To test the accuracy of the spherical harmonic transforms and reconstructions,
two sets of synthetic spherical harmonic coefficients were created. Each
coefficient was chosen to be a random Gaussian distributed number with unit
variance, and the coefficients were then scaled such that the power spectrum
was proportional to either
{% include image.html file="relative-errors.png" alt="Relative errors of the spherical harmonic coefficients" caption="Figure 2. Maximum and rms relative errors of the spherical harmonic coefficients as a function of spherical harmonic bandwidth following a reconstruction of the function in the space domain and a subsequent spherical harmonic transform." %}
The errors associated with the transform and inverse pair increase in an quasi-exponential manner, with the maximum relative error being approximately 1 part in a billion for degrees close to 400, and about 1 part in
a million for degrees close to 2600. Though the errors are negligible to about
degree 2600, they then grow somewhat between degrees 2700 and 2800. The rms
errors for the coefficients as a function of the bandwidth
The relative errors are nearly the same for the two tested power spectra, implying that the form of the data do not strongly affect the accuracy of the routines. Relative errors using the Driscoll and Healy [1994] sampled grids are nearly identical to those using Gauss-Legendre quadrature. The errors associated with the routines for complex data are lower by a few orders of magnitude.
The speed of the spherical harmonic reconstructions and transforms were tested for both real and complex data using the Gauss-Legendre and Driscoll and Healy [1994] quadrature implementations. The amount of time in seconds required to perform these operations is plotted in the figure below as a function of the spherical harmonic bandwidth of the function. These calculations were performed on a modern Mac Pro 2.7 GHz 12-Core Intel Xeon E5 using 64 bit executables and level 3 optimizations.
{% include image.html file="timing-tests.png" alt="Timing tests" caption="Figure 3. Time to perform the reconstruction of a function from its spherical harmonic coefficients (solid lines) and the spherical harmonic transform of the function (dashed lines)." %}
For the real Gauss-Legendre quadrature routines, the transform time is on the order of one second for degrees close to 800 and about 30 seconds for degree 2600. For the real Driscoll and Healy [1994] sampled grids, the transform time is close to a second for degree 600 and about 1 minute for degrees close to 2600. The complex routines are slower by a factor of about 1.4.
-
Driscoll, J. R. and D. M. Healy, Computing Fourier transforms and convolutions on the 2-sphere, Adv. Appl. Math., 15, 202-250, doi:10.1006/aama.1994.1008, 1994.
-
Frigo, M., and S. G. Johnson, The design and implementation of FFTW3, Proc. IEEE, 93, 216–231, doi:10.1109/JPROC.2004.840301, 2005.
-
Holmes, S. A., and W. E. Featherstone, A unified approach to the Clenshaw summation and the recursive computation of very high degree and order normalised associated Legendre functions, J. Geodesy, 76, 279- 299, doi:10.1007/s00190-002-0216-2, 2002.
-
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, "Numerical Recipes in FORTRAN: The Art of Scientific Computing," 2nd ed., Cambridge Univ. Press, Cambridge, UK, 1992.