PeriodicSignalGenerator#
- class acoular.signals.PeriodicSignalGenerator
Bases:
SignalGeneratorAbstract base class for periodic signal generators.
The
PeriodicSignalGeneratorclass defines the common interface for allSignalGenerator-derived classes with periodic signals. This class may be used as a base for class handling periodic signals that can be characterized by their frequency, phase and amplitude.It should not be used directly as it contains no real functionality.
See also
SineGeneratorGenerate a sine signal.
- freq
The frequency of the signal. Default is
1000.0.
- phase
The phase of the signal (in radians). Default is
0.0.
- amplitude
The amplitude of the signal. Default is
1.0.
- digest
Internal identifier based on generator properties. (read-only)
- abstractmethod signal()
Deliver the signal.
- usignal(factor)
Resample the signal at a higher sampling frequency.
This method uses Fourier transform-based resampling to deliver the signal at a sampling frequency that is a multiple of the original
sample_freq. The resampled signal has a length offactor * num_samples.- Parameters:
- factorint
The resampling factor. Defines how many times larger the new sampling frequency is compared to the original
sample_freq.
- Returns:
numpy.ndarrayThe resampled signal as a 1D array of floats.
Notes
This method relies on the
scipy.signal.resample()function for resampling.Examples
Resample a signal by a factor of 4:
>>> from acoular import SineGenerator # Class extending SignalGenerator >>> sg = SineGenerator(sample_freq=100.0, num_samples=1000) >>> resampled_signal = sg.usignal(4) >>> len(resampled_signal) 4000
- sample_freq
Sampling frequency of the signal in Hz. Default is
1.0.
- num_samples
The number of samples to generate for the signal.