math

  • Special functions of mathematical physics

Source code

pyTMD.math.asec2rad(x: float | ndarray)[source]

Convert angles from arcseconds to radians

Parameters:
x: float or np.ndarray

Input angle (arcseconds)

pyTMD.math.masec2rad(x: float | ndarray)[source]

Convert angles from microarcseconds to radians

Parameters:
x: float or np.ndarray

Input angle (microarcseconds)

pyTMD.math.rad2asec(x: float | ndarray)[source]

Convert angles from radians to arcseconds

Parameters:
x: float or np.ndarray

Input angle (radians)

pyTMD.math.rad2masec(x: float | ndarray)[source]

Convert angles from radians to microarcseconds

Parameters:
x: float or np.ndarray

Input angle (radians)

pyTMD.math.polynomial_sum(coefficients: list | ndarray, t: ndarray)[source]

Calculates the sum of a polynomial function using Horner’s method [28]

Parameters:
coefficients: list or np.ndarray

Leading coefficient of polynomials of increasing order

t: np.ndarray

Time for a given astronomical longitudes calculation

pyTMD.math.normalize_angle(theta: float | ndarray, circle: float = 360.0)[source]

Normalize an angle to a single rotation

Parameters:
theta: float or np.ndarray

Angle to normalize

circle: float, default 360.0

Circle of the angle

pyTMD.math.radius(x: float | ndarray, y: float | ndarray, z: float | ndarray)[source]

Calculate the radius from the origin to a point in 3-dimensional space

Parameters:
x: float or np.ndarray

x-coordinate of the point

y: float or np.ndarray

y-coordinate of the point

z: float or np.ndarray

z-coordinate of the point

pyTMD.math.rotate(theta: float | ndarray, axis: str = 'x')[source]

Rotate a 3-dimensional matrix about a given axis

Parameters:
theta: float or np.ndarray

Angle of rotation (radians)

axis: str, default ‘x’

Axis of rotation ('x', 'y', or 'z')

pyTMD.math.scalar_product(x: float | ndarray, y: float | ndarray, z: float | ndarray, u: float | ndarray, v: float | ndarray, w: float | ndarray)[source]

Calculate the scalar product of two vectors in 3-dimensional space

Parameters:
x: float or np.ndarray

x-coordinate of the first vector

y: float or np.ndarray

y-coordinate of the first vector

z: float or np.ndarray

z-coordinate of the first vector

u: float or np.ndarray

x-coordinate of the second vector

v: float or np.ndarray

y-coordinate of the second vector

w: float or np.ndarray

z-coordinate of the second vector

pyTMD.math.aliasing(f: float, fs: float) float[source]

Calculate the aliasing frequency of a signal

Parameters:
f: float

Frequency of the signal

fs: float

Sampling frequency of the signal

Returns:
fa: float

Aliasing frequency of the signal

pyTMD.math.legendre(l: int, x: ndarray, m: int = 0, norm: float = 1.0)[source]

Computes associated Legendre functions and their first-derivatives for a particular degree and order [27, 46]

Parameters:
l: int

Degree of the Legendre polynomials

x: np.ndarray

Elements ranging from -1 to 1

Typically \(\cos(\theta)\), where \(\theta\) is the colatitude

m: int, default 0

Order of the Legendre polynomials (\(0\) to \(l\))

norm: float, default 1.0

Normalization to apply to outputs

Returns:
Plm: np.ndarray

Legendre polynomials of degree \(l\) and order \(m\)

dPlm: np.ndarray

First derivative of spherical harmonics with respect to \(\theta\)

pyTMD.math._assoc_legendre(l: int, m: int, x: ndarray)[source]

Computes associated Legendre polynomials using equation 1.67 from Hofmann-Wellenhof and Moritz [27]

Parameters:
l: int

Degree of the Legendre polynomials

m: int

Order of the Legendre polynomials (\(0\) to \(l\))

x: np.ndarray

Elements ranging from -1 to 1

Typically \(\cos(\theta)\), where \(\theta\) is the colatitude

Returns:
Plm: np.ndarray

Legendre polynomials of degree \(l\) and order \(m\)

pyTMD.math._condon_shortley(m: int)[source]

Computes the Condon-Shortley phase

Parameters:
m: int

Order of the Legendre polynomials

pyTMD.math._legendre_norm(l: int, m: int)[source]

Calculates the Legendre Polynomial normalization from Munk et al. [46]

Parameters:
l: int

Degree of the Legendre polynomials

m: int

Order of the Legendre polynomials (\(0\) to \(l\))

pyTMD.math.sph_harm(l: int, theta: ndarray, phi: ndarray, m: int = 0, phase: float = 0.0)[source]

Computes the spherical harmonics for a particular degree and order [27, 46]

Parameters:
l: int

Degree of the spherical harmonics

theta: np.ndarray

Colatitude (radians)

phi: np.ndarray

Longitude (radians)

m: int, default 0

Order of the spherical harmonics (\(0\) to \(l\))

phase: float, default 0.0

Phase shift (radians)

Returns:
Ylm: np.ndarray

Complex spherical harmonics of degree \(l\) and order \(m\)

dYlm: np.ndarray

First derivative of spherical harmonics with respect to \(\theta\)