add chisq() function and use in fit_lc()