remove polynomial from data.
    used by autocorr_noise_id()
    
    Parameters
    ----------
    x: numpy.array
        time-series
    deg: int
        degree of polynomial to remove from x
        
    Returns
    -------
    x_detrended: numpy.array
        detrended time-series

def detrend(x, deg=1):
    """
    remove polynomial from data.
    used by autocorr_noise_id()
    
    Parameters
    ----------
    x: numpy.array
        time-series
    deg: int
        degree of polynomial to remove from x
        
    Returns
    -------
    x_detrended: numpy.array
        detrended time-series
    """
    t=range(len(x))
    p = np.polyfit(t, x, deg)
    residual = x - np.polyval(p, t)
    return residual