check_edges¶
- sofia_redux.toolkit.resampling.check_edges(coordinates, reference, mask, threshold, algorithm=1)[source]¶
Determine whether a reference position is within a distribution “edge”.
The purpose of this function is to allow the resampling algorithm to determine whether a fit should be performed at a
reference
location given a sample distribution ofcoordinates
. If a fit is attempted too far from the mean sample distribution, it will lead to a misleading result which becomes more pronounced at higher fit orders.Therefore, the sample distribution is assigned an “edge” based on one of four definitions. If the
reference
position is outside of this edge, aFalse
value will be returned, and no fitting will occur.For all edge definition algorithms, the
threshold
parameter will determine the distance of the edge from the sample mean. Asthreshold
is increased, the edge approaches the sample mean resulting in a more severe clipping of fit locations away from the center of a distribution. Ifthreshold
= 0, no edge clipping will occur.Since the main engine of the resampling algorithm relies on
numba
, the edgealgorithm
should be supplied as an integer. Please see the relevant function listed below for further details on how the “edge” is defined.algorithm
Function
1
2
3
4
Generally, algorithms are ordered from most to least robust, and slowest to fastest, so, the default (1) is considered the most robust (although slowest) of the available algorithms.
When dealing with more than one dimension, the
check_edge_with_distribution()
algorithm is recommended as it accounts for the shape of the distribution. If the sample distribution is unknown (as opposed to a set of uniformly spaced coordinates), there is a chance for some samples to be (or to approach) a collinear distribution. Attempting a fit at any location in a tangential direction away from the distribution would likely result in a very poor fit.- Parameters:
- coordinatesnumpy.ndarray (n_dimensions, n_samples)
The coordinates of the sample distribution.
- referencenumpy.ndarray (n_dimensions,)
The reference coordinate to test.
- masknumpy.ndarray of bool (n_samples,)
A mask where
True
values indicate a sample should be included in the edge determination.- thresholdnumpy.ndarray (n_dimensions,)
A threshold parameter determining how close an edge should be to the center of the distribution. Higher values result in an edge closer to the sample mean. A value should be provided for each dimension. A zero value in any dimension will result in an infinite edge for that dimension.
- algorithmint, optional
Integer specifying which edge definition to use. Please see above for the associated functions. Invalid choices will disable edge checking.
- Returns: