Signal Modeling
- class Signal(samples, sampling_rate, carrier_frequency=0.0, delay=0.0, noise_power=0.0)
Bases:
object
Base class of signal models in HermesPy.
- __samples
An MxT matrix containing uniformly sampled base-band samples of the modeled signal. M is the number of individual streams, T the number of available samples.
- Type
np.ndarray
- __sampling_rate
Sampling rate of the modeled signal in Hz (in the base-band).
- Type
float
- __carrier_frequency
Carrier-frequency of the modeled signal in the radio-frequency band, i.e. the central frequency in Hz.
- Type
float
- delay
Delay of the signal in seconds.
- Type
float
Signal model initialization.
- Parameters
samples (np.ndarray) – An MxT matrix containing uniformly sampled base-band samples of the modeled signal. M is the number of individual streams, T the number of available samples.
sampling_rate (float) – Sampling rate of the modeled signal in Hz (in the base-band).
carrier_frequency (float, optional) – Carrier-frequency of the modeled signal in the radio-frequency band, i.e. the central frequency in Hz. Zero by default.
delay (float, optional) – Delay of the signal in seconds. Zero by default.
noise_power (float, optional) – Power of the noise superimposed to this signal model. Zero by default.
- delay: float
- classmethod empty(sampling_rate, num_streams=0, num_samples=0, **kwargs)
Create a new empty signal model instance.
- Parameters
sampling_rate (float) – Sampling rate of the modeled signal in Hz (in the base-band).
num_streams (int, optional) – Number of signal streams within this empty model.
num_samples (int, optional) – Number of signal samples within this empty model.
kwargs – Additional initialization arguments, piped through to the class init.
- Return type
- property samples: numpy.ndarray
Uniformly sampled c
- Returns
An MxT matrix of samples, where M is the number of individual streams and T the number of samples.
- Return type
np.ndarray
- property num_streams: int
The number of streams within this signal model.
- Returns
The number of streams.
- Return type
int
- property num_samples: int
The number of samples within this signal model.
- Returns
The number of samples.
- Return type
int
- property sampling_rate: float
The rate at which the modeled signal was sampled.
- Returns
The sampling rate in Hz.
- Return type
float
- property carrier_frequency: float
The center frequency of the modeled signal in the radio-frequency transmit band.
- Returns
The carrier frequency in Hz.
- Return type
float
- property noise_power: float
Noise power of the superimposed noise signal.
- Return type
float
- Returns
Noise power.
- Raises
ValueError – If the noise power is smaller than zero.
- property power: numpy.ndarray
Compute the power of the modeled signal.
- Return type
ndarray
- Returns
np.ndarray:: The power of each modeled stream within a numpy vector.
- copy()
Copy this signal model to a new object.
- Returns
A copy of this signal model.
- Return type
- resample(sampling_rate)
Resample the modeled signal to a different sampling rate.
- Parameters
sampling_rate (float) – Sampling rate of the new signal model in Hz.
- Returns
The resampled signal model.
- Return type
- Raises
ValueError – If sampling_rate is smaller or equal to zero.
- superimpose(added_signal)
Superimpose an additive signal model to this model.
Internally re-samples added_signal to this model’s sampling rate, if required. Mixes added_signal according to the carrier-frequency distance.
- Raises
ValueError – If added_signal contains a different number of streams than this signal model.
NotImplementedError – If the delays if this signal and added_signal differ.
- Return type
None
- property timestamps: numpy.ndarray
The sample-points of the signal model.
- Returns
Vector of length T containing sample-timestamps in seconds.
- Return type
np.ndarray
- plot(title=None, angle=False, axes=None, space='both', legend=True)
Plot the current signal in time- and frequency-domain.
- Parameters
title (str, optional) – Figure title.
angle (bool, optional) – Plot the angle of complex frequency bins.
axes (Optional[np.ndarray], optional) – Axes to which the graphs should be plotted to. If none are provided, the routine will create a new figure.
space (Union['time', 'frequency', 'both'], optional) – Signal space to be plotted. By default, both spaces are visualized.
- Returns
The created matplotlib figure. None, if axes were provided.
- Return type
Optional[plt.figure]
- append_samples(signal)
Append samples in time-domain to the signal model.
- Parameters
signal (Signal) – The signal to be appended.
- Raises
ValueError – If the number of streams don’t align.
- Return type
None
- append_streams(signal)
Append streams to the signal model.
- Parameters
signal (Signal) – The signal to be appended.
- Raises
ValueError – If the number of samples don’t align.
- Return type
None
- property duration: float
Signal model duration in time-domain.
- Returns
Duration in seconds.
- Return type
float
- to_interleaved(data_type=<class 'numpy.int16'>, scale=True)
Convert the complex-valued floating-point model samples to interleaved integers.
- Parameters
data_type (optional) – Numpy resulting data type.
scale (bool, optional) – Scale the floating point values to stretch over the whole range of integers.
- Returns
Numpy array of interleaved samples. Will contain double the samples in time-domain.
- Return type
samples (np.ndarray)
- classmethod from_interleaved(interleaved_samples, scale=True, **kwargs)
Initialize a signal model from interleaved samples.
- Parameters
interleaved_samples (np.ndarray) – Numpy array of interleaved samples.
scale (bool, optional) – Scale the samples after interleaving
**kwargs – Additional class initialization arguments.
- Return type