GenericSignalGenerator#
- class acoular.signals.GenericSignalGenerator
Bases:
SignalGeneratorGenerate signals from a
SamplesGeneratoror derived object.The
GenericSignalGeneratorclass enables the integration of arbitrary signals into Acoular processing chains. The signal is fetched from a specified data source and optionally scaled by an amplitude factor. It supports looping the signal to match the desired number of samples and can handle signals with multiple channels (only the first channel is used).- Common use cases include:
Injecting custom or pre-recorded signals from HDF5 files.
Creating signals using the
TimeSamplesclass.Generating a continuous or repeated signal for simulations.
Notes
If the signal source has more than one channel, only channel 0 is used.
Examples
Inject a random signal into a processing chain:
>>> import acoular as ac >>> import numpy as np >>> >>> data = np.random.rand(1000, 1) >>> ts = ac.TimeSamples(data=data, sample_freq=51200) >>> sig = ac.GenericSignalGenerator(source=ts) >>> output_signal = sig.signal()
- source = Instance(SamplesGenerator)
The data source from which the signal is fetched. This can be any object derived from
SamplesGenerator.
- amplitude = Float(1.0)
Scaling factor applied to the generated signal. Defaults to
1.0.
- sample_freq = Delegate('source')
Sampling frequency of the output signal, as provided by the
sourceobject.
- num_samples = Property()
The number of samples to generate. Default is the number of samples available in the
source(source.num_samples). If set explicitly, it can exceed the source length, in which case the signal will loop ifloop_signalisTrue.
- loop_signal = Bool(True)
If
True(default), the signal is repeated to meet the requestednum_samples. IfFalse, the signal stops once the source data is exhausted.
- digest = Property( β¦
A unique checksum identifier based on the object properties. (read-only)
- signal()
Deliver the signal from the specified source.
- Returns:
numpy.arrayoffloatsThe resulting signal, scaled by the
amplitudeattribute, with a length matchingnum_samples.
Warning
A warning is raised if the source has more than one channel.