torch_harmonics.random_fields.GaussianRandomFieldS2#
- class torch_harmonics.random_fields.GaussianRandomFieldS2(
- nlat,
- alpha=2.0,
- tau=3.0,
- sigma=None,
- radius=1.0,
- grid='equiangular',
- dtype=torch.float32,
Bases:
ModuleGaussian random field on the sphere via Karhunen–Loève expansion.
Samples realisations of a centred Gaussian random field on \(S^2\) whose covariance operator has the Matérn-like power spectrum
\[C_l = \sigma^2 \left(\frac{l(l+1)}{R^2} + \tau^2\right)^{-\alpha}\]where \(l\) is the spherical harmonic degree. The field is generated by drawing i.i.d. standard-normal spectral coefficients, scaling them by \(\sqrt{C_l}\), and transforming to the spatial domain with an inverse SHT.
Larger
alphaproduces smoother fields (steeper spectral roll-off);taucontrols the transition scale between the flat low-\(l\) plateau and the power-law decay.- Parameters:
nlat (int) – Number of latitudinal grid points (
nlonis set to2 * nlat).alpha (float, optional) – Spectral exponent (smoothness). Must be > 1 when
sigmais not given. Default2.0.tau (float, optional) – Inverse correlation length scale. Default
3.0.sigma (float, optional) – Overall amplitude. If
None(default), computed fromalphaandtauso that the field variance is \(\mathcal{O}(1)\).radius (float, optional) – Radius of the sphere. Default
1.0.grid (str, optional) – Grid type for the inverse SHT (
"equiangular","legendre-gauss", etc.). Default"equiangular".dtype (torch.dtype, optional) – Floating-point dtype. Default
torch.float32.
Examples
>>> import torch >>> from torch_harmonics.random_fields import GaussianRandomFieldS2 >>> grf = GaussianRandomFieldS2(nlat=128, alpha=2.5, tau=5.0) >>> samples = grf(4) # 4 independent realisations >>> samples.shape torch.Size([4, 128, 256])