FourierTransform

FourierTransform class definition.

class FourierTransform(amplitude, frequency, fnyq=None, dtype=<class 'complex'>)

Bases: object

A class for manipulating Fourier transforms.

Variables:
  • frequency (ndarray) – Frequency vector of the transform in Hz.
  • amplitude (ndarray) – The transform’s amplitude in the same units as the input. May be 1D or 2D. If 2D each row corresponds to a unique FFT, where each column corresponds to an entry in frequency.
  • fnyq (float) – The Nyquist frequency associated with the time series used to generate the Fourier transform. Note this may or may not be equal to frequency[-1].
__init__(amplitude, frequency, fnyq=None, dtype=<class 'complex'>)

Initialize a FourierTransform object.

Parameters:
  • amplitude (ndarray) – Fourier transform amplitude.
  • frequency (ndarray) – Linearly spaced frequency vector for Fourier transform.
  • fnyq (float, optional) – Nyquist frequency of Fourier transform, default is max(frequency).
Returns:

FourierTransform – Initialized with amplitude and frequency information.

amp
amplitude
static fft(amplitude, dt, **kwargs)

Compute the fast-Fourier transform (FFT) of a time series.

Parameters:
  • amplitude (ndarray) – Denotes the time series amplitude. If amplitude is 1D each sample corresponds to a single time step. If amplitude is 2D each row corresponds to a particular section of the time record (i.e., time window) and each column corresponds to a single time step.
  • dt (float) – Denotes the time step between samples in seconds.
  • **kwargs (dict) – Additional keyard arguments to fft.
Returns:

Tuple – Of the form (frq, fft) where:

frq : ndarray

Positive frequency vector between zero and the Nyquist frequency (if even) or near the Nyquist (if odd) in Hz.

fft : ndarray

Complex amplitudes for the frequencies between zero and the Nyquist (if even) or near the Nyquist (if odd) with units of the input amplitude. If amplitude is a 2D array fft will also be a 2D array where each row is the FFT of each row of amplitude.

frequency
classmethod from_timeseries(timeseries, **fft_kwargs)

Create FourierTransform from TimeSeries.

Parameters:
  • timeseries (TimeSeries) – TimeSeries object to be transformed.
  • **fft_kwargs (dict) – Custom settings for fft.
Returns:

FourierTransform – Initialized with information from TimeSeries.

frq
imag

Imaginary component of complex FFT amplitude.

mag

Magnitude of complex FFT amplitude.

phase

Phase of complex FFT amplitude in radians.

real

Real component of complex FFT amplitude.

resample(minf, maxf, nf, res_type='log', inplace=False)

Resample FourierTransform over a specified range.

Parameters:
  • minf (float) – Minimum value of resample.
  • maxf (float) – Maximum value of resample.
  • nf (int) – Number of resamples.
  • res_type ({“log”, “linear”}, optional) – Type of resampling, default value is log.
  • inplace (bool, optional) – Determines whether resampling is done in place or if a copy is to be returned. By default the resampling is not done inplace (i.e., inplace=False).
Returns:

None or Tuple

If inplace=True

None, method edits the internal attribute amp.

If inplace=False

A tuple of the form (frequency, amplitude) where frequency is the resampled frequency vector and amplitude is the resampled amplitude vector if amp is 1D or array if amp is 2D.

Raises:
  • ValueError: – If maxf, minf, or nf are illogical.
  • NotImplementedError – If res_type is not among those options specified.
smooth_konno_ohmachi(bandwidth=40.0)

Apply Konno and Ohmachi smoothing.

Parameters:bandwidth (float, optional) – Width of smoothing window, default is 40.
Returns:None – Modifies the internal attribute amp to equal the smoothed value of mag.
smooth_konno_ohmachi_fast(frequencies, bandwidth=40)

Apply fast Konno and Ohmachi smoothing.

Parameters:
  • frequencies (array-like) – Frequencies at which the smoothing is performed. If you choose to use all of the frequencies from the FFT for this parameter you should not expect much speedup over smooth_konno_ohmachi.
  • bandwidth (float, optional) – Width of smoothing window, default is 40.
Returns:

None – Modifies the internal attribute amp to equal the smoothed value of mag.