polyexp¶
- sofia_redux.toolkit.fitting.polynomial.polyexp(order, ndim=None, indexing='j')[source]¶
Returns exponents for given polynomial orders in arbitrary dimensions.
Similar to
toolkit.resampling.resample_utils.polynomial_exponents
, but specialized for the polynomial fitting functions intoolkit.fitting
.- Parameters:
- orderint or array_like of int
Polynomial order for which to generate exponents. If an array will create full polynomial exponents over all len(order) dimensions.
- ndimint, optional
If set, return Taylor expansion for
ndim
dimensions for the givenorder
iforder
is not an array.- indexingstr, optional
{‘i’, ‘j’} If ‘i’, then if order = [nx, ny], exponents are ordered as [[y0, x0], [y1, x0], [yn, x0],…, [y1, x0]., … if ‘j’, then if order = [nx, ny], exponents are ordered as [[x0, y0], [x1, y0], [xn, y0], …, [x0, y1], …
- Returns:
- exponentsnumpy.ndarray
Polynomial exponents for the given order. Will be of shape:
order ndim shape ———- —- ————————————————— int None (order+1,) array (n,) None (array[0]+1, array[1]+1, …, array[n-1]+1) int n (ncoeffs, ndim) where ncoeffs is a Taylor expansion
Examples
>>> polyexp(3) array([0, 1, 2, 3])
>>> polyexp([1, 2], indexing='i') array([[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1]])
>>> polyexp([1, 2], indexing='j') array([[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [1, 2]])
>>> polyexp(2, ndim=2) array([[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [0, 2]])