def WavelengthErrorFunctionNew(self, pars, data, model, maxdiff=0.05):
        # xgrid = (data.x - np.median(data.x))/(data.x[-1] - data.x[0])
        #dx = chebyshev.chebval(xgrid, pars)
        dx = self.Poly(pars, np.median(data.x), min(data.x), max(data.x), data.x)
        penalty = np.sum(np.abs(dx[np.abs(dx) > maxdiff]))
        retval = (data.y / data.cont / model(data.x + dx) - 1.0) + penalty
        retval = (data.y / data.cont - model(data.x + dx)) + penalty
        return retval


    ### -----------------------------------------------
Cost function for the new wavelength fitter.
dataset/ETHPy150Open kgullikson88/Telluric-Fitter/src/TelluricFitter.py/TelluricFitter.WavelengthErrorFunctionNew