spaudiopy.plot
Plotting helpers.
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['axes.grid'] = True
import spaudiopy as spa
Functions
|
Compare A and B format signals. |
|
Shows amplitude, energy, spread and angular error measures on grid. |
|
Direction of Arrival, with optional p(t) scaling the size. |
|
Plot magnitude of frequency response over time frequency f. |
|
Plot ILDs and ITDs of HRIRs. |
|
Plot loudspeaker setup and valid simplices from its hull object. |
|
Plot loudspeaker setup with vertex and face normals. |
|
Polar plot (in dB) that allows negative values for r. |
|
Set 3D axis to equal aspect. |
|
Barplot over SH channels. |
|
Plot spherical harmonics coefficients as function on the sphere. |
|
Overlay spherical harmonics coefficients plot. |
|
Plot spherical harmonics coefficients list as function on the sphere. |
|
Plot spherical harmonic signal RMS as function on the sphere. |
|
Positive (single sided) amplitude spectrum of time signal x. |
|
Plot function 1D vector f over azi and zen. |
|
Plot function 1D vector f over azi and zen, can also convert to dB. |
|
Plot transfer function H (magnitude and phase) over time frequency f. |
|
Plot Zero Pole diagram from a and b coefficients. |
- spaudiopy.plot.spectrum(x, fs, ylim=None, scale_mag=False, **kwargs)[source]
Positive (single sided) amplitude spectrum of time signal x. kwargs are forwarded to plot.freq_resp().
- Parameters:
x (np.array, list of np.array) – Time domain signal.
fs (int) – Sampling frequency.
- spaudiopy.plot.freq_resp(freq, amp, TODB=True, smoothing_n=None, xlim=(20, 24000), ylim=(-30, None), title=None, labels=None, ax=None)[source]
Plot magnitude of frequency response over time frequency f.
- Parameters:
f (frequency array)
amp (array_like, list of array_like)
TODB (bool) – Plot in dB.
smoothing_n (int) – Forwarded to process.frac_octave_smoothing()
Examples
- spaudiopy.plot.transfer_function(freq, H, title=None, xlim=(10, 25000))[source]
Plot transfer function H (magnitude and phase) over time frequency f.
- spaudiopy.plot.zeropole(b, a, zPlane=False, title=None)[source]
Plot Zero Pole diagram from a and b coefficients.
- spaudiopy.plot.spherical_function(f, azi, zen, title=None, ax=None)[source]
Plot function 1D vector f over azi and zen.
- spaudiopy.plot.sh_coeffs(F_nm, sh_type=None, azi_steps=5, el_steps=3, title=None, ax=None, cbar=True)[source]
Plot spherical harmonics coefficients as function on the sphere. Evaluates the inverse SHT.
Examples
See
spaudiopy.sph
- spaudiopy.plot.sh_coeffs_subplot(F_nm_list, titles=None, fig=None, **kwargs)[source]
Plot spherical harmonics coefficients list as function on the sphere. kwargs are forwarded to
spaudiopy.plt.sh_coeffs
.Examples
See
spaudiopy.sph
- spaudiopy.plot.sh_coeffs_overlay(F_nm_list, sh_type=None, azi_steps=5, el_steps=3, title=None, ax=None)[source]
Overlay spherical harmonics coefficients plot.
Examples
- spaudiopy.plot.sh_rms_map(F_nm, TODB=False, w_n=None, sh_type=None, n_plot=50, title=None, clim=[0, None], ax=None)[source]
Plot spherical harmonic signal RMS as function on the sphere. Evaluates the maxDI beamformer, if w_n is None.
- Parameters:
F_nm (((N+1)**2, S) numpy.ndarray) – Matrix of spherical harmonics coefficients, Ambisonic signal.
TODB (bool) – Plot in dB.
w_n (array_like) – Modal weighting of beamformers that are evaluated on the grid.
sh_type (‘complex’ or ‘real’ spherical harmonics.)
n_plot (int) – Plotting precision (grid degree).
Examples
- spaudiopy.plot.spherical_function_map(f, azi, zen, TODB=False, title=None, clim=(None, None), ax=None)[source]
Plot function 1D vector f over azi and zen, can also convert to dB.
Examples
- spaudiopy.plot.sh_bar(x_nm, TODB=True, centered=False, num_groups=1, s=250, vf=4, clim=None, xticklabels=None, title=None, ax=None)[source]
Barplot over SH channels.
- Parameters:
x_nm (array_like) – C x L.
TODB (TYPE, optional) – DESCRIPTION. The default is True.
centered (TYPE, optional) – DESCRIPTION. The default is False.
num_groups (TYPE, optional) – Plot gourps. The default is 1.
s (TYPE, optional) – Scatter plot size. The default is 250.
vf (TYPE, optional) – Vertical ratio. The default is 4.
clim (TYPE, optional) – DESCRIPTION. The default is None.
xticklabels (TYPE, optional) – DESCRIPTION. The default is None.
title (TYPE, optional) – DESCRIPTION. The default is None.
fig (TYPE, optional) – DESCRIPTION. The default is None.
- Returns:
None.
- spaudiopy.plot.hull(hull, simplices=None, mark_invalid=True, title=None, draw_ls=True, ax_lim=None, color=None, clim=None, ax=None)[source]
Plot loudspeaker setup and valid simplices from its hull object.
- Parameters:
hull (decoder.LoudspeakerSetup)
simplices (optional)
mark_invalid (bool, optional) – mark invalid simplices from hull object.
title (string, optional)
draw_ls (bool, optional)
ax_lim (float, optional) – Axis limits in m.
color (array_like, optional) – Custom colors for simplices.
clim ((2,), optional) – vmin and vmax for colors.
Examples
- spaudiopy.plot.hull_normals(hull, plot_face_normals=True, plot_vertex_normals=True)[source]
Plot loudspeaker setup with vertex and face normals.
- spaudiopy.plot.polar(theta, r, TODB=True, rlim=None, title=None, ax=None)[source]
Polar plot (in dB) that allows negative values for r.
Examples
- spaudiopy.plot.decoder_performance(hull, renderer_type, azi_steps=5, ele_steps=3, show_ls=True, title=None, **kwargs)[source]
Shows amplitude, energy, spread and angular error measures on grid. For renderer_type={‘VBAP’, ‘VBIP’, ‘ALLRAP’, ‘NLS’}, as well as {‘ALLRAD’, ‘ALLRAD2’, ‘EPAD’, ‘MAD’, ‘SAD’}. All kwargs are forwarded to the decoder function.
References
Zotter, F., & Frank, M. (2019). Ambisonics. Springer Topics in Signal Processing.
Examples
- spaudiopy.plot.doa(azi, zen, p=None, size=250, c=None, alpha=None, fs=None, title=None, ltitle=None, ax=None)[source]
Direction of Arrival, with optional p(t) scaling the size.
Examples
n = 300 fs = 44100 t_ms = np.linspace(0, n/fs, n, endpoint=False) * 1000 # t in ms x = np.random.randn(n) y = np.random.randn(n) z = np.random.randn(n) azi, zen, r = spa.utils.cart2sph(x, y, z) ps = 1 / np.exp(np.linspace(0, 3, n)) spa.plot.doa(azi, zen, ps, fs=fs, ltitle="p(t)")
- spaudiopy.plot.hrirs_ild_itd(hrirs, plevels=50, pclims=(None, None), title=None, fig=None)[source]
Plot ILDs and ITDs of HRIRs.
- Parameters:
hrirs (sig.HRIRs)
plevels (int, optional) – Contour levels. The default is 50.
pclims ((2,), optional) – Set the plot color limits for ild and itd, e.g. (20, 0.75)
title (string, optional.)
fig (plt.figure, optional)
- Returns:
None.
See also
spaudiopy.process.ilds_from_hrirs
Calculating ILDs with defaults (in dB).
spaudiopy.process.itds_from_hrirs
Calculating ITDs with defaults.
Examples
dummy_hrirs = spa.io.load_hrirs(48000, 'dummy') spa.plot.hrirs_ild_itd(dummy_hrirs)