KeplerGO / pyke

Easy command line tools for Kepler, K2 & TESS data analysis.
http://pyke.keplerscience.org
118 stars 35 forks source link

Consider using scikit-learn's robust linear estimator fitting inside `SFFCorrector` #174

Open barentsen opened 6 years ago

barentsen commented 6 years ago

Right now, in SFFCorrector, we fit the motion polynomials as follows:

            # Next, we fit the motion polynomial after removing outliers
            self.outlier_cent = sigma_clip(data=self.rot_col,
                                           sigma=sigma_2).mask
            coeffs = np.polyfit(self.rot_row[~self.outlier_cent],
                                self.rot_col[~self.outlier_cent], polyorder)
            self.poly = np.poly1d(coeffs)
            self.polyprime = np.poly1d(coeffs).deriv()

The fitting is made robust by applying sigma-clipping before polyfit. This isn't great because the sigma-clipping is not relative to e.g. the running mean.

It may be better to use a different robust fitting technique, e.g. see here: http://scikit-learn.org/stable/auto_examples/linear_model/plot_robust_fit.html