pypeit.core.basis module
Module implements a set of basis functions for fitting.
- pypeit.core.basis._build_basis(x, m, func)[source]
Perform initial checks of the basis function inputs.
- Parameters:
x (array-like) – Compute the basis polynomials at these abscissa values.
m (
int
) – The number of polynomials to compute. For example, if \(m = 3\), \(P_0 (x)\), \(P_1 (x)\) and \(P_2 (x)\) will be computed. Must be \(\geq1\).func (callable) – Callable function that generates the basis polynomials. E.g., scipy.special.legendre for Legendre polynomials.
- Returns:
An array of shape \((N_x, m)\) with the basis polynomials.
- Return type:
- Raises:
TypeError – Raised if the provided
func
is not callable.
- pypeit.core.basis._init_basis(x, m)[source]
Initialize the basis functions.
- Parameters:
x (array-like) – Compute the basis polynomials at these abscissa values.
m (
int
) – The number of polynomials to compute. For example, if \(m = 3\), \(P_0 (x)\), \(P_1 (x)\) and \(P_2 (x)\) will be computed. Must be \(\geq1\).
- Returns:
Returns (1) the input \(x\) array explicitly converted to a numpy.ndarray and (2) a unity array with the same data type as \(x\). The returned shape of the latter is the \((N_x, m)\).
- Return type:
- Raises:
ValueError – Raised if the input order is not at least 1.
- pypeit.core.basis.fchebyshev(x, m)[source]
Compute the first m Chebyshev polynomials.
- Parameters:
x (array-like) – Compute the Chebyshev polynomials at these abscissa values.
m (
int
) – The number of Chebyshev polynomials to compute. For example, if \(m = 3\), \(T_0 (x)\), \(T_1 (x)\) and \(T_2 (x)\) will be computed.
- Returns:
Polynomial basis functions evaluated at
x
.- Return type:
- pypeit.core.basis.fchebyshev_split(x, m)[source]
Compute the first m Chebyshev polynomials, but modified to allow a split in the baseline at \(x=0\). The intent is to allow a model fit where a constant term is different for positive and negative x.
- Parameters:
x (array-like) – Compute the Chebyshev polynomials at these abscissa values.
m (
int
) – The number of Chebyshev polynomials to compute. For example, if \(m = 3\), \(T_0 (x)\), \(T_1 (x)\) and \(T_2 (x)\) will be computed.
- Returns:
Polynomial basis functions evaluated at
x
.- Return type:
- pypeit.core.basis.flegendre(x, m)[source]
Compute the first m Legendre polynomials.
- Parameters:
x (array-like) – Compute the Legendre polynomials at these abscissa values.
m (
int
) – The number of Legendre polynomials to compute. For example, if \(m = 3\), \(P_0 (x)\), \(P_1 (x)\) and \(P_2 (x)\) will be computed.
- Returns:
Polynomial basis functions evaluated at
x
.- Return type:
- pypeit.core.basis.fpoly(x, m)[source]
Compute the first m simple polynomials.
- Parameters:
x (array-like) – Compute the simple polynomials at these abscissa values.
m (
int
) – The number of simple polynomials to compute. For example, if \(m = 3\), \(x^0\), \(x^1\) and \(x^2\) will be computed.
- Returns:
Polynomial basis functions evaluated at
x
.- Return type: