find_knots¶
- sofia_redux.toolkit.splines.spline_utils.find_knots(coordinates, knots, valid_knot_start, valid_knot_end)[source]¶
Find the knot indices for an array of coordinates.
The knot index (i) for a given coordinate (x) is defined such that knot[i] <= x < knot[i + 1]. Coordinates that are less than the minimum valid knot are set to the minimum valid knot index, and values that are greater than the maximum valid knot are set to the maximum valid knot index - 1.
- Parameters:
- coordinatesnumpy.ndarray (float)
The coordinates of shape (n_dimensions, m) where m are the number of coordinates.
- knotsnumpy.ndarray (float)
The knots in each dimension of shape (n_dimensions, max_knot_estimate). Must be monotonically increasing for each dimension.
- valid_knot_startnumpy.ndarray (int)
The start indices for the first valid knot in each dimension. For a spline of degree k, this should be k. The shape is (n_dimensions,).
- valid_knot_endnumpy.ndarray (int)
The last valid knot index in each dimension of shape (n_dimensions,). for a spline of degree k, this should be n_knots - degree - 1.
- Returns:
- knot_indicesnumpy.ndarray (int)
The knot index for each coordinate in each dimension of shape (n_dimensions, m).