check_orders_with_counts

sofia_redux.toolkit.resampling.check_orders_with_counts(orders, counts, mask=None, minimum_points=None, n_dimensions=None, required=False)[source]

Checks maximum order based only on the number of samples.

For \(N\) samples of \(K\) dimensional data, the minimum number of samples required to perform a polynomial fit with orders \(o\) is:

\[N_{min} = \prod_{k=1}^{K}{(o_k + 1)}\]

if \(o_k = o_0, \, \forall k\), then it is possible to suggest a lower order over all dimensions in the case where \(N < N_{min}\). This is given as:

\[o_k^{max} = min\{ floor(N ^ {1 / K} - 1), o_k \}\]

The suggested maximum order is returned by setting the required keyword to False. If the orders vary between dimensions or required is True, the value of \(o_0\) is set to -1 indicating a polynomial fit of the desired order is not possible.

Parameters:
ordersnumpy.ndarray of int

The desired order of the fit as a (1,) or (n_dimensions,) array. If only a single value is supplied, it will be applied over all dimensions. This serves as an upper limit for the check. If the samples are distributed in a way that allows for a fit to be performed using orders, the return value will also be orders.

countsint

The number of samples available for the fit.

masknumpy.ndarray of bool (n_coordinates,), optional

An optional mask where False values indicate the associated sample should not be included in determining the maximum order. The counts parameter will be ignored in favor of sum(mask).

minimum_pointsint, optional

The minimum number of points required to perform a fit of the desired order, optionally passed in for speed.

n_dimensionsint, optional

If orders was supplied as an array of size 1, but should be applied over multiple dimensions, the number of dimensions should be supplied. Otherwise, the number of dimensions is taken to be equal to the number of orders.

requiredbool, optional

If required is False, the maximum available order given the distribution will be returned (up to a maximum of orders). If required is True, and the maximum available order is less than orders, the first element of the return value will be set to -1, indicating the criteria was not met.

Returns:
maximum_ordersnumpy.ndarray

An array of shape (1,) or (n_dimensions,) based on whether a single orders was passed in for all dimensions, or each dimension has a separate order requirement. If required was set to True, and the sample distribution did not allow for the requested order, the first element will be set to -1. Unlike check_orders_with_bounds() or check_orders_without_bounds(), a suggested maximum order can only be returned by setting required to False if orders are equal in all dimensions. Otherwise, it is impossible to know which dimension the order should be reduced for. In this case, the first element of maximum_orders will be set to -1.