smooth_values_at¶
- sofia_redux.scan.utilities.numba_functions.smooth_values_at(data, kernel, indices, kernel_reference_index, knots, coefficients, degrees, panel_mapping, panel_steps, knot_steps, nk1, spline_mapping, weight=None, valid=None)[source]¶
Return the values of data, smoothed by a kernel at the given indices.
A “smooth value” is one in which the convolution of the data with a kernel centered over a specific point is calculated and returned. This function is essentially a wrapper around
smooth_value_at()
to process multiple points in a single pass. This is a moderately low-level function, and requires a spline representation of the kernel to have been previously defined (seesofia_redux.toolkit.splines.spline.Spline
for further details).If the indices align perfectly with existing data indices (i.e., the difference between the
indices
andkernel_reference_index
can be represented exactly as an integer), no spline representation is required as direct convolution with the kernel is possible.- Parameters:
- datanumpy.ndarray (float)
The data from which to calculate smoothed values. Must be an array of arbitrary shape, but have n_dimensions.
- kernelnumpy.ndarray (float)
The kernel to smooth with. Must be an array of arbitrary shape, but match the same number of dimensions as
data
.- indicesnumpy.ndarray (int)
The indices in relation to
data
for which to calculate smoothed values. Must be of shape (n_dimensions, n) and use numpy dimensional ordering (y, x).- kernel_reference_indexnumpy.ndarray (int)
The kernel reference index specifying the center of the kernel. Must be of shape (n_dimensions,) and use numpy dimensional ordering (y, x).
- knotsnumpy.ndarray (float)
The knots as calculated by the
Spline
object onkernel
. These should be of shape (n_dimensions, max_knots) where max_knots is the maximum possible number of knots for a spline representation ofkernel
over all dimensions. Dimensions should be ordered as (x, y).- coefficientsnumpy.ndarray (float)
The spline coefficients of shape (n_coefficients,).
- degreesnumpy.ndarray (int)
- The spline degrees for each dimension of shape (n_dimensions,).
Dimensions should be ordered as (x, y).
- panel_mappingnumpy.ndarray (int)
The panel mapping translation for the spline fit. Should be of shape (n_dimensions, n_panels). Dimensions should be ordered as (x, y).
- panel_stepsnumpy.ndarray (int)
The panel steps translation for the spline fit. Should be of shape (n_dimensions,). Dimensions should be ordered as (x, y).
- knot_stepsnumpy.ndarray (int)
The spline knot steps translation for the spline fit. Should be of shape (n_dimensions,). Dimensions should be ordered as (x, y).
- nk1numpy.ndarray (int)
Another spline mapping parameter which is equal to n_knots - degrees - 1 for the spline. Should be of shape (n_dimensions,). Dimensions should be ordered as (x, y).
- spline_mappingnumpy.ndarray (int)
A spline mapping translation for the spline knots. Should be of shape (n_dimensions, max_knots). Dimensions should be ordered as (x, y).
- weightnumpy.ndarray (float), optional
The optional
data
weights. Should have the same shape asdata
.- validnumpy.ndarray (bool), optional
An optional array that marks good
data
values as True, and all others that should not be used in the fit asFalse
. Should be the same shape asdata
.
- Returns:
- smooth_values, smooth_weightsnumpy.ndarray, numpy.ndarray
The smoothed values and weights as determined by convolution of
data
withkernel
, and possibly adjusted for position by a spline fit. Both will be of shape (n,) matching the number of indices passed in as an argument.
Notes
For the purposes of debugging, please remember that any spline parameters have their dimensionality expressed in (x, y, z, …) order, but all other parameters (such as
indices
) use native numpy ordering (…, z, y, x). If the parameters were calculated (as expected) via the spline class and other nativesofia_scan
functions, then no conversion is necessary. However, if any of these parameters were manually created, please be aware of this difference.