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
, degreen
and wave-number-related variablej
. 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 variablej
and degreen
. 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, itsnmax
,ordering
andpnmj
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
. Useget_ordering_types()
to get all supported ordering schemes.
- Returns:
out – A
Pnmj
class instance- Return type:
- 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
. Useget_ordering_types()
to get all supported ordering schemes.
- Returns:
out – A
Pnmj
class instance- Return type:
- 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
, orderm
and wave-number-related valuej
.- Parameters:
- Returns:
out – Fourier coefficient of degree
n
, orderm
and wave-number-related valuej
.- 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-numberk
of a Fourier coefficient of fully-normalized associated Legendre function of degreen
.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 variablej
.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
- pyharm.leg.fourier_coeffs(nmax, ordering=0)#
Computes Fourier coefficients of Legendre functions up to degree
nmax
using theordering
ordering scheme of coefficients.- Parameters:
nmax (integer) – Maximum harmonic degree
ordering (integer) – Ordering scheme of Fourier coefficients, optional. Default value is
PMNJ
. UsePnmj.get_ordering_types()
to get all supported ordering schemes.
- Returns:
out – Fourier coefficients
- Return type: