Filters

class ptsa.data.filters.MorletWaveletFilter(freqs, width=5, output=('power', 'phase'), verbose=True, cpus=1, output_dim='output', complete=True)

Applies a Morlet wavelet transform to a time series, returning the power and phase spectra over time.

Changed in version 2.0.6: Return type is now a TimeSeries to conform with other filter types.

Parameters:

freqs (np.ndarray) – The frequencies to use in the decomposition

Keyword Arguments:
  • width (int) – The width of the wavelet (default: 5)

  • output (Union[Iterable[str], str]) – A string or a list of strings containing power, phase, and/or complex (default: ['power', 'phase'])

  • verbose (bool) – Print out the wavelet parameters (default: False)

  • cpus (int) – Number of threads to use when computing the transform (default: 1).

  • output_dim (str) – Name of the output dimension when returning both power and phase (default: 'output')

  • complete (bool) – Use complete Morlet wavelets with a zero mean, which is required for power and phase accuracy with small wavelet widths. The frequency is kept consistent with standard Morlet wavelets. (default: True)

filter(timeseries)

Apply the constructed filter.

class ptsa.data.filters.MorletWaveletFilterCpp

The same as ptsa.data.filters.MorletWaveletFilter, except it utilizes a C++ thread pool to parallelize the computations.

Additional keyword arguments:

  • cpus (int) - The number of threads to launch

class ptsa.data.filters.ButterworthFilter(freq_range, order=4, filt_type='stop')

Applies Butterworth filter to a time series.

Keyword Arguments:
  • timeseries – TimeSeries object

  • order – Butterworth filter order

  • freq_range (list-like) – Array [min_freq, max_freq] describing the filter range

  • versionchanged: (..) – 2.0: Parameter “time_series” was renamed to “timeseries”.

filter(timeseries)

Applies Butterwoth filter to input time series and returns filtered TimeSeries object.

Returns:

filtered – The filtered time series

Return type:

TimeSeries

class ptsa.data.filters.ResampleFilter(resamplerate, round_to_original_timepoints=False, time_axis_name='time')

Resample a time series to a new sample rate.

Parameters:
  • resamplerate (float) – new sampling frequency

  • round_to_original_timepoints (bool) – Flag indicating if timepoints from original time axis should be reused after proper rounding. Defaults to False

  • time_axis_name (str) – Name of the time axis.

  • versionchanged: (..) – 2.0: Parameter “time_series” was renamed to “timeseries”. Parameter “time_axis_index” was removed; the time axis is assumed to be named “time”

filter(timeseries)

Resample a time series.

Returns:

resampled – resampled time series with sampling frequency set to resamplerate

Return type:

TimeSeries