write_spharmpdm_coef#

ktch.io.write_spharmpdm_coef(path: str | Path, data: SpharmPdmData, precision: int | None = None) None[source]#

Write SPHARM coefficients to a SPHARM-PDM .coef file.

The inverse of read_spharmpdm_coef(). The file layout matches the output of ParaToSPHARMMesh in SPHARM-PDM: the number of coefficients per coordinate, then one {x, y, z} triple per line in SPHARM-PDM’s interleaved real/imaginary order.

Parameters:
pathstr or pathlib.Path

Path of the .coef file to write.

dataSpharmPdmData

SPHARM-PDM coefficient data for a single specimen.

precisionint, optional

Number of decimals to write. None writes the shortest representation that reads back to the same float64. SPHARM-PDM itself writes six decimals; pass precision=6 to reproduce that format.

Raises:
ValueError

If data is not a SpharmPdmData or its coefficients are malformed.

IOError

If the file cannot be written.

See also

read_spharmpdm_coef

Read a .coef file.

sha_coeffs_to_spharmpdm

Convert ktch coefficient vectors for writing.