PyfftwFFTBase

class baseband_tasks.fourier.pyfftw.PyfftwFFTBase(direction)[source] [edit on github]

Bases: baseband_tasks.fourier.base.FFTBase

Single pre-defined FFT based on pyfftw.FFTW.

To use, initialize an instance, then call the instance to perform the transform.

Parameters
direction‘forward’ or ‘backward’, optional

Direction of the FFT.

Attributes Summary

axis

Axis over which to perform the FFT.

direction

Direction of the FFT ('forward' or 'backward').

frequency

FFT sample frequencies.

frequency_dtype

Data type of the frequency-domain data.

frequency_shape

Shape of the frequency-domain data.

ortho

Use orthogonal normalization.

sample_rate

Rate of samples in the time domain.

time_dtype

Data type of the time-domain data.

time_shape

Shape of the time-domain data.

Methods Summary

__call__(a)

Perform FFT.

inverse()

Return inverse transform.

Attributes Documentation

axis

Axis over which to perform the FFT.

direction

Direction of the FFT (‘forward’ or ‘backward’).

frequency

FFT sample frequencies.

Uses numpy.fft.fftfreq for complex time-domain data, which returns, for an array of length n and a time-domain sample_rate,

f = [0, 1, …, n/2-1, -n/2, …, -1] * sample_rate / n

if n is even, and

f = [0, 1, …, (n-1)/2, -(n-1)/2, …, -1] * sample_rate / n

if n is odd.

For real time-domain data, numpy.fft.rfftfreq is used, which returns

f = [0, 1, …, n/2-1, n/2] * sample_rate / n

if n is even, and

f = [0, 1, …, (n-1)/2-1, (n-1)/2] * sample_rate / n

if n is odd.

If sample_rate is None, a unitless rate of 1 is used.

Returns
frequencyndarray or array of Quantity

Sample frequencies, with shape (len(f), 1, …, 1). The trailing dimensions of length unity are to facilitate broadcasting when operating on frequency.

frequency_dtype

Data type of the frequency-domain data.

frequency_shape

Shape of the frequency-domain data.

ortho

Use orthogonal normalization.

If True, both forward and backward transforms are scaled by 1 / sqrt(n), where n is the size of time-domain array’s transform axis. If False, forward transforms are unscaled and inverse ones scaled by 1 / n.

sample_rate

Rate of samples in the time domain.

time_dtype

Data type of the time-domain data.

time_shape

Shape of the time-domain data.

Methods Documentation

__call__(a) [edit on github]

Perform FFT.

To display the direction of the transform and shapes and dtypes of the arrays, use print or repr.

Parameters
aarray_like

Input data.

Returns
outndarray

Transformed data.

inverse()[source] [edit on github]

Return inverse transform.

If the type of fourier transform allows it (e.g., PyFFTW), the inverse transform will have its input array matched to the output array and vice versa, i.e., a sequence transforming some input data, do in-place calculations on the output fourier spectrum, and then transform back, will overwrite the input data. If this is not wanted, instantiate a new class directly (e.g., forward.__class__(direction='backward').

Returns
inverse_transformFFTBase subclass

Returns a new instance of the calling class with reversed transform direction.