finesse.utilities.polyfit.polyfit2d¶
- finesse.utilities.polyfit.polyfit2d(x, y, z, kx, ky, *, order=None, weights=None)[source]¶
- Two dimensional polynomial fitting by least squares. Fits the functional form f(x,y) = z. - Parameters:
- x, y: array-like, 1d
- x and y coordinates. 
- z: np.ndarray, 2d
- Surface to fit. 
- kx, ky: int
- Polynomial order in x and y, respectively. 
- order: int or None
- If None, all coefficients up to maxiumum kx, ky, ie. up to and including x^kx*y^ky, are considered. If int, coefficients up to a maximum of kx+ky <= order are considered. 
- weight: array_like, 2d
- Weighting to use for fit. Same dimenstions as z 
 
- Returns:
- Return parameters from np.linalg.lstsq.
- soln: np.ndarray
- Array of polynomial coefficients. 
- residuals: np.ndarray
- rank: int
- s: np.ndarray
 
 - Notes - Resultant fit can be evaluated with - polyfit2d_eval().- Based on code from: https://stackoverflow.com/questions/33964913/equivalent-of-polyfit-for-a-2d-polynomial-in-python