base#
Implements base classes for signal processing blocks in Acoular.
The classes in this module are abstract base classes that provide a common interface for all classes
that generate an output via the result generator in block-wise manner. They are not intended to
be used directly, but to be subclassed by classes that implement the actual signal processing.
Interface for any generating signal processing block. |
|
Interface for any generating multi-channel time domain signal processing block. |
|
Interface for any generating multi-channel signal frequency domain processing block. |
|
Abstract base class receiving from a |
|
Abstract base class receiving from a |
|
Time-domain block that requires a source with a known length. |
|
Abstract base class receiving from a |
- class acoular.base.Generator#
Bases:
ABCHasStrictTraitsInterface for any generating signal processing block.
It provides a common interface for all classes, which generate an output via the generator
result()in block-wise manner. It has a common set of traits that are used by all classes that implement this interface. This includes the sampling frequency of the signal (sample_freq), the number of samples (num_samples), and the number of channels (num_channels). A private traitdigestis used to store the internal identifier of the object, which is a hash of the object’s attributes. This is used to check if the object’s internal state has changed.- sample_freq#
Sampling frequency of the signal, defaults to 1.0
- num_samples#
Number of signal samples.
-1denotes an indefinite stream.
- num_channels#
Number of channels
- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num)#
Python generator that yields the output block-wise.
This method needs to be implemented by the derived classes.
- Parameters:
- numint
The size of the first dimension of the blocks to be yielded
- Yields:
- numpy.ndarray
Two-dimensional output data block of shape (num, …).
Notes
Yielded blocks remain stable after the generator advances. Implementations must not modify blocks received from their source. Callers should treat blocks as read-only because some generators return views to avoid copying.
- class acoular.base.SamplesGenerator#
Bases:
GeneratorInterface for any generating multi-channel time domain signal processing block.
It provides a common interface for all SamplesGenerator classes, which generate an output via the generator
result()in block-wise manner. This class has no real functionality on its own and should not be used directly.- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num)#
Python generator that yields the output block-wise.
- Parameters:
- numint
This parameter defines the size of the blocks to be yielded (i.e. the number of samples per block)
- Yields:
- numpy.ndarray
The two-dimensional time-data block of shape (num, num_channels).
- sample_freq#
Sampling frequency of the signal, defaults to 1.0
- num_samples#
Number of signal samples.
-1denotes an indefinite stream.
- num_channels#
Number of channels
- class acoular.base.SpectraGenerator#
Bases:
GeneratorInterface for any generating multi-channel signal frequency domain processing block.
It provides a common interface for all SpectraGenerator classes, which generate an output via the generator
result()in block-wise manner. This class has no real functionality on its own and should not be used directly.- num_freqs#
Number of frequencies
- freqs#
1-D array of frequencies
- block_size#
The length of the block used to calculate the spectra
- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num=1)#
Python generator that yields the output block-wise.
- Parameters:
- numint, optional
Maximum number of spectral snapshots per block to yield. Defaults to 1.
- Yields:
- numpy.ndarray
Two-dimensional spectral data block with shape
(n, num_freqs * num_channels), wherenis the number of snapshots in the yielded block and is at mostnum. The final block may contain fewer thannumsnapshots.The second axis stores the spectra in frequency-major order with channels interlaced for each frequency bin. Reshagping a block with
block.reshape(n, num_freqs, num_channels)gives direct access to the data by snapshot, frequency, and channel.
- sample_freq#
Sampling frequency of the signal, defaults to 1.0
- num_samples#
Number of signal samples.
-1denotes an indefinite stream.
- num_channels#
Number of channels
- class acoular.base.TimeOut#
Bases:
SamplesGeneratorAbstract base class receiving from a
sourceand returning time domain signals.It provides a base class that can be used to create signal processing blocks that receive data from any generating
sourceand generates a time signal output via theresult()generator in block-wise manner.- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num)#
Python generator that processes the source data and yields the time-signal block-wise.
This method needs to be implemented by the derived classes.
- Parameters:
- numint
This parameter defines the size of the blocks to be yielded (i.e. the number of samples per block)
- Yields:
- numpy.ndarray
Two-dimensional output data block of shape (num, num_channels)
- class acoular.base.FiniteTimeOut#
Bases:
TimeOutTime-domain block that requires a source with a known length.
- abstractmethod result(num)#
Python generator that processes the source data and yields the time-signal block-wise.
This method needs to be implemented by the derived classes.
- Parameters:
- numint
This parameter defines the size of the blocks to be yielded (i.e. the number of samples per block)
- Yields:
- numpy.ndarray
Two-dimensional output data block of shape (num, num_channels)
- digest#
A unique identifier for the generator, based on its properties. (read-only)
- class acoular.base.SpectraOut#
Bases:
SpectraGeneratorAbstract base class receiving from a
sourceand returning frequency domain signals.It provides a base class that can be used to create signal processing blocks that receive data from any generating
sourcedomain and generates a frequency domain output via theresult()generator in block-wise manner.- block_size#
The size of the block used to calculate the spectra
- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num=1)#
Python generator that processes the source data and yields the output block-wise.
This method needs to be implemented by the derived classes.
- Parameters:
- numint, optional
Maximum number of spectral snapshots per block to yield. Defaults to 1.
- Yields:
- numpy.ndarray
Two-dimensional spectral data block with shape (n,
num_freqs*num_channels), wherenis the number of snapshots in the yielded block and is at mostnum. The final block may contain fewer thannumsnapshots.The second axis stores the spectra in frequency-major order with channels interlaced for each frequency bin. Reshaping a block with
block.reshape(n, num_freqs, num_channels)gives direct access to the data by snapshot, frequency, and channel.
- class acoular.base.InOut#
Bases:
SamplesGenerator,SpectraGeneratorAbstract base class receiving from a
sourceand returning signals in the same domain.It provides a base class that can be used to create signal processing blocks that receive data from any generating
sourceand generates an output via theresult()generator in block-wise manner.- digest#
A unique identifier for the generator, based on its properties. (read-only)
- abstractmethod result(num)#
Python generator that processes the source data and yields the output block-wise.
This method needs to be implemented by the derived classes.
- Parameters:
- numint
The size of the first dimension of the blocks to be yielded
- Yields:
- numpy.ndarray
Two-dimensional output data block of shape (num, …)
- freqs#
1-D array of frequencies
- block_size#
The length of the block used to calculate the spectra