sweep_design.signal

Module Contents

Classes

Signal

Class describing some kind of signal.

Functions

_inp2signal_operation(...)

_inp2signal(→ Signal)

Attributes

S

Instance of Signal.

SSPR

Instance of Signal or Spectrum or Relation.

SSPRN

Instance of Signal or Spectrum or Relation or Number.

sweep_design.signal.S

Instance of Signal.

sweep_design.signal.SSPR

Instance of Signal or Spectrum or Relation.

sweep_design.signal.SSPRN

Instance of Signal or Spectrum or Relation or Number.

class sweep_design.signal.Signal(time: Union[sweep_design.core.RelationProtocol, sweep_design.axis.ArrayAxis, sweep_design.help_types.ArrayLike], amplitude: sweep_design.help_types.ArrayLike = None, spectrum: Optional[Signal.__init__.spectrum] = None)[source]

Bases: sweep_design.relation.Relation

Class describing some kind of signal.

The Signal class inherits the Relation class.

Each signal can be converted into a spectrum.Spectrum using method get_spectrum. To convert the signal into a spectrum, the method defined in the Config class is used. (Config.signal2spectrum_method). Current method can be overridden by own in Config class.

When performing arithmetic operations on instances of the spectrum.Spectrum class, an instance of the Signal class will be extracted from the spectrum.Spectrum instance, and arithmetic operations will be performed on this instance. An instance of Relation class will be converted into the instance of Signal class.

Initialization of instance of Signal.

Parameters
  • time (Union[RelationProtocol, ArrayAxis, ArrayLike]) – An instance of Relation class or inherited from it, or ArrayLike, or array_like object containing numbers (real or complex).

  • amplitude (ArrayLike, optional) – None or array_like object containing numbers (real or complex). Defaults to None.

property time: sweep_design.axis.ArrayAxis

Time array axis.

Equal to property x.

Returns

time array axis.

Return type

ArrayAxis

property amplitude: numpy.ndarray

Amplitude array.

Equal to property ‘y’

Returns

amplitude array.

Return type

np.ndarray

get_spectrum(frequency: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, is_start_zero=False) sweep_design.spectrum.Spectrum[source]

Get spectrum from signal.

Parameters
  • frequency (ArrayAxis, int, optional) – Define frequency to calculate

  • None. (spectrum. Defaults to) –

  • is_start_zero (bool, optional) – If True then the signal will be shifted to zero. Defaults to False.

Returns

instance of spectrum.Spectrum described this Signal.

Return type

spectrum.Spectrum

get_amplitude_spectrum(frequency: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, is_start_zero=False) sweep_design.relation.Relation[source]

Extract amplitude spectrum from spectrum.Spectrum.

Method get_spectrum is used to get instance of spectrum.Spectrum. The amplitude spectrum is calculated from it using get_amp_spectrum method.

Parameters

frequency (ArrayAxis, int, optional) –

Define frequency to calculate spectrum. Defaults to None.

is_start_zero (bool, optional): If True then the signal will be

shifted to zero. Defaults to False.

Returns

amplitude spectrum expected Relation instance.

Return type

Relation

get_phase_spectrum(frequency: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, is_start_zero=False) sweep_design.relation.Relation[source]

Extract amplitude spectrum from spectrum.Spectrum.

Method get_spectrum is used to get instance of spectrum.Spectrum. The amplitude spectrum is calculated from it using get_amp_spectrum method.

Parameters
  • frequency (ArrayAxis, int, optional) – Define frequency to calculate

  • None. (spectrum. Defaults to) –

  • is_start_zero (bool, optional) – If True then the signal will be shifted to zero. Defaults to False.

Returns

amplitude spectrum expected Relation instance.

Return type

Relation

shift(x_shift: sweep_design.help_types.RealNumber = 0) S[source]

Shifting of relation on the x-axis.

Parameters
  • self (R) – instance of Relation

  • x_shift (Number, optional) – Number of displacement on the x-axis.

  • 0. (Defaults to) –

Returns

new instance of Relation

Return type

R

get_reverse_signal(percent: Union[float, int] = 5.0, subtract_phase: bool = True, frequency_start: float = None, frequency_end: float = None) S[source]

Calculate reversed signal.

Parameters
  • self (S) – instance of Signal.

  • percent (Union[float, int], optional) – level of added white noise in percent. Defaults to 5.0.

  • subtract_phase (bool, optional) – If True performs phase subtraction, If False succeeds, add the phase. Defaults to True.

  • frequency_start (float, optional) – The start frequency. Defaults to None.

  • frequency_end (float, optional) – The end frequency. Defaults to None.

Returns

instance of Signal.

Return type

S

add_phase(other: SSPR) S[source]

Add phase to signal.

Parameters
  • self (S) – instance of Signal.

  • other (SSPR) – Extracting the spectrum.Spectrum from the object and adding the phase spectrum.Spectrum to the Signal.

Returns

new instance of Signal.

Return type

S

sub_phase(other: SSPR) S[source]

Subtrack phase from signal.

Parameters
  • self (S) – instance of Signal

  • other (SSPR) – Extracting the spectrum from the object and subtrack the phase spectrum from the signal.

Returns

new instance of Signal.

Return type

S

classmethod convolve(r1: SSPR, r2: SSPR) S[source]

Convolution of two instances of Relation and return new instance of Signal. Instances of spectrum.Spectrum will be converted to Signal

Parameters
  • cls (Type[S]) – Signal class.

  • r1 (SSPR) – instance of Relation or subclass of ‘Relation’

  • r2 (SSPR) – instance of Relation or subclass of ‘Relation’

Returns

new instance of Signal.

Return type

S

classmethod correlate(r1: SSPR, r2: SSPR) S[source]

Correlation of two instances of Relation and return new instance of Signal. Instance of spectrum.Spectrum will be converted to Signal

Parameters
  • cls (Type[S]) – Signal class.

  • r1 (SSPR) – instance of Relation or subclass of ‘Relation’

  • r2 (SSPR) – instance of Relation or subclass of ‘Relation’

Returns

new instance of Signal.

Return type

S

__add__(a: SSPRN) S[source]
__sub__(a: SSPRN) S[source]
__mul__(a: SSPRN) S[source]
__truediv__(a: SSPRN) S[source]
__pow__(a: SSPRN) S[source]
sweep_design.signal._inp2signal_operation(inp: SSPRN) Union[sweep_design.relation.Relation, Signal, sweep_design.help_types.Number][source]
sweep_design.signal._inp2signal(inp: SSPR) Signal[source]