SphericalHarmonicTransform#
- class de_ebsd.index.spherical.SphericalHarmonicTransform(bandwidth, *, device=None, dtype=torch.float64)[source]#
Bases:
objectA 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:
- bandwidth
int 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.- device
torch.deviceorstr,optional Device the grid and cached design matrices are built on (default CPU).
- dtype
torch.dtype,optional Real floating dtype of the transform; must be
torch.float32ortorch.float64(defaulttorch.float64). The complex coefficient dtype is the matchingcomplex64/complex128.
- bandwidth
- Attributes:
- bandwidth
int The band limit
L.- theta, phi
torch.Tensor 1-D quadrature nodes (
(L + 1,)and(2 L + 2,)).- weights
torch.Tensor (L + 1, 2 L + 2)quadrature weights.- n_coeff
int Number of packed coefficients
(L + 1) ** 2.
- bandwidth
Methods
Samples
(..., N_theta, N_phi)-> coefficients(..., n_coeff).Cartesian unit vectors
(N_theta, N_phi, 3)of every quadrature node.Coefficients
(..., n_coeff)-> samples(..., N_theta, N_phi).Return a plan on a new device / real dtype (cheap to rebuild).
- forward(values)[source]#
Samples
(..., N_theta, N_phi)-> coefficients(..., n_coeff).valuesmay be real or complex; the result is complex. Differentiable invalues.
- 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), thenforward.