bluemira.utilities.fit_tools ============================ .. py:module:: bluemira.utilities.fit_tools .. autoapi-nested-parse:: Fitting tools Functions --------- .. autoapisummary:: bluemira.utilities.fit_tools.surface_fit bluemira.utilities.fit_tools.powers_arange Module Contents --------------- .. py:function:: 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. :param x: The x values of the data set :param y: The y values of the data set :param z: The z values of the data set :param order: The order of the fitting polynomial :param n_grid: 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 .. rubric:: Notes The coefficients are ordered by power, and by x and y. For an order = 2 polynomial, the resultant equation would be: :math:`c_{1}x^{2}+c_{2}y^{2}+c_{3}xy+c_{4}x+c_{5}y+c_{6}` .. py:function:: powers_arange(powers: numpy.ndarray) -> list[int] Reorder powers index to order by power from 1st to nth index. :param powers: array of powers :rtype: index to rearrange array