sweep_design.spectrum

Module Contents

Classes

Spectrum

A class that describes the spectrum of a signal.

Functions

_input2spectrum_operation(...)

_input2spectrum(→ Spectrum)

Attributes

SP

Instance of Spectrum

SSPR

Instance of Spectrum or Signal or Relation

SSPRN

Instance of Spectrum or Signal or Relation or Number

sweep_design.spectrum.SP

Instance of Spectrum

sweep_design.spectrum.SSPR

Instance of Spectrum or Signal or Relation

sweep_design.spectrum.SSPRN

Instance of Spectrum or Signal or Relation or Number

class sweep_design.spectrum.Spectrum(frequency: Union[sweep_design.core.RelationProtocol, sweep_design.axis.ArrayAxis, sweep_design.help_types.ArrayLike], spectrum_amplitude: sweep_design.help_types.ArrayLike = None, signal: Optional[Spectrum.__init__.signal] = None)[source]

Bases: sweep_design.relation.Relation

A class that describes the spectrum of a signal.

The Spectrum class derived from the Relation class.

Each ‘Spectrum’ can be converted into a Signal using method get_spectrum To convert the Spectrum into a Signal, the method defined in the Config class is used. (Config.spectrum2signal_method). Current method can be overridden by own in Config class.

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

Initialization of instance of Spectrum.

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

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

property frequency: sweep_design.axis.ArrayAxis

Frequency array axis.

Equal to property x. :returns: frequency array axis. :rtype: ArrayAxis

property amplitude: numpy.ndarray

Spectrum amplitude array.

Equal to property y. :returns: spectrum amplitude array. :rtype: np.ndarray

get_signal(time: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, start_time: float = None) sweep_design.signal.Signal[source]

Get signal from spectrum.

Compute the signal from the spectrum.

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

  • None. (signal. Defaults to) –

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

Returns

instance of Signal described this Spectrum.

Return type

signal.Signal

get_amp_spectrum() sweep_design.relation.Relation[source]

Get amplitude spectrum.

Calculate the relationship between the frequency and the absolute value of the spectrum amplitude.

Parameters

self (SP) – instance of Spectrum.

Returns

new instance of Relation.

Return type

Relation

get_phase_spectrum() sweep_design.relation.Relation[source]

Calculate the relationship between frequency and phase of the spectrum.

Parameters

self (SP) – instance of Spectrum.

Returns

new instance of Relation.

Return type

Relation

get_reverse_filter(percent: Union[float, int] = 5.0, subtrack_phase=True, frequency_start: float = None, frequency_end: float = None) SP[source]

Calculate filter of reversed signal.

Parameters
  • self (SP) – instance of Spectrum.

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

  • subtrack_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

new instance of Spectrum.

Return type

SP

add_phase(other: SSPR) SP[source]

Add phase to spectrum.

Parameters
  • self (SP) – instance of Spectrum

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

Returns

new instance of Spectrum.

Return type

SP

sub_phase(other: SSPR) SP[source]

Subtrack phase from spectrum.

Parameters
  • self (SP) – instance of Spectrum

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

Returns

new instance of Spectrum.

Return type

SP

classmethod get_spectrum_from_amp_phase(amplitude_spectrum: sweep_design.relation.Relation, phase_spectrum: sweep_design.relation.Relation) SP[source]

Calculate of the spectrum from the amplitude and phase spectrum.

The spectrum is calculated through the amplitude and phase spectrum using the formula abs*exp(1j*phase).

Parameters
  • cls (Type[SP]) – Spectrum class.

  • amplitude_spectrum (Relation) – Amplitude spectrum is instance of ‘Relation’.

  • phase_spectrum (Relation) – Phase spectrum is instance of ‘Relation’.

Returns

new instance of Spectrum

Return type

SP

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

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

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 Spectrum.

Return type

S

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

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

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 Spectrum.

Return type

S

__add__(a: SSPRN) SP[source]
__sub__(a: SSPRN) SP[source]
__mul__(a: SSPRN) SP[source]
__truediv__(a: SSPRN) SP[source]
__pow__(a: SSPRN) SP[source]
sweep_design.spectrum._input2spectrum_operation(inp: SSPRN) Union[sweep_design.relation.Relation, Spectrum, sweep_design.help_types.Number][source]
sweep_design.spectrum._input2spectrum(inp: SSPR) Spectrum[source]