pypeit.bspline.utilpy module

Implements pure python support methods for pypeit.bspline.bspline.bspline.

pypeit.bspline.utilpy.bspline_model(x, action, lower, upper, coeff, n, nord, npoly)[source]

Calculate the bspline model.

Parameters:
  • x (numpy.ndarray) – The independent variable in the fit.

  • action (numpy.ndarray) – Action matrix. See pypeit.bspline.bspline.bspline.action(). The shape of the array is expected to be nd by npoly*nord.

  • lower (numpy.ndarray) – Vector with the starting indices along the second axis of action used to construct the model.

  • upper (numpy.ndarray) – Vector with the (inclusive) ending indices along the second axis of action used to construct the model.

  • coeff (numpy.ndarray) – The model coefficients used for each action.

  • n (int) – Number of unmasked measurements included in the fit.

  • nord (int) – Fit order.

  • npoly (int) – Polynomial per fit order.

Returns:

The best fitting bspline model at all provided \(x\).

Return type:

numpy.ndarray

pypeit.bspline.utilpy.cholesky_band(l, mininf=0.0, verbose=False)[source]

Compute Cholesky decomposition of banded matrix.

This function is pure python.

Parameters:
  • l (numpy.ndarray) – A matrix on which to perform the Cholesky decomposition.

  • mininf (float, optional) – Entries in the l matrix are considered negative if they are less than this value (default 0.0).

Returns:

If problems were detected, the first item will be the index or indexes where the problem was detected, and the second item will simply be the input matrix. If no problems were detected, the first item will be -1, and the second item will be the Cholesky decomposition.

Return type:

tuple

pypeit.bspline.utilpy.cholesky_solve(a, bb)[source]

Solve the equation Ax=b where A is a Cholesky-banded matrix.

This function is pure python.

Parameters:
Returns:

A tuple containing the status and the result of the solution. The status is always -1.

Return type:

tuple

pypeit.bspline.utilpy.intrv(nord, breakpoints, x)[source]

Find the segment between breakpoints which contain each value in the array x.

The minimum breakpoint is nbkptord -1, and the maximum is nbkpt - nbkptord - 1.

Parameters:
  • nord (int) – Order of the fit.

  • breakpoints (numpy.ndarray) – Locations of good breakpoints

  • x (numpy.ndarray) – Data values, assumed to be monotonically increasing.

Returns:

Position of array elements with respect to breakpoints.

Return type:

numpy.ndarray

pypeit.bspline.utilpy.solution_arrays(nn, npoly, nord, ydata, action, ivar, upper, lower)[source]

Support function that builds the arrays for Cholesky decomposition.

Parameters:
  • nn (int) – Number of good break points.

  • npoly (int) – Polynomial per fit order.

  • nord (int) – Fit order.

  • ydata (numpy.ndarray) – Data to fit.

  • action (numpy.ndarray) – Action matrix. See pypeit.bspline.bspline.bspline.action(). The shape of the array is expected to be nd by npoly*nord.

  • ivar (numpy.ndarray) – Inverse variance in the data to fit.

  • upper (numpy.ndarray) – Vector with the (inclusive) ending indices along the second axis of action used to construct the model.

  • lower (numpy.ndarray) – Vector with the starting indices along the second axis of action used to construct the model.

Returns:

Returns (1) matrix \(A\) and (2) vector \(b\) prepared for Cholesky decomposition and used in the solution to the equation \(Ax=b\).

Return type:

tuple