webbpsf_ext.maths.jl_poly

webbpsf_ext.maths.jl_poly(xvals, coeff, dim_reorder=False, use_legendre=False, lxmap=None, **kwargs)[source]

Evaluate polynomial

Replacement for np.polynomial.polynomial.polyval(wgood, coeff) to evaluate y-values given a set of xvals and coefficients. Uses matrix multiplication, which is much faster. Beware, the default output array shapes organization may differ from the polyval routine for 2D and 3D results.

Parameters
  • xvals (ndarray) – 1D array (time, for instance)

  • coeff (ndarray) – 1D, 2D, or 3D array of coefficients from a polynomial fit. The first dimension should have a number of elements equal to the polynomial degree + 1. Order such that lower degrees are first, and higher degrees are last.

Keyword Arguments
  • dim_reorder (bool) – If true, then result to be ordered (nx,ny,nz), otherwise we use the Python preferred ordering (nz,ny,nx)

  • use_legendre (bool) – Fit with Legendre polynomial, an orthonormal basis set.

  • lxmap (ndarray or None) – Legendre polynomials are normaly mapped to xvals of [-1,+1]. lxmap gives the option to supply the values for xval that should get mapped to [-1,+1]. If set to None, then assumes [xvals.min(),xvals.max()].

Returns

float array – An array of values where each xval has been evaluated at each set of supplied coefficients. The output shape has the first dimension equal to the number of xvals, and the final dimensions correspond to coeff’s latter dimensions. The result is flattened if there is either only one xval or one set of coeff (or both).