bluemira.utilities.fit_tools
Fitting tools
Functions
|
Fit a polynomial surface to a 3-D data set. |
|
Reorder powers index to order by power from 1st to nth index. |
Module Contents
- bluemira.utilities.fit_tools.surface_fit(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, order: int = 2, n_grid: int = 30) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, list[float], float]
Fit a polynomial surface to a 3-D data set.
- Parameters:
x (numpy.ndarray) – The x values of the data set
y (numpy.ndarray) – The y values of the data set
z (numpy.ndarray) – The z values of the data set
order (int) – The order of the fitting polynomial
n_grid (int) – The number of gridding points to use on the x and y data
- Returns:
x2d – The gridded x data (i, j indexed)
y2d – The gridded y data (i, j indexed)
zz – The gridded z fit data (i, j indexed)
coeffs – The list of polynomial coefficents
r2 – The R^2 score of the fit
- Raises:
ValueError – x, y and z are not of equal length
- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, list[float], float]
Notes
The coefficients are ordered by power, and by x and y. For an order = 2 polynomial, the resultant equation would be:
\(c_{1}x^{2}+c_{2}y^{2}+c_{3}xy+c_{4}x+c_{5}y+c_{6}\)
- bluemira.utilities.fit_tools.powers_arange(powers: numpy.ndarray) list[int]
Reorder powers index to order by power from 1st to nth index.
- Parameters:
powers (numpy.ndarray) – array of powers
- Return type:
index to rearrange array