vtools.butterworth¶
- butterworth(ts, cutoff_period=None, cutoff_frequency=None, order=4)[source]¶
low-pass butterworth-squared filter on a regular time series.
- Parameters
- ts
DataFrame
Must be one or two dimensional, and regular.
- order: int ,optional
The default is 4.
- cutoff_frequency: float,optional
Cutoff frequency expressed as a ratio with Nyquist frequency, should within the range (0,1). For a discretely sampled system, the Nyquist frequency is the fastest frequency that can be resolved by that sampling, which is half the sampling frequency. For example, if the sampling frequency is 1 sample/1 hour, the Nyquist frequency is 1 sample/2 hours. If we want a 36 hour cutoff period, the frequency is 1/36 or 0.0278 cycles per hour. Hence the cutoff frequency argument used here would be 0.0278/0.5 = 0.056.
- cutoff_periodstring or _time_interval
Period corresponding to cutoff frequency. If input as a string, it must be convertible to a regular interval using the same rules as a pandas frequency.. cutoff_frequency and cutoff_period can’t be specified at the same time.
- ts
- Returns
- result
A new regular time series with the same interval as ts.
- Raises
- ValueError
If input order is not even, or input timeseries is not regular, or neither cutoff_period and cutoff_frequency is given while input time series interval is not 15min or 1 hour, or cutoff_period and cutoff_frequency are given at the same time.