Signal#

class Signal(samples, sampling_rate, carrier_frequency=0.0, delay=0.0, noise_power=0.0)[source]#

Bases: HDFSerializable, Visualizable

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

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.

append_samples(signal)[source]#

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)[source]#

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

copy()[source]#

Copy this signal model to a new object.

Returns:

A copy of this signal model.

Return type:

Signal

classmethod empty(sampling_rate, num_streams=0, num_samples=0, **kwargs)[source]#

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:

Signal

classmethod from_interleaved(interleaved_samples, scale=True, **kwargs)[source]#

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:

Signal

plot(axes=None, *, title=None, angle=False, space='both', legend=True)[source]#

Plot the current signal in time- and frequency-domain.

(Source code, png, hires.png, pdf)

../_images/core-signal_model-Signal-1.png
Parameters:
  • axes (plt.Axes, optional) – The axis object into which the information should be plotted. If not specified, the routine will generate and return a new figure.

  • title (str, optional) – Title of the generated plot.

  • angle (bool, optional) – Plot the angle of complex frequency bins.

  • space (Literal["time", "frequency", "both"], optional) – Signal space to be plotted. By default, both spaces are visualized.

  • legend (bool, optional) – Add a legend to the plots. Enabled by default.

Return type:

FigureBase

Returns:

The created matplotlib figure. None, if axes were provided.

plot_eye(symbol_duration, axes=None, *, title=None, domain='time', legend=True, linewidth=0.75, symbol_cutoff=0.1)[source]#

Plot the signal model’s eye diagram.

Depending on the domain flag the eye diagram will either be rendered with the time-domain on the plot’s x-axis

(Source code, png, hires.png, pdf)

../_images/core-signal_model-Signal-2.png

or on the complex plane

(Source code, png, hires.png, pdf)

../_images/core-signal_model-Signal-3.png
Parameters:
  • symbol_duration (float) – Assumed symbol repetition interval in seconds. Will be rounded to match the signal model’s sampling rate.

  • line_width (float, optional) – Line width of a single plot line.

  • title (str, optional) – Title of the plotted figure. Eye Diagram by default.

  • domain (Literal["time", "complex"]) – Plotting behaviour of the eye diagram. time by default. See above examples for rendered results.

  • legend (bool, optional) – Display a plot legend. Enabled by default. Only considered when in time domain plotting mode.

  • linewidth (float, optional) – Line width of the eye plot. \(.75\) by default.

  • symbol_cutoff (float, optional) – Relative amount of symbols ignored during plotting. \(0.1\) by default. This is required to properly visualize intersymbol interferences within the communication frame, since special effects may occur at the start and end.

Return type:

FigureBase

resample(sampling_rate, aliasing_filter=True)[source]#

Resample the modeled signal to a different sampling rate.

Parameters:
  • sampling_rate (float) – Sampling rate of the new signal model in Hz.

  • aliasing_filter (bool, optional) – Apply an anti-aliasing filter during downsampling. Enabled by default.

Returns:

The resampled signal model.

Return type:

Signal

Raises:

ValueError – If sampling_rate is smaller or equal to zero.

superimpose(added_signal, resample=True, aliasing_filter=True, stream_indices=None)[source]#

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.

Parameters:
  • added_signal (Signal) – The signal to be superimposed onto this one.

  • resample (bool) – Allow for dynamic resampling during superposition.

  • aliasing_filter (bool, optional) – Apply an anti-aliasing filter during mixing.

  • stream_indices (Sequence[int], optional) – Indices of the streams to be mixed.

Raises:
  • ValueError – If added_signal contains a different number of streams than this signal model.

  • RuntimeError – If resampling is required but not allowd.

  • NotImplementedError – If the delays if this signal and added_signal differ.

Return type:

None

to_interleaved(data_type=<class 'numpy.int16'>, scale=False)[source]#

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)

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

delay: float#
property duration: float#

Signal model duration in time-domain.

Returns:

Duration in seconds.

Return type:

float

property energy: ndarray#

Compute the energy of the modeled signal.

Returns: The energy of each modeled stream within a numpy vector.

filter_order: int = 10#

Order of the filters applied during resampling and supoperosition mixing.

property frequencies: ndarray#

The signal model’s discrete sample points in frequcy domain.

Returns: Numpy vector of frequency bins.

property noise_power: float#

Noise power of the superimposed noise signal.

Returns:

Noise power.

Raises:

ValueError – If the noise power is smaller than zero.

property num_samples: int#

The number of samples within this signal model.

Returns:

The number of samples.

Return type:

int

property num_streams: int#

The number of streams within this signal model.

Returns:

The number of streams.

Return type:

int

property power: ndarray#

Compute the power of the modeled signal.

Returns: The power of each modeled stream within a numpy vector.

property samples: ndarray#

Uniformly sampled complex signal model in time-domain.

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 sampling_rate: float#

The rate at which the modeled signal was sampled.

Returns:

The sampling rate in Hz.

Return type:

float

property timestamps: ndarray#

The sample-points of the signal model.

Returns:

Vector of length T containing sample-timestamps in seconds.

Return type:

np.ndarray

property title: str#

Title of the visualizable.