lightkurve.LightCurve.flatten#
- LightCurve.flatten(window_length=101, polyorder=2, return_trend=False, break_tolerance=5, niters=3, sigma=3, mask=None, **kwargs)[source]#
Removes the low frequency trend using scipy’s Savitzky-Golay filter.
This method wraps
scipy.signal.savgol_filter
.- Parameters
- window_lengthint
The length of the filter window (i.e. the number of coefficients).
window_length
must be a positive odd integer.- polyorderint
The order of the polynomial used to fit the samples.
polyorder
must be less than window_length.- return_trendbool
If
True
, the method will return a tuple of two elements (flattened_lc, trend_lc) where trend_lc is the removed trend.- break_toleranceint
If there are large gaps in time, flatten will split the flux into several sub-lightcurves and apply
savgol_filter
to each individually. A gap is defined as a period in time larger thanbreak_tolerance
times the median gap. To disable this feature, setbreak_tolerance
to None.- nitersint
Number of iterations to iteratively sigma clip and flatten. If more than one, will perform the flatten several times, removing outliers each time.
- sigmaint
Number of sigma above which to remove outliers from the flatten
- maskboolean array with length of self.time
Boolean array to mask data with before flattening. Flux values where mask is True will not be used to flatten the data. An interpolated result will be provided for these points. Use this mask to remove data you want to preserve, e.g. transits.
- **kwargsdict
Dictionary of arguments to be passed to
scipy.signal.savgol_filter
.
- Returns
- flatten_lc
LightCurve
New light curve object with long-term trends removed.
- If
return_trend
is set toTrue
, this method will also return: - trend_lc
LightCurve
New light curve object containing the trend that was removed.
- flatten_lc