torch_harmonics.distributed.DistributedRealSHT#

class torch_harmonics.distributed.DistributedRealSHT(
nlat,
nlon,
lmax=None,
mmax=None,
grid='equiangular',
norm='ortho',
csphase=True,
)[source]#

Bases: Module

Distributed version of the forward (real-valued) SHT. Precomputes Legendre Gauss nodes, weights and associated Legendre polynomials on these nodes. The SHT is applied to the last two dimensions of the input.

Distribution scheme. The input tensor has shape (B, C, nlat_local, nlon_local) where latitudes and longitudes are split across the polar and azimuth process groups respectively. All leading dimensions are flattened into a single axis N = B * C which is used as the redistribution currency during the all-to-all transposes. The forward pass proceeds as follows:

  1. Azimuth transpose (nlon ↔ N) — each rank trades its local longitude chunk for a slice of the channel axis, making nlon fully local so the real FFT can be applied.

  2. Real FFT along the (now local) longitude dimension.

  3. Azimuth transpose (N ↔ mmax) — redistribute so that spectral orders m are split across azimuth ranks and channels are local again.

  4. Polar transpose (N ↔ nlat) — trade channel slices for the full latitude axis, making nlat local for the Legendre contraction.

  5. Legendre contraction — local matrix multiply with the quadrature weights, producing spectral degrees l.

  6. Polar transpose (l ↔ N) — redistribute so that degrees l are split across polar ranks.

The output has shape (B, C, lmax_local, mmax_local) with spectral modes partitioned in the same way as the spatial grid.

If N < max(polar_group_size, azimuth_group_size), the leading axis is zero-padded before the transposes and the padding is removed afterwards; since the transform is linear this is exact.

See also

torch_harmonics.RealSHT

Serial counterpart with full mathematical description and parameter documentation.

Parameters:
  • nlat (int) – Number of latitude points

  • nlon (int) – Number of longitude points

  • lmax (int) – Maximum spherical harmonic degree

  • mmax (int) – Maximum spherical harmonic order

  • grid (str) – Grid type ("equiangular", "legendre-gauss", "lobatto", "equiangular-trapezoidal"), by default "equiangular"

  • norm (str) – Normalization type ("ortho", "schmidt", "unnorm"), by default "ortho"

  • csphase (bool) – Whether to apply the Condon-Shortley phase factor, by default True

Returns:

Tensor of shape (…, lmax, mmax)

Return type:

torch.Tensor

References

[2], [3]