RFFT¶
- class acoular.fprocess.RFFT¶
Bases:
BaseSpectra
,SpectraOut
Compute the one-sided Fast Fourier Transform (FFT) for real-valued multichannel time data.
The FFT is performed block-wise, dividing the input data into blocks of length specified by the
block_size
attribute. A window function can be optionally applied to each block before the FFT calculation, controlled via thewindow
attribute.This class provides flexibility in scaling the FFT results for different use cases, such as preserving amplitude or energy, by setting the
scaling
attribute.- source = Instance(SamplesGenerator)¶
Data source; an instance of
SamplesGenerator
or a derived object. This provides the input time-domain data for FFT processing.
- workers = Union(Int(), None, default_value=None, desc='number of workers to use')¶
The number of workers to use for FFT calculation. If set to a negative value, all available logical CPUs are used. Default is
None
, which relies on thescipy.fft.rfft()
implementation.
- scaling = Enum('none', 'energy', 'amplitude')¶
Defines the scaling method for the FFT result. Options are:
'none'
: No scaling is applied.'energy'
: Compensates for energy loss in the FFT result due to truncation, doubling the values for frequencies other than DC and the Nyquist frequency.'amplitude'
: Scales the result so that the amplitude of discrete tones is independent of the block size.
- block_size = Property()¶
The length of each block of time-domain data used for the FFT. Must be an even number. Default is
1024
.
- num_freqs = Property(depends_on=['_block_size'])¶
The number of frequency bins in the FFT result, calculated as
block_size // 2 + 1
.
- num_samples = Property(depends_on=['source.num_samples', '_block_size'])¶
The total number of snapshots (blocks) available in the FFT result, determined by the size of the input data and the block size.
- freqs = Property()¶
A 1-D array containing the Discrete Fourier Transform sample frequencies corresponding to the FFT output.
- digest = Property(depends_on=['source.digest', 'scaling', 'precision', '_block_size', 'window', 'overlap'])¶
A unique identifier based on the process properties.
- result(num=1)¶
Yield the FFT results block-wise as multi-channel spectra.
This generator processes the input data block-by-block, applying the specified window function and FFT parameters. The output consists of the FFT spectra for each block, scaled according to the selected
scaling
method.- Parameters:
- num
int
, optional Number of multi-channel spectra (snapshots) per block to return. Default is
1
.
- num
- Yields:
numpy.ndarray
A block of FFT spectra with shape (num,
num_channels
*
num_freqs
). The final block may contain fewer thannum
spectra if the input data is insufficient to fill the last block.
Notes
The generator compensates for energy or amplitude loss based on the
scaling
attribute.If the input data source provides fewer samples than required for a complete block, the remaining spectra are padded or adjusted accordingly.