The SPHERE_HARM_INVERSE function uses the Gauss-Legendre algorithm to compute the inverse spherical harmonic transform of an input array, and return the result on a spherical coordinate grid, where the output latitudes are on a Gauss-Legendre grid.
The spherical harmonic transform is a useful tool for analyzing wave patterns on a global dataset, and is extensively used in meteorology and oceanography, and in the study of geomagnetic and solar magnetic fields.
The forward and inverse transforms are also useful for applying a spectral filter. In this case, the forward transform is performed, then a filtering function is applied to the spectral coefficients, and then the inverse transform is performed.
For details on the algorithm see SPHERE_HARM_FORWARD.
SPHERE_HARM_INVERSE is based on the original spherical_transform_inv routine written by Mark Miesch and modified by Marc DeRosa and Gilbert P. Compo, and is used with permission.
Example
In this example, we do a forward + inverse transform on a two-dimensional array of air temperatures from 1 Dec 1884.
restore, filepath('reanl20v3_1dec1884_512x256dbl.sav', subdir=['examples', 'data'])
ntheta = A.dim[1]
lmax = ntheta - 1
costheta = gauss_quad_legendre(-1, 1, ntheta)
B = sphere_harm_forward(A, costheta, lmax=lmax)
A1 = sphere_harm_inverse(B, costheta, lmax=lmax)
print, 'maximum error: ', max(abs(A1 - A))
IDL prints:
maximum error: 2.4930245e-09
For a more detailed example as well as data credits and reference, see SPHERE_HARM_FORWARD.
Syntax
Result = SPHERE_HARM_INVERSE( Array, Costheta, LMAX=value, PERIOD=value, /TPOOL_NOTHREAD )
Return Value
The result is a double-precision array of dimension [nphi, ntheta], where the first dimension represents the longitudes and the second dimension represents the colatitudes. The number of longitudes nphi is 2 * ntheta.
Arguments
Array
An input array of complex values, B(l, m), where the first dimension represents the degree l values and the second dimension represents the order m values.
Costheta
An input vector of length ntheta, containing the cosine of the theta colatitude points on a Gauss-Legendre grid for the output result. These values may be computed using the GAUSS_QUAD_LEGENDRE function, with integration limits –1 to 1.
Keywords
LMAX
Set this keyword to the maximum Legendre degree l to be used for the inverse transform. The default is the length of the first dimension of the input Array minus one (since l ranges from 0 to LMAX).
PERIOD
Set this keyword to an integers ≥ 1 giving the periodicity of the waves in the longitudinal direction. Only Fourier coefficients that are integer multiples of the period will be computed. For example, if your data is known to be periodic in longitude, with a wavelength of 120°, then you only need to compute the spherical harmonics over a 0° to 120° swath of longitude on the sphere. In this case you would set PERIOD=3, and you would get an expansion with only mode values of m = 0, ±3, ±6, ±9, etc.
If this keyword is > 1 then the result will have dimensions [LMAX+1, (LMAX+PERIOD) / PERIOD]. The default is PERIOD=1, which will return every m value.
Note: If you set PERIOD in your initial call to SPHERE_HARM_FORWARD, you should set the same PERIOD value when calling SPHERE_HARM_INVERSE.
TPOOL_NOTHREAD
Set this keyword to explicitly prevent IDL from using the thread pool for the computation. If this keyword is set, IDL will use the non-threaded implementation of the routine even if the current settings of the !CPU system variable would allow use of the threaded implementation.
Version History
See Also
GAUSS_QUAD_LEGENDRE, SPHERE_HARM_FORWARD, SPHERE_HARM_FILTER, SPHERE_HARM_KERNEL