Spherical Filters¶
SphericalFilter1D
¶
Bases: Module
1D spectral filter on the Gauss-Legendre latitude grid.
Filters are applied as multiplicative masks in Legendre coefficient space
c_l_filtered = F(l) * c_l
Attributes:¶
grid : SphericalGrid1D The 1D Gauss-Legendre grid.
Source code in spectraldiffx/_src/spherical/filters.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
Functions¶
exponential_filter(u, alpha=36.0, power=16, spectral=False)
¶
Apply exponential filter in Legendre coefficient space.
F(l) = exp(-alpha * (l / l_max)^power)
Near unity for low degrees, falls sharply near l_max.
Parameters:¶
u : Float[Array, "N"] Physical field or Legendre coefficients (if spectral=True). alpha : float Damping coefficient. Default is 36.0. power : int Filter sharpness (even integer). Default is 16. spectral : bool If True, treat u as Legendre coefficients.
Returns:¶
Array [N] Filtered field or spectral coefficients.
Source code in spectraldiffx/_src/spherical/filters.py
hyperviscosity(u, nu_hyper, dt, power=4, spectral=False)
¶
Apply hyperviscous damping in Legendre coefficient space.
F(l) = exp(-nu_hyper * [l*(l+1)/R^2]^(power/2) * dt)
where R = grid.L / pi is the sphere radius. This matches the physical Laplacian eigenvalue so that the damping rate is independent of the sphere radius for a given nu_hyper.
Simulates high-order diffusion: du/dt = (-1)^(p+1) * nu_h * nabla^p u.
Parameters:¶
u : Float[Array, "N"] Physical field or Legendre coefficients. nu_hyper : float Hyperviscosity coefficient. dt : float Time step for the damping. power : int Order of the Laplacian power (e.g., 4 for biharmonic). Default is 4. spectral : bool If True, treat u as Legendre coefficients.
Returns:¶
Array [N]
Source code in spectraldiffx/_src/spherical/filters.py
SphericalFilter2D
¶
Bases: Module
2D spectral filter on the full sphere lat-lon grid.
Filters are applied in SHT coefficient space using the spherical harmonic degree l as the spectral index.
Attributes:¶
grid : SphericalGrid2D The 2D lat-lon grid.
Source code in spectraldiffx/_src/spherical/filters.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
Functions¶
exponential_filter(u, alpha=36.0, power=16, spectral=False)
¶
Apply 2D exponential filter using spherical harmonic degree l.
F(l, m) = exp(-alpha * (l / l_max)^power)
Parameters:¶
u : Float[Array, "Ny Nx"] Physical field or SHT coefficients. alpha : float Damping coefficient. Default is 36.0. power : int Filter sharpness. Default is 16. spectral : bool If True, treat u as SHT coefficients.
Returns:¶
Array [Ny, Nx] Filtered field or spectral coefficients.
Source code in spectraldiffx/_src/spherical/filters.py
hyperviscosity(u, nu_hyper, dt, power=4, spectral=False)
¶
Apply 2D hyperviscous damping using l*(l+1)/R^2 eigenvalues.
F(l) = exp(-nu_hyper * [l*(l+1)/R^2]^(power/2) * dt)
where R = grid.Ly / pi is the sphere radius.
Parameters:¶
u : Float[Array, "Ny Nx"] Physical field or SHT coefficients. nu_hyper : float Hyperviscosity coefficient. dt : float Time step. power : int Laplacian power order. Default is 4. spectral : bool If True, treat u as SHT coefficients.
Returns:¶
Array [Ny, Nx]