Linear Fit routine. This will allow errors on the Y values, and will report chi squared. Borrowed from pamguard, https://sourceforge.net/projects/pamguard/.
do fit with uniform weights or weight=0 where fill is found.
do fit with weights. X and Y must not contain fill where sig>0.
return the result A, the intercept, of the fit y = A + B * x
return the result B, the slope, of the fit y = A + B * x
return the Chi-Squared result from the fit.
return the intercept (A of linear fit equation) as a datum with units of y.
return the slope (B of linear fit equation) as a datum with units of Yunits/Xunits. Note the current version of the library is unable to do many unit calculations.