sht_inverse

hrtfpykit.hrtf.sht_inverse(sh)

Reconstruct HRTF magnitudes on the original source grid.

The reconstruction multiplies the basis matrix stored in SH.Y by the coefficient matrix stored in SH.C. It reconstructs magnitudes only and uses the same source directions that were used to build the SH object; it does not evaluate the spherical-harmonic model on new directions.

Parameters:

sh (SH) – SH-domain object returned by sht(). Y must have shape (N, n_coefficients) and C must start with the same coefficient count implied by sh_order.

Returns:

Reconstructed linear magnitude matrix. The shape is (N, n_frequencies) when sh.C is two-dimensional, or (N, 2, n_frequencies) when sh.C is three-dimensional.

Return type:

np.ndarray

Raises:

ValueError – If Y, C, N, or sh_order are mutually inconsistent, or if C is not two- or three-dimensional.

Examples

Reconstruct magnitudes on the same source grid used for decomposition:

>>> from hrtfpykit.hrtf import load_hrtf, sht, sht_inverse
>>> hrtf = load_hrtf("hrtfs/P0001_FreeFieldComp_44kHz.sofa")
>>> sh = sht(hrtf, sh_order=3, ear="both")
>>> magnitude_reconstructed = sht_inverse(sh)
>>> magnitude_reconstructed.shape
(793, 2, 129)