Grid Types

Grid constructors validate sampling constraints immediately. Every grid stores latitude in the first spatial dimension, longitude in the second, and uses equally spaced longitudes. The important choice is how points are placed in colatitude $\theta$ from the north pole ($\theta = 0$) to the south pole ($\theta = \pi$). The comparison below uses the same 12 latitude samples and 16 longitudes in every panel, so the different latitude patterns are directly comparable.

Four globes comparing Gauss–Legendre, regular midpoint, regular with poles, and Driscoll–Healy sampling grids.
Faint dots lie on the far side of each globe. Driscoll–Healy dot size reflects quadrature weight.

At a pole, all longitudes describe the same physical point, so their markers overlap in the figure.

Compare the sampling patterns

GridColatitudesPole samplesGood choice when…
Gauss–LegendreRoots of the degree-nlat Legendre polynomialNeitherYou want the default grid and the most accurate quadrature for a given number of latitudes.
Regular midpoint (Fejér)$\theta_i = (i + 1/2)\pi/n_\mathrm{lat}$NeitherYour data are cell-centred or already live on an equiangular image-like grid.
Regular with poles$\theta_i = i\pi/(n_\mathrm{lat}-1)$BothYour external format requires explicit values at both poles.
Driscoll–Healy$\theta_i = i\pi/n_\mathrm{lat}$North onlyYou want equiangular sampling with Driscoll–Healy quadrature for band-limited transforms.

Gauss–Legendre quadrature with nlat points integrates polynomials in $x = \cos\theta$ through degree 2*nlat - 1 exactly. Driscoll–Healy quadrature is exact at the intended band limit when nlat = 2*(lmax + 1); nlat must be even.

Equiangular grids need `nlat ≥ 2*lmax + 1`

Fejér and Clenshaw–Curtis rules with nlat nodes are exact only through degree $n_\mathrm{lat} - 1$, and analysis integrates a product of two degree-lmax Legendre functions — degree $2\,l_\mathrm{max}$. So the two regular grids reproduce alm from analysis(synthesis(alm)) only from nlat = 2*lmax + 1 upward, where Gauss–Legendre needs just nlat = lmax + 1.

Below the threshold nothing warns; the answer is simply wrong. Measured relative round-trip error at lmax = 8:

nlat:gaussregular midpointregular with poles
108e-167.2e-23.6e-1
148e-161.3e-27.1e-3
168e-164.2e-31.3e-3
17 (2*lmax+1)8e-167e-167e-16

Size the grid deliberately, or use Gauss–Legendre (or Driscoll–Healy, exact at nlat = 2*(lmax+1)) when round-trip accuracy matters.

Which grid should I choose?

Start with Gauss–Legendre unless you need to exchange data with a particular equiangular layout. Use regular midpoint for cell-centred data, regular with poles for formats that store both endpoints, and Driscoll–Healy when its sampling theorem and quadrature weights are part of your numerical method.

Gauss–Legendre

create_gauss_config is the default choice for numerical transforms:

using SHTnsKit

lmax = 32
cfg = create_gauss_config(lmax, lmax + 1; nlon=2lmax + 1)
cfg
SHTConfig{Gauss-Legendre} with lmax=32, mmax=32, mres=1
├── grid: 33 × 65 (north-pole-first)
│   ├── θ: 0.07178 … 3.07
│   └── φ: 0.0 … 6.187, Δφ = 0.09666
├── quadrature: Σw = 2.0
├── normalization: :orthonormal, Condon-Shortley = true, real_norm = false
├── Legendre mode: on-the-fly
├── spectral modes: nlm = 561
├── φ scaling: :dft
└── padding: disabled

Constraints:

  • nlat >= lmax + 1
  • 0 <= mmax <= lmax
  • mres >= 1
  • nlon >= 2*mmax + 1

create_gauss_fly_config uses the same nodes while keeping Legendre recurrence on the fly. create_gauss_config_spf creates the south-pole-first variant.

Regular Fejér grid

The default regular grid uses midpoint colatitudes theta_i = (i + 1/2)π/nlat, excluding both poles:

using SHTnsKit

cfg = create_regular_config(32, 34; include_poles=false)
cfg
SHTConfig{regular (Fejér)} with lmax=32, mmax=32, mres=1
├── grid: 34 × 66 (north-pole-first)
│   ├── θ: 0.0462 … 3.095
│   └── φ: 0.0 … 6.188, Δφ = 0.0952
├── quadrature: Σw = 2.0
├── normalization: :orthonormal, Condon-Shortley = true, real_norm = false
├── Legendre mode: tables (578.5 KiB)
├── spectral modes: nlm = 561
├── φ scaling: :dft
└── padding: disabled

It requires nlat >= lmax + 2 and nlon >= 2*mmax + 1. Associated Legendre tables are precomputed by default; pass precompute_plm=false to favor a lower initial memory footprint.

Pole-inclusive regular grid

using SHTnsKit

cfg = create_regular_config(32, 33; include_poles=true)
cfg
SHTConfig{regular (pole-inclusive)} with lmax=32, mmax=32, mres=1
├── grid: 33 × 66 (north-pole-first)
│   ├── θ: 0.0 … 3.142
│   └── φ: 0.0 … 6.188, Δφ = 0.0952
├── quadrature: Σw = 2.0
├── normalization: :orthonormal, Condon-Shortley = true, real_norm = false
├── Legendre mode: tables (561.5 KiB)
├── spectral modes: nlm = 561
├── φ scaling: :dft
└── padding: disabled

This grid includes both endpoints, requires nlat >= lmax + 1, and always requires at least two latitudes. Pole-safe scalar and vector recurrences handle the endpoint rows.

Robert-form vector and QST analysis rejects this grid when the stored orders include m=1 (mres=1 and mmax>=1). Multiplication by sin(theta) removes the pole values needed by its nonzero endpoint quadrature weights. Synthesis remains supported. Use Gauss–Legendre, regular midpoint, or Driscoll–Healy grids for Robert-form roundtrips; fixed-order analysis of m!=1 is also supported.

Driscoll–Healy weights

Enable Driscoll–Healy quadrature on a pole grid:

using SHTnsKit

lmax = 15
nlat = 2 * (lmax + 1)
cfg = create_regular_config(
    lmax, nlat;
    include_poles=true,
    use_dh_weights=true,
)
cfg
SHTConfig{Driscoll-Healy} with lmax=15, mmax=15, mres=1
├── grid: 32 × 32 (north-pole-first)
│   ├── θ: 0.0 … 3.043
│   └── φ: 0.0 … 6.087, Δφ = 0.1963
├── quadrature: Σw = 2.0
├── normalization: :orthonormal, Condon-Shortley = true, real_norm = false
├── Legendre mode: tables (128.0 KiB)
├── spectral modes: nlm = 136
├── φ scaling: :dft
└── padding: disabled

use_dh_weights=true requires include_poles=true and an even nlat. Exact sampling uses nlat == 2*(lmax + 1); another even value is accepted with a warning because it no longer has that exactness guarantee. The DH nodes include the north pole and exclude the south pole.

Common constructor

create_config selects a grid through grid_type and forwards the normalization and sampling options. When nlat is left at its default it picks a latitude count that the grid transforms exactly: lmax + 2 for Gauss, 2lmax + 1 for the equiangular grids, and 2(lmax + 1) for Driscoll–Healy. The default is recognised by its value, so an explicit nlat = lmax + 2 does the same; call create_regular_config for exactly lmax + 2 equiangular latitudes. Prefer the specific constructors in user code when the chosen grid should be obvious at the call site.

Latitude order

New configurations are north-pole-first. Use set_south_pole_first! or set_north_pole_first! before allocating/filling fields when an external data source uses the opposite order. Query with is_south_pole_first(cfg).

Do not reverse only the field: the field, nodes, quadrature weights, and tables must use one consistent ordering.