Spherical Harmonic Transform
The following sections outline the implementation of the spherical harmonic transform (in short spectral transform) between the coefficients of the spherical harmonics (the spectral space) and the grid space which can be any of the Implemented grids as defined by RingGrids. This includes the classical full Gaussian grid, a regular longitude-latitude grid called the full Clenshaw grid (FullClenshawGrid), ECMWF's octahedral Gaussian grid[^Malardel2016], and HEALPix grids[^Gorski2004]. SpeedyWeather.jl's spectral transform module SpeedyTransforms is grid-flexible and can be used with any of these, see Grids.
SpeedyTransforms is a module too!
SpeedyTransform is the underlying module that SpeedyWeather imports to transform between spectral and grid-point space, which also implements Derivatives in spherical coordinates. You can use this module independently of SpeedyWeather for spectral transforms, see SpeedyTransforms.
Inspiration
The spectral transform implemented by SpeedyWeather.jl follows largely Justin Willmert's CMB.jl and SphericalHarmonicTransforms.jl package and makes use of AssociatedLegendrePolynomials.jl and FFTW.jl for the Fourier transform. Justin described his work in a Blog series [^Willmert2020].
Spherical harmonics
The spherical harmonics
with
Latitudes versus colatitudes
The implementation of the spectral transforms in SpeedyWeather.jl uses colatitudes
Synthesis (spectral to grid)
The synthesis (or inverse transform) takes the spectral coefficients
We obtain an approximation with a finite set of trunc when creating the SpectralGrid.
For
meaning that the coefficients at trunc. One is added here because the degree
For correctness we want to mention here that vector quantities require one more degree
Another consequence of the symmetry mentioned above is that the zonal harmonics, meaning
Following the notation of [^Willmert2020] we can therefore write the truncated synthesis as
The
Another symmetry arises from the fact that the spherical harmonics are either symmetric or anti-symmetric around the Equator. There is an even/odd combination of degrees and orders so that the sign flips like a checkerboard
This means that one only has to compute the Legendre polynomials for one hemisphere and the other one follows with this equality.
Analysis (grid to spectral)
Starting in grid-point space we can transform a field
Note that this notation again uses colatitudes
The hat on
So the term in brackets can be separated out as long as the latitude
Spectral packing
Spectral packing is the way how the coefficients 
Every row represents an order
which is consistently extended for higher degrees and orders. Consequently, all spectral fields are lower-triangular matrices with complex entries. The upper triangle excluding the diagonal are zero. Note that internally vector fields include an additional degree, such that
For correctness it is mentioned here that SpeedyWeather.jl uses a LowerTriangularMatrix type to store the spherical harmonic coefficients. By doing so, the upper triangle is actually not explicitly stored and the data technically unravelled into a vector, but this is hidden as much as possible from the user. For more details see LowerTriangularArrays.
Array indices
For a spectral field a note that due to Julia's 1-based indexing the coefficient a[l+1, m+1]. Alternatively, we may index over 1-based l, m but a comment is usually added for clarification.
Fortran SPEEDY does not use the same spectral packing as SpeedyWeather.jl. The alternative packing
| degree | order | ||
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
| 2 | 0 | 0 | 2 |
| 2 | 1 | 1 | 1 |
| 2 | 2 | 2 | 0 |
| 3 | 0 | 0 | 3 |
| ... | ... | ... | ... |
This alternative packing uses the top-left triangle of a coefficient matrix, and the degrees and orders from above are stored at the following indices
This spectral packing is not used in SpeedyWeather.jl but illustrated here for completeness and comparison with Fortran SPEEDY.
SpeedyWeather.jl uses triangular truncation such that only spherical harmonics with
Available horizontal resolutions
Technically, SpeedyWeather.jl supports arbitrarily chosen resolution parameter trunc when creating the SpectralGrid that refers to the highest non-zero degree
trunc | nlon | nlat | |
|---|---|---|---|
| 31 (default) | 96 | 48 | 400 km |
| 42 | 128 | 64 | 312 km |
| 63 | 192 | 96 | 216 km |
| 85 | 256 | 128 | 165 km |
| 127 | 384 | 192 | 112 km |
| 170 | 512 | 256 | 85 km |
| 255 | 768 | 384 | 58 km |
| 341 | 1024 | 512 | 43 km |
| 511 | 1536 | 768 | 29 km |
| 682 | 2048 | 1024 | 22 km |
| 1024 | 3072 | 1536 | 14 km |
| 1365 | 4092 | 2048 | 11 km |
Some remarks on this table
This assumes the default quadratic truncation, you can always adapt the grid resolution via the
dealiasingoption, see Matching spectral and grid resolutionnlatrefers to the total number of latitude rings, see Grids. With non-Gaussian grids,nlatwill be one one less, e.g. 47 instead of 48 rings.nlonis the number of longitude points on the Full Gaussian Grid, for other grids there will be at most these number of points around the Equator.is the horizontal resolution. For a spectral model there are many ways of estimating this[^Randall2021]. We use here the square root of the average area a grid cell covers, see Effective grid resolution
Effective grid resolution
There are many ways to estimate the effective grid resolution of spectral models[^Randall2021]. Some of them are based on the wavelength a given spectral resolution allows to represent, others on the total number of real variables per area. However, as many atmospheric models do represent a considerable amount of physics on the grid (see Parameterizations) there is also a good argument to include the actual grid resolution into this estimate and not just the spectral resolution. We therefore use the average grid cell area to estimate the resolution
with trunc=85 can resolve the atmospheric dynamics at a scale of 165km.
Derivatives in spherical coordinates
Horizontal gradients in spherical coordinates are defined for a scalar field
However, the divergence of a vector field
and similar for the curl
The radius of the sphere (i.e. Earth) is
Starting with a spectral field of vorticity
The velocities
How the operators
Zonal derivative
The zonal derivative of a scalar field
So for every spectral harmonic,
Meridional derivative
The meridional derivative of the spherical harmonics is a derivative of the Legendre polynomials for which the following recursion relation applies[^Randall2021], [^Durran2010], [^GFDL], [^Orszag70]
with recursion factors
In the following we use the example of obtaining the zonal velocity
we multiply with
at which point the recursion from above can be applied. Collecting terms proportional to
To obtain the coefficient of each spherical harmonic
In SpeedyWeather.jl, vector quantities like
Divergence and curl in spherical harmonics
The meridional gradient as described above can be applied to scalars, such as
The spectral transform of vorticity
Given that
which can be solved through integration by parts. As
remains. Inserting the recurrence relation from the Meridional derivative turns this into
Now we expand
And the divergence
Laplacian
The spectral Laplacian is easily applied to the coefficients
This can be easily inverted to obtain the stream function
See also Horizontal diffusion and Normalization of diffusion.
U, V from vorticity and divergence
After having discussed the zonal and meridional derivatives with spherical harmonics as well as the Laplace operator, we can derive the conversion from vorticity
We have moved the scaling with the radius
References
[^Malardel2016]: Malardel S, Wedi N, Deconinck W, Diamantakis M, Kühnlein C, Mozdzynski G, Hamrud M, Smolarkiewicz P. A new grid for the IFS. ECMWF newsletter. 2016; 146(23-28):321. doi: 10.21957/zwdu9u5i
[^Gorski2004]: Górski, Hivon, Banday, Wandelt, Hansen, Reinecke, Bartelmann, 2004. HEALPix: A FRAMEWORK FOR HIGH-RESOLUTION DISCRETIZATION AND FAST ANALYSIS OF DATA DISTRIBUTED ON THE SPHERE, The Astrophysical Journal. doi:10.1086/427976
[^Willmert2020]: Justin Willmert, 2020. justinwillmert.com
Introduction to Associated Legendre Polynomials (Legendre.jl Series, Part I)
Calculating Legendre Polynomials (Legendre.jl Series, Part II)
Pre-normalizing Legendre Polynomials (Legendre.jl Series, Part III)
Maintaining numerical accuracy in the Legendre recurrences (Legendre.jl Series, Part IV)
Numerical Accuracy of the Spherical Harmonic Recurrence Coefficient (Legendre.jl Series Addendum)
More Notes on Calculating the Spherical Harmonics: Analysis of maps to harmonic coefficients
[^Daley78]: Roger Daley & Yvon Bourassa (1978) Rhomboidal versus triangular spherical harmonic truncation: Some verification statistics, Atmosphere-Ocean, 16:2, 187-196, DOI: 10.1080/07055900.1978.9649026
[^Randall2021]: David Randall, 2021. An Introduction to Numerical Modeling of the Atmosphere, Chapter 22.
[^Durran2010]: Dale Durran, 2010. Numerical Methods for Fluid Dynamics, Springer. In particular section 6.2, 6.4.
[^GFDL]: Geophysical Fluid Dynamics Laboratory, The barotropic vorticity equation.
[^FFT]: Depending on the implementation of the Fast Fourier Transform (Cooley-Tukey algorithm, or or the Bluestein algorithm) easily Fourier-transformable can mean different things: Vectors of the length
[^Bourke72]: Bourke, W. An Efficient, One-Level, Primitive-Equation Spectral Model. Mon. Wea. Rev. 100, 683–689 (1972). doi:10.1175/1520-0493(1972)100<0683:AEOPSM>2.3.CO;2
[^Orszag70]: Orszag, S. A., 1970: Transform Method for the Calculation of Vector-Coupled Sums: Application to the Spectral Form of the Vorticity Equation. J. Atmos. Sci., 27, 890–895, 10.1175/1520-0469(1970)027<0890:TMFTCO>2.0.CO;2.