get_modes#
- acoular.sources.get_modes(lOrder, direction, mpos, sourceposition=None)
Calculate the spherical harmonic radiation pattern at microphone positions.
This function computes the spherical harmonic radiation pattern values at each microphone position for a given maximum spherical harmonic order (
lOrder), orientation (direction), and optional source position (sourceposition).- Parameters:
- lOrder
int The maximum order of spherical harmonics to compute. The resulting modes will include all orders up to and including
lOrder.- direction
numpy.ndarrayof shape(3,) Unit vector representing the orientation of the spherical harmonics. Should contain the
x,y, andzcomponents of the direction.- mpos
numpy.ndarrayof shape(3, N) Microphone positions in a 3D Cartesian coordinate system. The array should have 3 rows (the
x,yandzcoordinates) andNcolumns (one for each microphone).- sourceposition
numpy.ndarrayof shape(3,), optional Position of the source in a 3D Cartesian coordinate system. If not provided, it defaults to the origin
[0, 0, 0].
- lOrder
- Returns:
numpy.ndarrayof shape(N, (lOrder+1) ** 2)Complex values representing the spherical harmonic radiation pattern at each microphone position (
Nmicrophones) for each spherical harmonic mode.
See also
get_radiation_angles()Computes azimuth and elevation angles between microphones and the source.
scipy.special.sph_harmComputes spherical harmonic values.
Notes
The azimuth (
azi) and elevation (ele) angles between the microphones and the source are calculated using theget_radiation_angles()function.Spherical harmonics (
sph_harm) are computed for each mode(l, m), wherelis the degree (ranging from0tolOrder) andmis the order (ranging from-lto+l).For negative orders (m < 0), the conjugate of the spherical harmonic is computed and scaled by the imaginary unit
1j.
Examples
>>> import acoular as ac >>> import numpy as np >>> >>> lOrder = 2 >>> direction = [0, 0, 1] # Orientation along z-axis >>> mpos = np.array([[1, -1], [1, -1], [0, 0]]) # Two microphones >>> sourcepos = [0, 0, 0] # Source at origin >>> >>> modes = ac.sources.get_modes(lOrder, direction, mpos, sourcepos) >>> modes.shape (2, 9)