check_sofa_against_conventions

hrtfpykit.sofa.check_sofa_against_conventions(target, convention_name=None, version=None)

Validate a SOFA file or open netCDF4 object against a SOFA convention.

The check emits warnings for: - missing mandatory attributes/variables - read-only defaults that do not match - dimension mismatches - custom attributes/variables/dimensions not listed in the spec

Parameters:
  • target (Union[str, netCDF4.Dataset]) – Path to a SOFA file or an open netCDF4 object containing SOFA data.

  • convention_name (Optional[str], optional) – Convention name to validate against. If None, uses the file’s SOFAConventions attribute.

  • version (Optional[str], optional) – Convention version to validate against. If None, uses the file’s SOFAConventionsVersion attribute.

Returns:

Summary containing the resolved convention name and version.

Return type:

dict

Raises:
  • ValueError – If target is a SOFA object without a loaded netCDF4 handle.

  • OSError – If target is a path-like input that cannot be opened as a SOFA file.

Examples

Validate a SOFA file against the convention declared in its global attributes and keep the resolved convention metadata for downstream checks:

>>> from hrtfpykit.sofa import check_sofa_against_conventions
>>> summary = check_sofa_against_conventions(
...     "hrtfs/P0001_FreeFieldComp_44kHz.sofa"
... )
>>> summary["convention"]["name"]
'SimpleFreeFieldHRIR'