detrend (pyleoclim.utils.tsutils.detrend)¶
- pyleoclim.utils.tsutils.detrend(y, x=None, method='emd', sg_kwargs=None)[source]¶
Detrend a timeseries according to four methods
- Detrending methods include, “linear”, “constant”, using a low-pass
Savitzky-Golay filter, and using eigen mode decomposition (default).
- Parameters
y (array) – The series to be detrended.
x (array) – The time axis for the timeseries. Necessary for use with the Savitzky-Golay filters method since the series should be evenly spaced.
method (str) – The type of detrending: - linear: the result of a linear least-squares fit to y is subtracted from y. - constant: only the mean of data is subtrated. - “savitzky-golay”, y is filtered using the Savitzky-Golay filters and the resulting filtered series is subtracted from y. - “emd” (default): Empirical mode decomposition. The last mode is assumed to be the trend and removed from the series
sg_kwargs (dict) – The parameters for the Savitzky-Golay filters. see pyleoclim.utils.filter.savitzy_golay for details.
- Returns
ys – The detrended timeseries.
- Return type
array
See also
pylecolim.utils.filter.savitzky_golay
Filtering using Savitzy-Golay
pylecolim.utils.tsutils.preprocess
pre-processes a times series using standardization and detrending.