Utility#

Interpolation#

sasktran2.util.interpolation.linear_interpolating_matrix(from_grid: array, to_grid: array, out_of_bounds_mode: str) ndarray[source]#

Constructs an interpolating matrix that can be used to interpolate from one grid to another.

Parameters:
  • from_grid (np.array) – Grid with the original values. Must be sorted in ascending order

  • to_grid (np.array) – Grid we are going to interpolate to. Must be sorted in ascending order

  • out_of_bounds_mode (str) – One of [“zero”, “extend”], “zero” will set the result to 0 outside the bounds of the original grid, “extend” will extend the lowest and highest values

Returns:

A matrix such that M @ (values on from_grid) = (values on to_grid)

Return type:

np.ndarray

Wigner Functions#

class sasktran2.util.WignerD(self: sasktran2._core.WignerD, m: int, n: int)#

Bases: pybind11_object

Performs calculations of the Wigner (small) d function, \(d^l_{m, n}(\theta)\).

First, this class is constructed for a given m and n, and then d() is called for a given l.

The Wigner functions are closely related to the associated Legendre polynomials, .. math:

d^l_{m, 0}(\theta) = \sqrt{\frac{(l-m)!}{(l+m)!}} P^m_l(\cos \theta)

and the regular Legendre polynomials, .. math:

d^l_{0, 0}(\theta) = P_l(\cos \theta)
Parameters:
  • m (int) – The parameter m in \(d^l_{m, n}\)

  • n (int) – The parameter n in \(d^l_{m, n}\)

d(self: sasktran2._core.WignerD, theta: numpy.ndarray[numpy.float64], l: numpy.ndarray[numpy.int32]) object#

Calculates \(d^l_{m, n}(\theta)\) for a given l, and m, n provided in the constructor. Note that only one of theta, l can be array-like, one must be scalar.

Parameters:
  • theta (numpy.ndarray[numpy.float64]) – Angles (in radians) to calculate the function at

  • l (numpy.ndarray[numpy.int32]) – The parameter n in \(d^l_{m, n}\)

Returns:

The calculated Wigner function, either scalar or the same size as theta or l, whichever is array-like.

Return type:

np.array