compare_absolute_ild

hrtfpykit.plots.compare_absolute_ild(hrtfs, plane_angle=0.0, legends=None, line_colors=None, line_styles=None, legend_location=None, legend_bbox_to_anchor=None, show=True, show_titles=True, show_labels=True, show_legends=True)

Compare absolute broad band ILD curves from several HRTFs.

compare_absolute_ild calls ild() for each HRTF as ild(hrtf, mode="broad-band", epsilon=1e-12, absolute=True). It selects the nearest measured horizontal plane for each HRTF, sorts each polar curve by azimuth, and overlays the curves in one figure.

Each HRTF resolves the requested horizontal plane independently. If compared HRTFs resolve to different real elevations, the function emits an HRTFPyKitWarning.

Parameters:
  • hrtfs (list[HRTF]) – HRTF objects to compare. The list must contain at least 2 and at most 5 entries. Every object must contain IR data.

  • plane_angle (float, default=0.0) – Requested horizontal plane elevation in degrees. The nearest available elevation is selected separately for each HRTF.

  • legends (list[str] | tuple[str, ...] | None, default=None) – Subject legend labels. Defaults to subject_1 through subject_n.

  • line_colors (list[str] | tuple[str, ...] | None, default=None) – One line color per subject. Uses the default color cycle when omitted.

  • line_styles (list[str] | tuple[str, ...] | None, default=None) – One line style per subject. Defaults to solid lines.

  • legend_location (str | None, default=None) – Legend location. Defaults to upper right.

  • legend_bbox_to_anchor (tuple[float, float] | None, default=None) – Legend anchor tuple (x, y). Defaults to (1.08, 1.08).

  • show (bool, default=True) – If True, display the figure before returning.

  • show_titles (bool, default=True) – If False, suppress generated figure titles.

  • show_labels (bool, default=True) – If False, suppress generated axis labels and colorbar labels.

  • show_legends (bool, default=True) – If False, suppress generated legends.

Returns:

Figure containing the overlaid absolute broad band ILD polar curves.

Return type:

matplotlib.figure.Figure

Raises:

ValueError – If the HRTF list length, plane_angle, legend/style lengths, or IR availability is invalid.

Warns:

HRTFPyKitWarning – If HRTFs resolve the requested horizontal plane to different real elevations.

Notes

The polar angular axis uses spherical azimuth in the SOFA convention. The radial axis uses ILD dB units and integer tick labels.

Examples

Compare absolute broad band ILD on the horizontal plane for two HRTFs:

>>> from hrtfpykit.hrtf import load_hrtf
>>> from hrtfpykit.plots import compare_absolute_ild
>>> hrtf_a = load_hrtf("P0001_FreeFieldComp_44kHz.sofa")
>>> hrtf_b = load_hrtf("P0002_FreeFieldComp_44kHz.sofa")
>>> compare_absolute_ild(
...     [hrtf_a, hrtf_b],
...     plane_angle=0.0,
...     legends=["P0001", "P0002"],
...     line_styles=["-", "--"],
... )