Directivity

The directivity module provides tools to work with directivity.

The following conventions are used within this module:

  • The inclination angle \(\theta\) has a range \([0, \pi]\).
  • The azimuth angle \(\phi\) has a range \([0 , 2 \pi]\).
class acoustics.directivity.Cardioid(rotation=None)[source]

Cardioid directivity.

class acoustics.directivity.Custom(theta=None, phi=None, r=None)[source]

A class to work with directivity.

__init__(theta=None, phi=None, r=None)[source]

Constructor.

phi = None

Longitude. 1-D array.

r = None

Magnitude or radius. 2-D array.

theta = None

Latitude. 1-D array.

class acoustics.directivity.Directivity(rotation=None)[source]

Abstract directivity class.

This class defines several methods to be implemented by subclasses.

__init__(rotation=None)[source]

Initialize self. See help(type(self)) for accurate signature.

plot(filename=None, include_rotation=True)[source]

Directivity plot. Plot to filename when given.

Parameters:
  • filename – Filename
  • include_rotation – Apply the rotation to the directivity. By default the rotation is applied in this figure.
rotation = None

Rotation of the directivity pattern.

using_cartesian(x, y, z, include_rotation=True)[source]

Return the directivity for given cartesian coordinates.

Parameters:
  • x – x
  • y – y
  • z – z
using_spherical(r, theta, phi, include_rotation=True)[source]

Return the directivity for given spherical coordinates.

Parameters:
  • r – norm
  • theta – angle \(\theta\)
  • phi – angle \(\phi\)
class acoustics.directivity.FigureEight(rotation=None)[source]

Directivity of a figure of eight.

class acoustics.directivity.Omni(rotation=None)[source]

Class to work with omni-directional directivity.

class acoustics.directivity.SphericalHarmonic(rotation=None, m=None, n=None)[source]

Directivity of a spherical harmonic of degree n and order m.

__init__(rotation=None, m=None, n=None)[source]

Initialize self. See help(type(self)) for accurate signature.

m = None

Order m.

n = None

Degree n.

acoustics.directivity.cardioid(theta, a=1.0, k=1.0)[source]

A cardioid pattern.

Parameters:
  • a – a
  • k – k
acoustics.directivity.cartesian_to_spherical(x, y, z)[source]

Convert cartesian coordinates to spherical coordinates.

Parameters:
  • x – x
  • y – y
  • z – z
\[r = \sqrt{\left( x^2 + y^2 + z^2 \right)}\]
\[\theta = \arccos{\frac{z}{r}}\]
\[\phi = \arccos{\frac{y}{x}}\]
acoustics.directivity.figure_eight(theta, phi=0.0)[source]

A figure-of-eight pattern.

Parameters:theta – angle \(\theta\)
acoustics.directivity.plot(d, sphere=False)[source]

Plot directivity d.

Parameters:d (Directivity) – Directivity
Returns:Figure
acoustics.directivity.spherical_harmonic(theta, phi, m=0, n=0)[source]

Spherical harmonic of order m and degree n.

Note

The degree n is often denoted l.

See also

scipy.special.sph_harm()

acoustics.directivity.spherical_to_cartesian(r, theta, phi)[source]

Convert spherical coordinates to cartesian coordinates.

Parameters:
  • r – norm
  • theta – angle \(\theta\)
  • phi – angle \(\phi\)
\[x = r \sin{\theta}\cos{\phi}\]
\[y = r \sin{\theta}\sin{\phi}\]
\[z = r \cos{\theta}\]