You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement NonnegativeLeastSquares.jl enhanced Energy Transfers from Third-Order Structure Functions #18
An Improved Methodology to Estimate Cross-Scale Kinetic Energy Transfers from Third-Order Structure Functions Using Regularized Least Squares https://doi.org/10.1175/JTECH-D-25-0025.1 indicates that we should be able to use this method of optimized energy transfer calculations.
Implement Dimension-Aware Transforms Between Structure Functions and Spectra
Description
Our package calculates Structure Functions (SFs) of all orders, but lacks the ability to invert them into Isotropic Power Spectra ($E(k)$). Because our data spans different dimensions (1D tracks, 2D surfaces, 3D volumes), we cannot use a standard 1D FFT for all inversions. When multi-dimensional fields are averaged into 1D isotropic spectra, the geometry of the required transform changes.
Theoretical Basis
The 2nd-Order SF is the Bridge: By the Wiener-Khinchin theorem, only the 2nd-order structure function ($S_2(r)$) can be directly transformed into the kinetic energy power spectrum ($E(k)$).
The 3rd-Order SF is the Flux: The 3rd-order structure function ($S_3(r)$) represents spectral energy transfer (e.g., Kolmogorov's 4/5ths law). It cannot be inverted into a standard power spectrum.
Dimensionality Constraints & Required Basis Functions
To accurately convert an isotropic spectrum $E(k_r)$ back to a physical $S_2(r)$ (and vice versa), the integration basis function must match the dimension the data was azimuthally or spherically averaged from:
1D Data (Straight-line tracks): No angular averaging.
Transform: Standard 1D FFT / Discrete Cosine Transform.
Basis Function: Cosine wave ($\cos(kr)$).
2D Data (Ocean/Atmosphere surfaces): Averaged over circular rings.
Transform: Discrete Hankel Transform.
Basis Function: Bessel function of the first kind, order zero ($J_0(kr)$).
3D Data (Volume fields): Averaged over spherical shells.
Transform: Spherical Bessel Transform.
Basis Function: Sinc function ($\frac{\sin(kr)}{kr}$).
Implementation Checklist
Implement 1D Cosine inversion for $S_2(r) \leftrightarrow E(k_{1D})$
Implement 2D Hankel inversion (Bessel $J_0$) for isotropic surface fields.
Implement 3D Spherical Bessel inversion (Sinc) for isotropic volume fields.
Add explicit errors if a user attempts an $E(k)$ inversion on $S_n$ where $n \neq 2$.
(Optional) Add a dedicated method to extract the turbulent dissipation rate ($\epsilon$) directly from $S_3(r)$.
This actually I think can used the generalized Hankel Transform for any dimensions, but the rest of the package needs to be updated to accept any dimension data.
The transform half is implemented; the NNLS estimator is not, and is what remains here.
Done, following the dimension↔kernel table in the comments above:
data
angular average
kernel
1-D tracks
none
cos(kr)
2-D surfaces
circular rings
J₀(kr)
3-D volumes
spherical shells
sin(kr)/(kr)
isotropic_spectrum(result, wavenumbers, Val(D)), verified pointwise against a closed form (a Gaussian correlation has an analytic spectral density in every dimension): agreement to 6.6e-05, 2.3e-09, 9.9e-14 in 1-D/2-D/3-D. Bessels.jl is a zero-dependency weakdep, needed only for the 2-D kernel since the other two are elementary.
Two corrections to the spec in this issue, both of which would otherwise have been silent errors:
"S₂" is ambiguous, and the ambiguity is a factor of 2. This package has three second-order quantities: S2SF is the trace ⟨‖δu‖²⟩, L2SF is ⟨δu_L²⟩, T2SF is ⟨δu_T²⟩. Only the trace maps to the KE spectrum by the plain Wiener–Khinchin route — measured in 2-D, mean(D_LL / trace) = 0.497. So handing L2SF to a routine documented as "S₂ → E(k)" would silently return about half the kinetic-energy spectrum. assert_invertible now accepts only the trace and refuses L2SF/T2SF naming the isotropy relation needed to convert.
No variance argument. The k ≠ 0 spectrum follows from D(r) alone: since FT[D](k) = 2C(0)·N·δ_{k,0} − 2·FT[C](k), the constant lives entirely at k = 0. Verified to 2.3e-16 against a directly computed spectrum, and adding a constant offset of 137 to the field leaves D unchanged to 4.6e-14 and the recovered spectrum unchanged to 1.3e-12. Only the k = 0 mode is lost, and no variance argument would recover it. (That argument is required for the covariance in Covariance Matrix from Structure Fucntion #21 — same blindness, opposite consequence.)
Also implemented, and worth noting since it was not in the original scope: the Helmholtz route. D_rot/D_div transform to E_rot(k)/E_div(k) with the same kernels — the canonical oceanographic SF→KE pipeline, and the reason the package carries a Helmholtz decomposition at all. It was unreachable until the factor-of-r defect in #16 was fixed.
"Only S₂ may be inverted" is enforced: orders other than two are refused as fluxes rather than spectra.
Remaining here: the NNLS-regularised energy transfers. That needs NonnegativeLeastSquares.jl and a regularisation choice which is a research decision rather than an implementation one, so it is deliberately its own deliverable on top of the transforms above.
Activity
jbphyswx commentedon Jun 5, 2026
Implement Dimension-Aware Transforms Between Structure Functions and Spectra
Description
Our package calculates Structure Functions (SFs) of all orders, but lacks the ability to invert them into Isotropic Power Spectra ($E(k)$). Because our data spans different dimensions (1D tracks, 2D surfaces, 3D volumes), we cannot use a standard 1D FFT for all inversions. When multi-dimensional fields are averaged into 1D isotropic spectra, the geometry of the required transform changes.
Theoretical Basis
Dimensionality Constraints & Required Basis Functions$E(k_r)$ back to a physical $S_2(r)$ (and vice versa), the integration basis function must match the dimension the data was azimuthally or spherically averaged from:
To accurately convert an isotropic spectrum
Implementation Checklist
This actually I think can used the generalized Hankel Transform for any dimensions, but the rest of the package needs to be updated to accept any dimension data.
jbphyswx commentedon Jun 6, 2026
Hankel Links:
https://github.com/pbeckman/FastHankelTransform.jl, https://doi.org/10.48550/arXiv.2411.09583 (this is also NUFHT - nonuniform fast hankel transform)
https://github.com/chrisbrahms/Hankel.jl for QDHT
https://github.com/marcobonici/FFTLog.jl, https://www.marcobonici.com/FFTLogDocs.jl/dev/ also has an old potentially useful impelmentation to study
jbphyswx commentedon Sep 6, 2026
The transform half is implemented; the NNLS estimator is not, and is what remains here.
Done, following the dimension↔kernel table in the comments above:
cos(kr)J₀(kr)sin(kr)/(kr)isotropic_spectrum(result, wavenumbers, Val(D)), verified pointwise against a closed form (a Gaussian correlation has an analytic spectral density in every dimension): agreement to6.6e-05,2.3e-09,9.9e-14in 1-D/2-D/3-D.Bessels.jlis a zero-dependency weakdep, needed only for the 2-D kernel since the other two are elementary.Two corrections to the spec in this issue, both of which would otherwise have been silent errors:
S2SFis the trace⟨‖δu‖²⟩,L2SFis⟨δu_L²⟩,T2SFis⟨δu_T²⟩. Only the trace maps to the KE spectrum by the plain Wiener–Khinchin route — measured in 2-D,mean(D_LL / trace) = 0.497. So handingL2SFto a routine documented as "S₂ → E(k)" would silently return about half the kinetic-energy spectrum.assert_invertiblenow accepts only the trace and refusesL2SF/T2SFnaming the isotropy relation needed to convert.varianceargument. Thek ≠ 0spectrum follows fromD(r)alone: sinceFT[D](k) = 2C(0)·N·δ_{k,0} − 2·FT[C](k), the constant lives entirely atk = 0. Verified to 2.3e-16 against a directly computed spectrum, and adding a constant offset of 137 to the field leavesDunchanged to 4.6e-14 and the recovered spectrum unchanged to 1.3e-12. Only thek = 0mode is lost, and no variance argument would recover it. (That argument is required for the covariance in Covariance Matrix from Structure Fucntion #21 — same blindness, opposite consequence.)Also implemented, and worth noting since it was not in the original scope: the Helmholtz route.
D_rot/D_divtransform toE_rot(k)/E_div(k)with the same kernels — the canonical oceanographic SF→KE pipeline, and the reason the package carries a Helmholtz decomposition at all. It was unreachable until the factor-of-rdefect in #16 was fixed."Only S₂ may be inverted" is enforced: orders other than two are refused as fluxes rather than spectra.
Remaining here: the NNLS-regularised energy transfers. That needs
NonnegativeLeastSquares.jland a regularisation choice which is a research decision rather than an implementation one, so it is deliberately its own deliverable on top of the transforms above.jbphyswx commentedon Nov 11, 2026
Should be closed by #39, reopen if anything was missed