Using chi2 instead of reduced_chi2 to avoid division by zero when there are few pixels.