Load SPHARM Coefficients#
ktch can read spherical harmonic coefficients from SPHARM-PDM format files.
Read SPHARM-PDM coefficients#
The .coef file is an output of the ParaToSPHARMMesh step of SPHARM-PDM.
from ktch.io import read_spharmpdm_coef
# Path to a sample .coef file (from ktch test data)
sample_coef_path = "../../../ktch/io/tests/data/andesred_07_allSegments_SPHARM.coef"
data = read_spharmpdm_coef(sample_coef_path)
print(f"Specimen name: {data.specimen_name}")
print(f"Maximum degree (l_max): {data.l_max}")
print(f"Coefficient array shape: {data.to_numpy().shape}")
Specimen name: andesred_07_allSegments_SPHARM
Maximum degree (l_max): 25
Coefficient array shape: (676, 3)
Coefficient structure#
SPHARM-PDM coefficients are organized by spherical harmonic degree:
# Each element contains coefficients for one harmonic degree
for i, coef in enumerate(data.coeffs[:3]):
print(f"Degree {i}: shape {coef.shape}")
Degree 0: shape (1, 3)
Degree 1: shape (3, 3)
Degree 2: shape (5, 3)
See also
Harmonic-based Morphometrics for background on spherical harmonic analysis