SHTnsKit.jl

SHTnsKit.jl transforms scalar and vector fields between values on a spherical grid and spherical-harmonic coefficients. It is written in Julia and supports the same transform conventions on CPUs, NVIDIA and AMD GPUs, and MPI-distributed arrays.

What it provides

  • Scalar, tangential-vector, and three-component QST transforms.
  • Gauss–Legendre and equiangular grids, with explicit quadrature conventions.
  • Reusable plans, batch transforms, rotations, operators, and energy spectra.
  • Optional CUDA, AMDGPU, MPI, automatic-differentiation, and SIMD extensions.

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 the basic arrays and transform directionQuick Start
choose the right spherical samplingGrid Types
adapt a working scientific recipeExamples Gallery
keep transforms on an NVIDIA or AMD 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

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