pyrt.decompose#

pyrt.decompose(phase_function, scattering_angles, n_moments)[source]#

Decompose a phase function into Legendre coefficients.

Parameters:
  • phase_function (ArrayLike) – 1-dimensional array of the phase function to decompose.

  • scattering_angles (ArrayLike) – 1-dimensional array of the scattering angles [degrees]. This array must have the same shape as phase_function and the angles should be monotonically increasing.

  • n_moments (int) – The number of moments to decompose the phase function into. This value must be smaller than the number of points in the phase function.

Returns:

1-dimensional array of Legendre coefficients of the decomposed phase function with a shape of (moments,).

Return type:

np.ndarray

Examples

Construct a Henyey-Greenstein phase function and decompose it into 129 moments.

>>> import numpy as np
>>> import pyrt
>>> scattering_angles = np.arange(181)
>>> pf = pyrt.construct_henyey_greenstein(0.5, scattering_angles) * 4 * np.pi
>>> coeff = pyrt.decompose(pf, scattering_angles, 129)

Compare the result of this general decomposition to the result of the formula for the Henyey-Greenstein decomposition.

>>> coeff0 = pyrt.henyey_greenstein_legendre_coefficients(0.5, 129)
>>> print(np.amax(np.abs(coeff - coeff0)) < 1e-10)
True