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 generator result() in block-wise manner. They are not intended to be used directly, but to be subclassed by classes that implement the actual signal processing.

Inheritance diagram of acoular.base

Generator

Interface for any generating signal processing block.

SamplesGenerator

Interface for any generating multi-channel time domain signal processing block.

SpectraGenerator

Interface for any generating multi-channel signal frequency domain processing block.

InOut

Abstract base class receiving from a source and returning signals in the same domain.

TimeOut

Abstract base class receiving from a source and returning time domain signals.

SpectraOut

Abstract base class receiving from a source and returning frequency domain signals.

class acoular.base.Generator#

Bases: ABCHasStrictTraits

Interface 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 trait digest is 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 = Float(1.0)#

Sampling frequency of the signal, defaults to 1.0

num_samples = CInt#

Number of signal samples

num_channels = CInt#

Number of channels

digest = Property(depends_on=['sample_freq', 'num_samples', 'num_channels'])#

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, …)

class acoular.base.SamplesGenerator#

Bases: Generator

Interface 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 = Property(depends_on=['sample_freq', 'num_samples', 'num_channels'])#

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).

class acoular.base.SpectraGenerator#

Bases: Generator

Interface 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 = CInt#

Number of frequencies

freqs = CArray#

1-D array of frequencies

block_size = CInt#

The length of the block used to calculate the spectra

digest = Property(depends_on=['sample_freq', 'num_samples', 'num_channels', 'num_freqs', 'block_size'])#

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:
numinteger

This parameter defines the size of the number of snapshots to be yielded. Defaults to 1.

Yields:
numpy.ndarray

A two-dimensional block of shape (num, num_channels * num_freqs).

class acoular.base.TimeOut#

Bases: SamplesGenerator

Abstract base class receiving from a source and returning time domain signals.

It provides a base class that can be used to create signal processing blocks that receive data from any generating source and generates a time signal output via the generator result() in block-wise manner.

source = Instance(Generator)#

Data source; Generator or derived object.

sample_freq = Delegate('source')#

Sampling frequency of output signal, as given by source.

num_channels = Delegate('source')#

Number of channels in output, as given by source.

num_samples = Delegate('source')#

Number of samples in output, as given by source.

digest = Property(depends_on=['source.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.SpectraOut#

Bases: SpectraGenerator

Abstract base class receiving from a source and returning frequency domain signals.

It provides a base class that can be used to create signal processing blocks that receive data from any generating source domain and generates a frequency domain output via the generator result() in block-wise manner.

source = Instance(Generator)#

Data source; Generator or derived object.

sample_freq = Delegate('source')#

Sampling frequency of output signal, as given by source.

num_channels = Delegate('source')#

Number of channels in output, as given by source.

num_samples = Delegate('source')#

Number of snapshots in output, as given by source.

num_freqs = Delegate('source')#

Number of frequencies in output, as given by source.

freqs = Delegate('source')#

1-D array of frequencies, as given by source.

block_size = Delegate('source')#

The size of the block used to calculate the spectra

digest = Property(depends_on=['source.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.

numinteger

This parameter defines the the number of snapshots to be yielded. Defaults to 1.

Yields:
numpy.ndarray

A two-dimensional block of shape (num, num_channels * num_freqs).

class acoular.base.InOut#

Bases: SamplesGenerator, SpectraGenerator

Abstract base class receiving from a source and 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 source and generates an output via the generator result() in block-wise manner.

source = Instance(Generator)#

Data source; Generator or derived object.

sample_freq = Delegate('source')#

Sampling frequency of output signal, as given by source.

num_channels = Delegate('source')#

Number of channels in output, as given by source.

num_freqs = Delegate('source')#

Number of frequencies in output, as given by source.

num_samples = Delegate('source')#

Number of samples / snapshots in output, as given by source.

digest = Property(depends_on=['source.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, …)