This routine will expand a grid containing N samples in both longitude and latitude (or N x 2N, see sampling) into spherical harmonics. This routine makes use of the sampling theorem presented in Driscoll and Healy (1994) and employs FFTs when calculating the sine and cosine terms. The number of samples, N, must be EVEN for this routine to work, and the spherical harmonic expansion is exact if the function is band limited to degree N/2-1. Legendre functions are computed on the fly using the scaling methodology presented in Holmes and Featherston (2002). When norm is 1,2 or 4, these are accurate to about degree 2800. When norm is 3, the routine is only stable to about degree 15.
Parameters: |
|
---|---|
Returns: | coefficients array of shape (2, l+1, l+1) where l=max(degmax, lmax_calc) |
Return type: | numpy array |
This routine will expand a set of discrete data points into spherical harmonics using a least squares inversion. When there are more data points than spherical harmonic coefficients (len(d) > (lmax+1)**2) the solution of the overdetermined system will be determined by least squares. If there are more coefficients than data points, then the solution of the underdetermined system will be determined by minimizing the solution norm. (See LAPACK DGELS documentation).
Note that this routine takes lots of memory (~ 8*nmax*(lmax+1)**2 bytes) and is very slow for large lmax.
Parameters: |
|
---|---|
Returns: | coefficients array of shape (2, lmax+1, lmax+1) |
Return type: | numpy array |
Returns: | residual sum of squares misfit for an overdetermined inversion |
Return type: | real |
Given the Spherical Harmonic coefficients cilm, this routine will compute a 2D grid with equal latitude and longitude spacings. The spacing is determined based on the bounding coordinate values represented by north, south, east, west and the number of latitude and longitude points - ny, nx respectively. If the mix of these values does not produce equal spacing in both latitude and longitude, then the program will raise an error.
The values in the returned grid are in the order of latitude going from 90 to -90 and longitudes going from 0 to 360 (both these longitudes present in the returned grid). If the optional parameters north, south, east and west are specified, the upper-left and lower right coordinates of the output grid are (north, west) and (south, east), respectively.
Note that since this routined does not use FFTs, this routine is therefore slower than MakeGridDH. However MakeGridDH does not allow for the specification of arbitray dimensions of the returned grid.
Parameters: |
|
---|---|
Returns: | 2D grid that has been constructed from the coefficients. If sampling==1, the shape of the array is (N,N) and for sampling==2 the shape is (N,2N), where N=2*l+1. |
Return type: | numpy array |
Parameters: |
|
---|---|
Returns: | 2D grid that has been constructed from the coefficients. If sampling==1, the shape of the array is (N,N) and for sampling==2 the shape is (N,2N), where N=2*l+1. |
Return type: | numpy array |