Spherical Harmonic Definitions#
Within spharpy, the spherical harmonics are referred to using the symbol
\(Y_n^m(\theta, \phi)\), where \(n\) is the spherical harmonic order,
\(m\) is the degree, and \(\theta\) and \(\phi\) are the
colatitude and azimuth angles, respectively.
This coordinate convention corresponds to the spherical_colatitude
coordinate convention in pyfar
(see also the pyfar documentation page).
Spharpy supports multiple definitions of the spherical harmonics also referred to as conventions. These definitions differ in their choice of real or complex valued functions and in the magnitude normalization and phase convention.
General definition#
In a general form, the spherical harmonics can be expressed as
where \(N_n^m\) is the magnitude normalization, \(S^m\) is the phase convention, \(P_n^{m}(\cos\theta)\) are the associated Legendre functions, and \(A^m(\phi)\) is the azimuthal function.
Magnitude normalization#
All implementations form an orthogonal basis on the sphere. Accordingly, the inner product of two spherical harmonics yields the weighted product of Kronecker delta symbols \(\delta_{nn'} \delta_{mm'}\)
where \(C_n\) depends on the chosen normalization convention.
Magnitude normalizations implemented in spharpy are:
Identifier |
Description |
\(C\) |
\(N_n^m\) |
|---|---|---|---|
|
full normalization on the sphere |
1 |
\(\sqrt{\frac{2n+1}{4\pi} \frac{(n-m)!}{(n+m)!}}\) |
|
semi-normalized on the sphere |
\(\frac{1}{2n+1}\) |
\(\sqrt{ \frac{1}{4 \pi} \frac{(n-m)!}{(n+m)!}}\) |
|
monopole moment normalization |
\(4\pi\) |
\(\sqrt{(2n+1) \frac{(n-m)!}{(n+m)!}}\) |
|
monopole moment semi-normalized |
\(\frac{4\pi}{2n+1}\) |
\(\sqrt{\frac{(n-m)!}{(n+m)!}}\) |
|
maximum magnitude normalization |
N/A |
N/A |
Note that for the 'maxN' normalization, no general closed-form expression
for the constant \(C\) exists. The constant is chosen such that the
maximum magnitude of the spherical harmonics on the sphere is equal to 1,
i.e., \(\max_{\theta, \phi} |Y_n^m(\theta, \phi)| = 1\).
The name monopole moment normalization refers to the fact that the magnitude of the spherical harmonic of order \(n=0\) is normalized to 1 for this convention. In contrast, for fully normalized and semi normalized spherical harmonics, the magnitude of the spherical harmonic of order \(n=0\) is normalized to \(\sqrt{1/4\pi}\).
Note that in some literature, the normalization and Legendre functions are expressed using the absolute value of the degree \(|m|\) instead of \(m\). This has however no effect on the resulting spherical harmonics as long as the absolute value is used consistently for the normalization and associated Legendre function, since
Phase convention#
Spharpy implements two different phase conventions, also referred to as the Condon-Shortley phase term
By default, the Condon-Shortley phase term is included for complex spherical
harmonics and not included for real spherical harmonics, which corresponds to
the common convention in the fields of acoustics.
Note that the Condon-Shortley phase term is included in the definition of the
associated Legendre functions in the scipy.special module, which is used
for the computation of the spherical harmonics in spharpy.
Real and complex valued definition of the azimuthal function#
The azimuthal function \(A^m(\phi)\) can be defined in a real or complex-valued form, which leads to the real and complex spherical harmonics. For complex valued spherical harmonics, the azimuthal function is defined as
For real valued spherical harmonics, the azimuthal function is defined as
Examples#
For reference, the following plots show the spherical harmonics up to third order. The color map encodes the phase of the spherical harmonics and the radius encodes the magnitude. The source code of the plot function is hidden for better readability, but can be downloaded using the link below.
The default definition of the complex valued spherical harmonics corresponds to
the 'N3D' normalization, the inclusion of the Condon-Shortley phase term.
import spharpy
n_max = 2
sampling = spharpy.samplings.equal_area(0, n_points=500)
Y_nm = spharpy.SphericalHarmonics(
n_max=n_max,
coordinates=sampling,
basis_type='complex',
normalization='N3D',
condon_shortley='auto'
).basis
axs, gs = plot_basis_functions(Y_nm, sampling)
(Source code, png, hires.png, pdf)
The default definition of the real valued spherical harmonics corresponds
to the 'N3D' normalization and the exclusion of the Condon-Shortley phase term.
Y_nm = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='real',
normalization='N3D',
condon_shortley='auto'
).basis
axs, gs = plot_basis_functions(Y_nm, sampling)
(Source code, png, hires.png, pdf)
As an example, the following plot shows the real valued spherical harmonics with the inclusion of the Condon-Shortley phase term. Note that the phase is rotated by \(\pi\) for all spherical harmonics with odd degree \(m\) compared to the plot above.
Y_nm = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='real', condon_shortley=True).basis
axs, gs = plot_basis_functions(Y_nm, sampling)
(Source code, png, hires.png, pdf)
Common conventions#
Within the fields of acoustics and audio reproduction, several different definitions of the spherical harmonics are commonly used, which differ in their choice of real or complex valued functions, the magnitude normalization, and phase convention. They can primarily be distinguished into complex and real valued definitions. For each of these two types, the most commonly used definitions are described in the following.
Complex valued spherical harmonics#
The most commonly used definition of complex valued spherical harmonics used in the fields
of acoustics corresponds the 'N3D' normalization and the inclusion of the
Condon-Shortley phase term. This definition is found in Ref. [1] and [2] and
serves as the default parametrization used in spharpy for complex valued spherical harmonics.
spherical_harmonics = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='complex', normalization='N3D', condon_shortley=True
)
Real valued spherical harmonics#
When considering real valued spherical harmonics, a larger number of different definitions are commonly used in the literature or implemented in software packages. Note that especially in software packages for music production, the normalization used in the implementation is often not explicitly stated or even inconsistent with the normalization stated in the documentation.
Fully normalized spherical harmonics#
This convention is the real valued equivalent of the complex valued spherical harmonics
from the previous section, i.e., it corresponds to the 'N3D' normalization and the
exclusion of the Condon-Shortley phase term.
This convention is found in Ref. [3] and Sec. 5.9.1. of Ref. [4] and implemented as
the default parametrization for real valued spherical harmonics in spharpy.
spherical_harmonics = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='real', normalization='N3D', condon_shortley=False
)
AmbiX#
The most commonly used definition of the real valued spherical harmonics used in
audio reproduction via Ambisonics corresponds to the AmbiX convention.
The AmbiX convention corresponds to the 'SN3D' normalization and the exclusion
of the Condon-Shortley phase term for real valued spherical harmonics,
see Sec. 5.9.1. of Ref. [4].
In spharpy, this definition is implemented using the following parametrization.
spherical_harmonics = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='real', normalization='SN3D', condon_shortley=False
)
Note that especially in software plug-ins for music production, the normalization
used in the implementation corresponds to spharpy’s 'SNM' normalization without
explicitly stating this in the documentation.
This normalization results in an undistorted magnitude of the mono-channel when
encoding to Ambisonics, which is often desirable for music production.
AES69-2022#
The convention used in the AES69-2022 [5] standard corresponds to the 'NM' normalization
and the exclusion of the Condon-Shortley phase term.
This convention is implemented in spharpy using the following parametrization
spherical_harmonics = spharpy.SphericalHarmonics(
n_max=n_max, coordinates=sampling,
basis_type='real', normalization='NM', condon_shortley=False
)