Filtering on the sphere
The generalized convolution of vectors and tensors, its spin-weighted transforms and its analysis.
CoarseGrainingEnergyFluxes.Filtering.AbstractAnalysis — Type
AbstractAnalysisHow GeneralizedConvolution takes a field's spin-weighted coefficients: AutoAnalysis, Quadrature or LeastSquares.
CoarseGrainingEnergyFluxes.Filtering.AbstractSpinTransforms — Type
AbstractSpinTransformsSpin-weighted spherical harmonic transforms of spin 0, 1 and 2 over every cell of a spherical grid, built by spin_transforms, in the grid's element type. A subtype defines
spin_field(tr): a zeroed complex field array of the kind they read and write;spin_field_size(tr): its size;spin_position(tr): a callable taking a cell's linear index to its position in that array;spin_coefficients(tr): a zeroed coefficient array;spin_transfer_buffer(tr): a zeroed host vector of one entry per degree a coefficient array carries, from 0, for the transferĜ;spin_analyze!(C, F, tr, s): the coefficients of the spin-sfieldFintoC;spin_synthesize!(F, C, W, Ĝ, tr, s): intoF, the spin-sfield whose degree-ncoefficients areĜ[n+1]times those ofC, withWa coefficient array to scale in.Cis left as it is;spin_ladder_synthesize!(F, C, W, d, tr, s, t): intoF, the spin-tfieldð(t = s + 1) orð̄(t = s − 1) of the spin-sfield whose coefficients areC, its degree-ncoefficients scaled byd[n+1].
and may define spin_host(tr), whether its arrays are host memory, true unless it says otherwise; a device workspace stages its fields through host copies for transforms that run there. Transforms whose analysis is the quadrature Aᴴ W define spin_weights, which a LeastSquares analysis reads.
CoarseGrainingEnergyFluxes.Filtering.AbstractVectorFilter — Type
AbstractVectorFilterHow a filter acts on a vector or a rank-2 tensor on the surface of a sphere: GeneralizedConvolution or CartesianComponents. A diagnostic takes it as its vector_filter keyword; resolve_vector_filter states which applies where.
CoarseGrainingEnergyFluxes.Filtering.AutoAnalysis — Type
AutoAnalysis() <: AbstractAnalysisQuadrature on Gauss–Legendre and reduced Gaussian samplings, where it is exact, and on grids whose sampling may be regional (none, latitude–longitude or scattered), where it is the zero-extended field's integral; LeastSquares on every other spherical sampling, whose quadrature is not exact at its band limit (Fejér, Driscoll–Healy, McEwen–Wiaux, HEALPix, cubed-sphere, icosahedral, Yin–Yang). A latitude–longitude grid over the whole sphere takes LeastSquares() by name.
CoarseGrainingEnergyFluxes.Filtering.CartesianComponents — Type
CartesianComponents <: AbstractVectorFilterThe scalar filter of each ambient Cartesian component of a vector, and of each Cartesian component of a tensor, rotated back to the local frame (Aluie 2019, eq. 41). On the surface of a sphere it equals GeneralizedConvolution for a tangent field with no divergence, whose Cartesian components of degree n are spherical harmonics of degree n; the components of a divergent field's degree-n part carry degrees n ± 1, which it filters with Ĝ(n ± 1), and it gives a tangent field a radial component, which a tangent diagnostic drops. It is how a vector is filtered under Deformable, which is no convolution, and on a spheroid.
CoarseGrainingEnergyFluxes.Filtering.CellOrder — Type
CellOrder()The position of cell k in a field array laid out in the grid's own linear cell order: k.
CoarseGrainingEnergyFluxes.Filtering.GeneralizedConvolution — Type
GeneralizedConvolution(; lmax = nothing, analysis = AutoAnalysis()) <: AbstractVectorFilterThe convolution of vectors and rank-2 tensors on a sphere of Aluie (2019, eqs. 58 and 121): every degree-n vector or tensor spherical harmonic is multiplied by the kernel's Ĝ(n) (Kernels.spectral_transfer_degrees!), so filtering commutes with the surface gradient, divergence and curl (Propositions 1–3). It runs as spin-weighted transforms of the field extended by zero over the sphere (spin_transforms): FastSphericalHarmonics' on a Float64 Fejer1Sampling grid of 2N − 1 by N, NUFSHT's on every other spherical grid when a NUFFT library is loaded to run it, and otherwise the direct sums, RingSpinTransforms on a latitude–longitude StructuredGrid and DirectSpinTransforms elsewhere. The theory page derives the spin-weighted form.
lmax is the highest degree the NUFSHT and direct transforms carry, nothing the grid's spin_band_limit. FastSphericalHarmonics transforms at its grid's own band limit, so a given lmax selects another transform under transform = AutoSpectralBackend(). analysis is how the NUFSHT and direct transforms take coefficients (AbstractAnalysis); FastSphericalHarmonics' transform is exact on its grid.
CoarseGrainingEnergyFluxes.Filtering.LeastSquares — Type
LeastSquares(; rtol = nothing, maxiter = 100) <: AbstractAnalysisThe coefficients minimizing Σ_k w_k |F_k − Σ_ℓm C_ℓm ₛY_ℓm(x_k)|² over the grid's cells, by FlowTransformBindings' lsmr! in the inner product of the cells' measures, whose first iterate is the Quadrature. It recovers a field of degree at most lmax wherever the cells determine its coefficients, whatever the quadrature's accuracy. rtol bounds ‖Aᴴ W r‖ / ‖Aᴴ W F‖. nothing takes max(1e-12, 100 eps(T)) in the generalized convolution's transforms, and max(10 tol, √eps(T)) in a NUFSHT spectral plan, whose NUFFT tolerance tol bounds the fit's accuracy. A fit that stops at maxiter keeps its last iterate and reports through analysis_status.
CoarseGrainingEnergyFluxes.Filtering.Quadrature — Type
Quadrature() <: AbstractAnalysisThe coefficients by the quadrature over the grid's cells, C_ℓm = Σ_k w_k F_k conj(ₛY_ℓm(x_k)), w_k the cell's measure over R². It is exact for a field of degree at most lmax where the measure integrates degree 2lmax exactly, as Gauss–Legendre rows do to lmax = nrings − 1, and over a regional grid it is the integral of the field extended by zero over the sphere.
CoarseGrainingEnergyFluxes.Filtering.TransposedCells — Type
TransposedCells(nlon, nlat)The position of cell k of an nlon × nlat longitude–latitude grid in an nlat × nlon array: cell (i, j), k = i + (j − 1)nlon, sits at j + (i − 1)nlat.
CoarseGrainingEnergyFluxes.Filtering._spin_nodes — Method
_spin_nodes(grid) -> (θ, φ, w)Host vectors, in the grid's element type and its linear cell order, of every cell's colatitude, its longitude in [0, 2π) and its measure over R², the quadrature weight of a transform on the unit sphere.
CoarseGrainingEnergyFluxes.Filtering.resolve_vector_filter — Method
resolve_vector_filter(grid, mask_strategy, vector_filter) -> AbstractVectorFilterThe filter a diagnostic applies to a vector on grid under mask_strategy. On the surface of a sphere, nothing takes GeneralizedConvolution under ZeroFill and CartesianComponents under Deformable, and a given filter is taken as given. Everywhere else it is CartesianComponents(): on a plane and in a volume, whose kernel is a ball of the ambient space, the convolution of each Cartesian component is the generalized convolution there; on a spheroid it is the only one defined. A GeneralizedConvolution given under Deformable or on a spheroid raises an ArgumentError.
CoarseGrainingEnergyFluxes.Filtering.spin_band_limit — Method
spin_band_limit(grid) -> IntThe highest spherical-harmonic degree grid's cells resolve, at least 2: the band limit of a sampling that ties its ring count to one (SphericalSampling.has_bandlimit), and otherwise ⌈πR/√A⌉ − 1, the degree whose half wavelength is the side √A of the grid's largest cell.
CoarseGrainingEnergyFluxes.Filtering.spin_ladder_synthesize! — Function
spin_ladder_synthesize!(F, C, W, d, tr, s, t) -> FInto F, the spin-t field ð (t = s + 1) or ð̄ (t = s − 1) of the spin-s field whose coefficients are C, ð and ð̄ the Newman–Penrose operators on the unit sphere, with its degree-n coefficients scaled by d[n + 1]. The caller folds the ladder factor √((n − s)(n + s + 1)) or −√((n + s)(n − s + 1)) into d; each transform applies the phases of its own harmonics. W is a coefficient array to scale in.
CoarseGrainingEnergyFluxes.Filtering.spin_transforms — Method
spin_transforms(transform, grid; lmax = nothing, nthreads = 1, nufft = AutoSpectralBackend(),
execution = SerialBackend()) -> AbstractSpinTransformsThe spin transforms of GeneralizedConvolution over grid's cells, for a workspace whose loops run under the local backend execution, a library's on nthreads threads. transform = AutoSpectralBackend() takes FastSphericalHarmonics on its own grids when lmax is nothing, NUFSHT on every spherical grid where it is loaded with a NUFFT library (nufft, or under Auto NonuniformFFTs or FINUFFT), and the direct sum otherwise. DirectSumSpectralBackend() takes the direct sum: RingSpinTransforms on a latitude–longitude StructuredGrid, DirectSpinTransforms on any other grid. A library named that no loaded extension provides raises an ArgumentError.
CoarseGrainingEnergyFluxes.Filtering.DirectSpinTransforms — Type
DirectSpinTransforms(grid; lmax = nothing, execution = SerialBackend())The spin-weighted transforms of GeneralizedConvolution by direct summation over the cells of a spherical grid, for any spin |s| ≤ 2, in the grid's element type and in the memory of the local backend execution, whose loops run them. With ₛY_ℓm(θ, φ) = N_ℓ d^ℓ_{m,−s}(θ) e^{imφ}, N_ℓ = √((2ℓ+1)/4π) and θ the colatitude, the analysis is the quadrature C_ℓm = Σ_k w_k F_k conj(ₛY_ℓm(x_k)) with w_k the cell's measure over R², one work item per order m, and the synthesis is F_k = Σ_ℓm Ĝ(ℓ) C_ℓm ₛY_ℓm(x_k), one work item per cell. The coefficients are C[ℓ+1, m+lmax+1].
The Wigner d^ℓ_{m,−s} run up FlowTransformBindings' recurrence in ℓ from ℓ₀ = max(|m|, |s|), a value below the floating-point range carried with its own scale, so an order whose start lies below the range keeps the values it reaches at higher degree. A transform costs O(M·lmax²) over M cells and fills its spin's step coefficients, O(lmax²). lmax = nothing takes spin_band_limit.
CoarseGrainingEnergyFluxes.Filtering._wigner_nodes — Method
_wigner_nodes(T, S, θ) -> (; x, xl, u, pos, lc, ls, cs)Per colatitude θ_k: cos θ_k as x + xl to twice T's precision (the plain step's), pos = θ_k ≤ π/2 and u = 2sin²(θ_k/2) where pos, 2cos²(θ_k/2) elsewhere (Reinsch's), and log₂ cos(θ_k/2), log₂ sin(θ_k/2) and cos(θ_k/2) sin(θ_k/2) in S, which the starting values read.
CoarseGrainingEnergyFluxes.Filtering.DenseLongitudes — Type
DenseLongitudes(E)The longitude step of RingSpinTransforms as products with E[i, m+L+1] = e^{imφ_i}: the row sums ring = Eᴴ·(w F) and the synthesis F = E·ring, for any longitudes the rows share.
CoarseGrainingEnergyFluxes.Filtering.RingSpinTransforms — Type
RingSpinTransforms(grid; lmax = nothing, execution = SerialBackend())The sums of DirectSpinTransforms on a two-dimensional latitude–longitude grid, whose rows share a colatitude. The analysis is C_ℓm = Σ_j N_ℓ d^ℓ_{m,−s}(θ_j) Σ_i w_ij F_ij e^{−imφ_i}: the sums along every row are taken at once by the grid's DenseLongitudes, or with an FFT library loaded on a whole ring of uniform longitude by one FFT per row, and the Wigner recurrence runs once per row and order, one work item per order, two degrees a pass over the rows. The synthesis is its transpose with Ĝ(ℓ). A transform costs O(nlat·lmax²) for the recurrence and O(M·lmax) for the dense longitude sums, O(M log nlon) by FFT, over M cells. lmax = nothing takes spin_band_limit.
CoarseGrainingEnergyFluxes.Filtering.SpinFit — Type
SpinFitWhat a LeastSquares analysis holds over a spin transforms' arrays: √w laid out as the field, a field and a coefficient array of scratch, the unit transfer, FlowTransformBindings' LSMR workspace, the stopping rule, the worst outcome of the fits it has run (converged == false with no iterations before the first), and whether it has run one.
CoarseGrainingEnergyFluxes.Filtering.resolved_analysis — Method
resolved_analysis(analysis, grid) -> Quadrature or LeastSquaresanalysis itself, or for AutoAnalysis the one grid's sampling takes.
CoarseGrainingEnergyFluxes.Filtering.spin_fit! — Method
spin_fit!(C, F, tr, fit, s) -> CThe spin-s coefficients of the field F into C: the quadrature spin_analyze! (AbstractSpinTransforms) where fit is nothing, the least-squares fit of a SpinFit otherwise, its outcome folded into the fit's status.
CoarseGrainingEnergyFluxes.Filtering.spin_fit — Method
spin_fit(analysis, grid, tr) -> SpinFit or nothingThe fit GeneralizedConvolution's analysis takes on grid with the transforms tr, nothing for the quadrature; a transform whose analysis is exact on its grid adds a method returning nothing.
CoarseGrainingEnergyFluxes.Filtering.spin_weights — Function
spin_weights(tr) -> AbstractVectorThe quadrature weights of the analysis of tr, each cell's measure over R², laid out as its field.