ctdcal.fit_ctd.apply_polyfit¶
- ctdcal.fit_ctd.apply_polyfit(y, y_coefs, *args)[source]¶
Apply a polynomial correction to series of data. Coefficients should be provided in increasing order (i.e., a0, a1, a2 for y_fit = y + a2 * y ** 2 + a1 * y + a0)
For the independent variables (y), coefficients start from the zero-th order (i.e., constant offset). For dependent variables (args), coefficients start from the first order (i.e., linear term).
- Parameters
- Returns
fitted_y – Independent variable data with polynomial fit correction applied
- Return type
array-like
Examples
Behavior without additional args:
>>> y = [2, 4, 6] >>> apply_polyfit(y, (1, 2, 3)) # y0 = 1; y1 = 2; y2 = 3 array([ 19., 61., 127.])
where fitted_y = y + y0 + (y1 * y) + (y2 * y ** 2)
Behavior with additional args:
>>> y = [2, 4, 6] >>> x = [1, 2, 3] >>> apply_polyfit(y, (1,), (x, (2, 3))) # y0 = 1; x1 = 2; x2 = 3 array([ 8., 21., 40.])
where fitted_y = y + y0 + (x1 * x) + (x2 * x ** 2)