sht_inverse¶
- hrtfpykit.hrtf.sht_inverse(sh)¶
Reconstruct HRTF magnitudes on the original source grid.
The reconstruction multiplies the basis matrix stored in
SH.Yby the coefficient matrix stored inSH.C. It reconstructs magnitudes only and uses the same source directions that were used to build theSHobject; it does not evaluate the spherical-harmonic model on new directions.- Parameters:
sh (SH) – SH-domain object returned by
sht().Ymust have shape (N, n_coefficients) andCmust start with the same coefficient count implied bysh_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, orsh_orderare mutually inconsistent, or ifCis 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)