shxarray.shlib#

shlib is shxarray’s default binary Cython backend. Some of the heavy lifting such as synthesis and analysis operations, is done using this the functions of this shared library.

class shxarray.shlib.Analysis#

Bases: object

class shxarray.shlib.Pn#

Bases: object

Double precision Legendre polynomial wrapper

class shxarray.shlib.Pnm#

Bases: object

Double precision Legendre polynomial wrapper

idx(self, int n, int m)#
index(self)#
nm(self, size_t idx)#
nmax(self)#
class shxarray.shlib.SHComputeBackend#

Bases: SHComputeBackendBase

analysis(self, dain, nmax, **kwargs)#
gaunt(self, n2, n3, m2, m3)#
gauntReal(self, n2, n3, m2, m3)#
lonlat_grid(self, nmax=None, lon=None, lat=None, gtype='regular')#

Create a lon-lat grid compatible with the SHlib backend :param nmax: Maximum expected degree of the spherical harmonic expansion. :type nmax: int, optional :param gtype: Type of grid to create. Only ‘regular’,’regular_lon0’ and “point” are supported. The regular_lon0 option is a regular grid with the first longitude point at 0 degrees. :type gtype: str, optional

Return type:

An empty xarray.Dataset with CF-complying lon, lat coordinates variables

multiply(self, dash1: xr.DataArray, dash2: xr.DataArray, method='spectral') xr.DataArray#

Multiply two spherical harmonics DataArrays together (equivalent to multiplying in the spatial domain) This function uses the computation of Real Gaunt coefficients :param dash1: :type dash1: xr.DataArray :param dash2: :type dash2: xr.DataArray

Return type:

xr.DataArray

p2s(self, daobj)#
synthesis(self, dain, dslonlat, **kwargs)#
wigner3j(self, j2, j3, m2, m3)#
class shxarray.shlib.Synthesis#

Bases: object

class shxarray.shlib.Ynm#

Bases: object

Compute surface spherical harmonics in double precision

nmax#
shxarray.shlib.getGaunt(n2, n3, m2, m3)#

Compute non-zero Gaunt coefficients for valid values of n1 and m1

shxarray.shlib.getGauntReal(n2, n3, m2, m3)#

Compute non-zero Real Gaunt coefficients for valid values of n1 and m1

shxarray.shlib.getWigner3j(j2, j3, m2, m3)#

Compute non-zero Wigner3J symbols with their valid (j1,m1) for j2,j3,m2,m3 input

shxarray.shlib.getp2s(daobj)#
shxarray.shlib.multiply_sh(dash1, dash2)#

Compute the multiplication of two spherical harmonic datasets while staying in the spectral domain

shxarray.shlib.read_symmat_fast(fileobj, dsout, blockname)#
Reads a triangular matrix from a SINEX block and returns a symmetric version (Cython version)

This version is optimized and uses the following tricks 1. Direct access through a character pointer to the data of a unicode object (line of the files) 2. Use of Cython memoryviews to avoid boiunds checking of the numpy arrays 3. Use of Cython cdef variables to avoid type checking and optimize loop 4. Use of stdlib strtol, and strod to parse the lines

Parameters:
  • fileobj – io buffer to read lines from

  • dsout (xarray.Dataset) – xarray.Dataset to augment the matrix data to

blocknamestr

name of the SINEX block. should be one of: SOLUTION/NORMAL_EQUATION_MATRIX U SOLUTION/NORMAL_EQUATION_MATRIX L

Return type:

an updated xarray.Dataset holding the new matrix in a new variable ‘N’