import matplotlib.pyplot as plt
import numpy as np
from spectractor.tools import fit_poly1d_legendre
p = [-1e-6, -1e-4, 1, 1]
x = np.arange(500., 1000., 1)
y = np.polyval(p, x)
err = np.ones_like(y)
fit, cov2, model2 = fit_poly1d_legendre(x,y,order=3,w=err)
plt.errorbar(x,y,yerr=err,fmt='ro')
plt.plot(x,model2)
plt.show()