build_observation

sofia_redux.toolkit.splines.spline_utils.build_observation(coordinates, values, weights, n_coefficients, bandwidth, degrees, knots, knot_steps, start_indices, next_indices, panel_mapping, spline_mapping)[source]

Build the spline observation matrices.

The observation matrices are used to solve the linear system of equations Ax = B in row-echelon form. A and B (amat and beta) may be used to solve for x using either back_substitute() if A is full rank, or solve_rank_deficiency() if A is rank deficient.

Parameters:
coordinatesnumpy.ndarray (float)

The m coordinates to fit (n_dimensions, m).

valuesnumpy.ndarray (float)

The values at each coordinate (m,).

weightsnumpy.ndarray (float)

The associated weight value for each coordinate (m,).

n_coefficientsint

The number of coefficients to fit.

bandwidthint

The bandwidth of the observation.

degreesnumpy.ndarray (int)

The degrees of the splines to fit (n_dimensions,).

knotsnumpy.ndarray (float)

The knots in each dimension of shape (n_dimensions, max_knot_estimate). Must be monotonically increasing for each dimension.

knot_stepsnumpy.ndarray (int)

The flat index mapping steps in knot-space of shape (n_dimensions,). These are returned by passing the shape (n_knots - degrees - 1) into flat_index_mapping().

start_indicesnumpy.ndarray (int)

The starting indices of shape (m,) as returned by create_ordering().

next_indicesnumpy.ndarray (int)

The next indices of shape (m,) as returned by create_ordering().

panel_mappingnumpy.ndarray (int)

An array containing the panel mapping (flat to n-D) indices. This is created by passing the panel shape (n_knots - (2 * degrees) - 1) into flat_index_mapping(). Should be an array of shape (n_dimensions, n_panels).

spline_mappingnumpy.ndarray (int)

An array containing the spline mapping (flat to n-D) indices. This is created by passing the spline shape (degrees + 1) into flat_index_mapping(). Should be an array of shape (n_dimensions, n_spline_coefficients).

Returns:
amat, beta, knot_splines, ssrarray, array, array, float

The observation matrix amat of shape (n_coefficients, bandwidth), the observation matrix beta of shape (n_coefficients,), the base spline coefficients for each knot (n_dimensions, n_knots, max(degree) + 1), and ssr (sum of the residuals squared)