SphericalHarmonicTransform#

class de_ebsd.index.spherical.SphericalHarmonicTransform(bandwidth, *, device=None, dtype=torch.float64)[source]#

Bases: object

A cached, separable spherical harmonic transform for a fixed bandwidth.

Builds the exact Gauss-Legendre x equiangular quadrature grid and the associated-Legendre design matrices once, then transforms via an FFT over phi and a per-order matmul over theta. Both directions are batched over arbitrary leading dimensions and are autograd-differentiable in the samples/coefficients.

Parameters:
bandwidthint

The band limit L. Sets the quadrature grid (N_theta = L + 1, N_phi = 2 L + 2) and the packed coefficient count (L + 1) ** 2.

devicetorch.device or str, optional

Device the grid and cached design matrices are built on (default CPU).

dtypetorch.dtype, optional

Real floating dtype of the transform; must be torch.float32 or torch.float64 (default torch.float64). The complex coefficient dtype is the matching complex64 / complex128.

Attributes:
bandwidthint

The band limit L.

theta, phitorch.Tensor

1-D quadrature nodes ((L + 1,) and (2 L + 2,)).

weightstorch.Tensor

(L + 1, 2 L + 2) quadrature weights.

n_coeffint

Number of packed coefficients (L + 1) ** 2.

Methods

forward

Samples (..., N_theta, N_phi) -> coefficients (..., n_coeff).

grid_directions

Cartesian unit vectors (N_theta, N_phi, 3) of every quadrature node.

inverse

Coefficients (..., n_coeff) -> samples (..., N_theta, N_phi).

to

Return a plan on a new device / real dtype (cheap to rebuild).

forward(values)[source]#

Samples (..., N_theta, N_phi) -> coefficients (..., n_coeff).

values may be real or complex; the result is complex. Differentiable in values.

grid_directions()[source]#

Cartesian unit vectors (N_theta, N_phi, 3) of every quadrature node.

n = (sin th cos ph, sin th sin ph, cos th) – sample the sphere here (e.g. resample a master pattern onto these directions), then forward.

inverse(coeffs)[source]#

Coefficients (..., n_coeff) -> samples (..., N_theta, N_phi).

Returns complex samples (take .real for a real-valued function). Differentiable in coeffs.

to(device=None, dtype=None)[source]#

Return a plan on a new device / real dtype (cheap to rebuild).