SHTnsKit.jl

SHTnsKit.jl

Fast spherical harmonic transforms for Julia — scalars, vectors, and spectral operators on CPUs, GPUs, and MPI clusters.

🌐 Full Transform Suite

Scalar, tangential-vector, and three-component QST transforms with Gauss–Legendre and equiangular grids.

⚡ Multi-Backend

Run full-grid transforms on CPUs, NVIDIA CUDA, AMD ROCm, and Apple Metal GPUs through the same Julia API.

📡 MPI Distribution

Distribute latitude bands across MPI ranks with PencilArrays for fields that exceed single-node memory.

🧮 Differentiable

ForwardDiff, Zygote, and ChainRules extensions make transforms compatible with Julia’s AD ecosystem.

Install

using Pkg
Pkg.add("SHTnsKit")

See Installation only if you need a GPU, MPI, or help with setup.

First transform

Start with known band-limited coefficients so the roundtrip has an exact answer:

using SHTnsKit

cfg = create_gauss_config(16, 18)
coefficients = zeros(ComplexF64, cfg.lmax + 1, cfg.mmax + 1)
coefficients[3, 1] = 1.0             # degree l=2, order m=0
coefficients[5, 3] = 0.25 - 0.1im   # degree l=4, order m=2

field = synthesis(cfg, coefficients)
recovered = analysis(cfg, field)

@assert maximum(abs, recovered - coefficients) < 1e-12
size(field)
(18, 34)

Spatial fields use (latitude, longitude) order. Dense coefficients use (l + 1, m + 1) indexing because Julia arrays start at one.

Choose your path

I want to...Read...
understand arrays and transform directionsQuick Start
choose the right spherical samplingGrid Types
adapt a working scientific recipeExamples Gallery
keep transforms on an NVIDIA, AMD, or Apple GPUGPU Acceleration
distribute fields across MPI ranksDistributed Computing
make repeated transforms fasterPerformance Guide
use packed storage, operators, rotations, or ADAdvanced Usage
exchange coefficients with another libraryNormalization and Phase
understand source files and extension systemPackage Architecture

The API Reference lists the complete public surface. Most users can begin with the default Gauss–Legendre grid and orthonormal convention.