# Path: data_cube_utilities/plotter_utils_consts.py



import numpy as np
from numpy import fft
from .plotter_utils_consts import n_pts_smooth, default_fourier_n_harm
    from scipy.optimize import curve_fit
    from .scale import np_scale
    from scipy.interpolate import CubicSpline
    from scipy.ndimage.filters import gaussian_filter1d
    Fits a polynomial of any positive integer degree to some data - x and y. Returns predicted interpolation values.

    Parameters
    ----------
    x: list-like
        The x values of the data to fit to.
    y: list-like
        The y values of the data to fit to.
    x_smooth: list-like
        The exact x values to interpolate for. Supercedes `n_pts`.
    n_pts: int
        The number of evenly spaced points spanning the range of `x` to interpolate for.
    degree: int
        The degree of the polynomial to fit.

    Returns
    -------
    x_smooth, y_smooth: numpy.ndarray
        The smoothed x and y values of the curve fit.
    """
    if x_smooth is None:
        x_smooth_inds = np.linspace(0, len(x)-1, n_pts)
        x_smooth = np.interp(x_smooth_inds, np.arange(len(x)), x)
    y_smooth = np.array([np.array([coef * (x_val ** current_degree) for
                                   coef, current_degree in zip(np.polyfit(x, y, degree),
                                                               range(degree, -1, -1))]).sum() for x_val in x_smooth])
    return x_smooth, y_smooth


def fourier_fit(x, y, n_predict=0, x_smooth=None, n_pts=n_pts_smooth,

# Path: data_cube_utilities/plotter_utils_consts.py



# Path: data_cube_utilities/curve_fitting.py
import numpy as np
from numpy import fft
from .plotter_utils_consts import n_pts_smooth, default_fourier_n_harm
    from scipy.optimize import curve_fit
    from .scale import np_scale
    from scipy.interpolate import CubicSpline
    from scipy.ndimage.filters import gaussian_filter1d

    Fits a polynomial of any positive integer degree to some data - x and y. Returns predicted interpolation values.

    Parameters
    ----------
    x: list-like
        The x values of the data to fit to.
    y: list-like
        The y values of the data to fit to.
    x_smooth: list-like
        The exact x values to interpolate for. Supercedes `n_pts`.
    n_pts: int
        The number of evenly spaced points spanning the range of `x` to interpolate for.
    degree: int
        The degree of the polynomial to fit.

    Returns
    -------
    x_smooth, y_smooth: numpy.ndarray
        The smoothed x and y values of the curve fit.
    """
    if x_smooth is None:
        x_smooth_inds = np.linspace(0, len(x)-1, n_pts)
        x_smooth = np.interp(x_smooth_inds, np.arange(len(x)), x)
    y_smooth = np.array([np.array([coef * (x_val ** current_degree) for
                                   coef, current_degree in zip(np.polyfit(x, y, degree),
                                                               range(degree, -1, -1))]).sum() for x_val in x_smooth])
    return x_smooth, y_smooth


def fourier_fit(x, y, n_predict=0, x_smooth=None, n_pts=n_pts_smooth,

                n_harm=default_fourier_n_harm):