pyharm.leg#

Module to work with the fully-normalized associated Legendre functions of the first kind:

  • defines the pyharm.leg.Pnmj class to store Fourier coefficients of the Legendre functions,

  • computes Fourier coefficients of Legendre functions.

Note

This documentation is written for double precision version of PyHarm.

pyharm.leg.PMNJ: int = 0#

Ordering scheme of Fourier coefficients of Legendre functions: order m, degree n and wave-number-related variable j. For further details, refer to charm_leg.

Type:

int

pyharm.leg.PMJN: int = 1#

Ordering scheme of Fourier coefficients of Legendre functions: order m, wave-number-related variable j and degree n. For further details, refer to charm_leg.

Type:

int

class pyharm.leg.Pnmj(nmax, ordering, coeffs)#

Class for Fourier coefficients of fully-normalized associated Legendre functions of the first kind.

To create a Pnmj class instance, always use one of the following factory methods:

Examples

>>> import pyharm
>>> pnmj = pyharm.leg.Pnmj.from_garbage(10)
Parameters:
  • nmax (integer) – Maximum harmonic degree

  • ordering (integer) – Ordering scheme of Fourier coefficients. Use get_ordering_types() to get all supported ordering schemes.

  • coeffs (None or 0) –

    Determines the way of initializing Fourier coefficients:

    • None to not initialize Fourier coefficients (malloc in C),

    • 0 to set all Fourier coefficients to zero (calloc in C).

Note

Once a Pnmj class instance is created, its nmax, ordering and pnmj attributes are not writable.

For details, refer to charm_leg.

property nmax#

Maximum harmonic degree of the Fourier coefficients.

property ordering#

Ordering scheme of the Fourier coefficients. Use the get_ordering_str() method to transform the attribute to a pretty string.

property pnmj#

Fourier coefficients.

classmethod from_garbage(nmax, ordering=0)#

Returns a Pnmj class instance with uninitialized Fourier coefficients (malloc in C).

Parameters:
  • nmax (integer) – Maximum harmonic degree

  • ordering (integer) – Ordering scheme of Fourier coefficients, optional. Default value is PMNJ. Use get_ordering_types() to get all supported ordering schemes.

Returns:

out – A Pnmj class instance

Return type:

Pnmj

classmethod from_zeros(nmax, ordering=0)#

Returns a Pnmj class instance with all Fourier coefficients initialized to zero (calloc in C).

Parameters:
  • nmax (integer) – Maximum harmonic degree

  • ordering (integer) – Ordering scheme of Fourier coefficients, optional. Default value is PMNJ. Use get_ordering_types() to get all supported ordering schemes.

Returns:

out – A Pnmj class instance

Return type:

Pnmj

coeffs(nmax=None)#

Computes Fourier coefficients of Legendre functions.

Parameters:

nmax (integer) – Maximum harmonic degree, optional. If not provided, the object’s nmax attribute is used.

get_coeff(n, m, j)#

Returns Fourier coefficient of degree n, order m and wave-number-related value j.

Parameters:
  • n (integer) – Spherical harmonic degree

  • m (integer) – Spherical harmonic order

  • j (integer) – Value related to the wave-number of Fourier coefficient (refer to j2k() and k2j() for further details)

Returns:

out – Fourier coefficient of degree n, order m and wave-number-related value j.

Return type:

floating point

get_ordering_str()#

Transforms the object’s ordering attribute to a pretty string.

Returns:

out – Pretty name of the ordering attribute

Return type:

str

static j2k(n, j)#

Transforms a wave-number-related variable j to the wave-number k of a Fourier coefficient of fully-normalized associated Legendre function of degree n.

For further details, see the references at charm_leg.

Parameters:
  • n (integer) – Spherical harmonic degree of the Legendre function

  • j (integer) – Variable related to the wave-number k

Returns:

out – Wave-number k of the Fourier coefficient of a Legendre function

Return type:

integer

static k2j(k)#

Transforms a wave-number k of a Fourier coefficient of fully-normalized associated Legendre functions to the wave-number-related variable j.

For further details, see the references at charm_leg.

Parameters:

k (integer) – Wave-number

Returns:

out – Wave-number-related variable j of the Fourier coefficient of a Legendre function

Return type:

integer

static get_ordering_types()#

Prints all names of symbolic constants that are accepted as the ordering attribute of the Pnmj class.

pyharm.leg.fourier_coeffs(nmax, ordering=0)#

Computes Fourier coefficients of Legendre functions up to degree nmax using the ordering ordering scheme of coefficients.

Parameters:
  • nmax (integer) – Maximum harmonic degree

  • ordering (integer) – Ordering scheme of Fourier coefficients, optional. Default value is PMNJ. Use Pnmj.get_ordering_types() to get all supported ordering schemes.

Returns:

out – Fourier coefficients

Return type:

Pnmj